在Linux中挂载NFS的时候,你可能遇到如题所示的错误,具体如下:

[root@cdh2 ~]# mount cdh1:/software /software




mount.nfs: Connection timed out
[root@cdh2 ~]# 
[root@cdh2 ~]# service nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
[root@cdh2 ~]# 
[root@cdh2 ~]# showmount -e cdh1
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
[root@cdh2 ~]# 
[root@cdh2 ~]# ping cdh1 -c 3
PING cdh1 (10.158.1.111) 56(84) bytes of data.
64 bytes from cdh1 (10.158.1.111): icmp_seq=1 ttl=64 time=0.409 ms
64 bytes from cdh1 (10.158.1.111): icmp_seq=2 ttl=64 time=0.469 ms
64 bytes from cdh1 (10.158.1.111): icmp_seq=3 ttl=64 time=0.523 ms

--- cdh1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.409/0.467/0.523/0.046 ms
[root@cdh2 ~]#

其实,服务端NFS是启动的:

[root@cdh1 software]# showmount -e localhost
Export list for localhost:
/software 10.158.1.0/24
[root@cdh1 software]# 

造成这个问题的原因是服务端的防火墙拦截:

[root@cdh1 software]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

[root@cdh1 software]#

将防火墙关掉就好了:

[root@cdh1 software]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@cdh1 software]# 

再看看:

[root@cdh2 ~]# showmount -e cdh1
Export list for cdh1:
/software 10.158.1.0/24
[root@cdh2 ~]# 
[root@cdh2 ~]# mount cdh1:/software /software
[root@cdh2 ~]# 
[root@cdh2 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_cdh2-lv_root
                       50G  3.0G   44G   7% /
tmpfs                 7.9G  224K  7.9G   1% /dev/shm
/dev/sda1             477M   41M  412M   9% /boot
/dev/mapper/vg_cdh2-lv_home
                       22G   44M   21G   1% /home
cdh1:/software         50G   11G   37G  23% /software
[root@cdh2 ~]# 

——————————————
Done。

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒