简单配置了NFS,nfs的设置到不复杂,本机测试通过。但是客户端在卸载时或挂载文件/磁分区时,总出现错误,类似以下:
[root@node1 ~]# showmount -e 192.168.0.26 mount clntudp_create: RPC: Port mapper failure - RPC: Unable to receive[root@node1 ~]# mount -t nfs 192.168.0.26:/data /mnt mount: mount to NFS server '192.168.0.26' failed: timed out (retrying). mount: mount to NFS server '192.168.0.26' failed: timed out (retrying). mount: mount to NFS server '192.168.0.26' failed: timed out (giving up)
在nfs服务器端中iptabes里面开放了如下的端口111:tcp 111:udp 2049:tcp 2049:udp,测试还是报错。后来,经测试关闭防火墙就没问题。开启防火墙就出现上述问题。后来,经查询是NFS端口没有完全通过防火墙导致。
NFS主要用到的端口有:111- portmapper, 875 - rquotad,2049-nfs,udp:32769-nlockmgr(tcp 32803-nlockmgr),892-mountd..
分别把以上端口(程序所用端口)加入iptables允许其通过即可。
编辑配置文件为 /etc/sysconfig/nfs设置端口号:(添加红色字体即可)
# vi /etc/sysconfig/nfsRQUOTAD_PORT=875LOCKD_TCPPORT=32803LOCKD_UDPPORT=32769MOUNTD_PORT=892 重启相关服务 # /etc/init.d/portmap restart # /etc/init.d/nfs restart 查看服务运行的相关端口情况 [root@bj data]# rpcinfo -p 程序 版本 协议 端口 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 100024 1 udp 709 status 100024 1 tcp 712 status 100011 1 udp 875 rquotad 100011 2 udp 875 rquotad 100011 1 tcp 875 rquotad 100011 2 tcp 875 rquotad 100003 2 udp 2049 nfs 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100021 1 udp 32769 nlockmgr 100021 3 udp 32769 nlockmgr 100021 4 udp 32769 nlockmgr 100021 1 tcp 32803 nlockmgr 100021 3 tcp 32803 nlockmgr 100021 4 tcp 32803 nlockmgr 100003 2 tcp 2049 nfs 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100005 1 udp 892 mountd 100005 1 tcp 892 mountd 100005 2 udp 892 mountd 100005 2 tcp 892 mountd 100005 3 udp 892 mountd 100005 3 tcp 892 mountd调整你的iptables规制如下:
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 111 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 111 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 875 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 875 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 892 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 892 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 32803 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 32769 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT -A RH-Firewall-1-INPUT -p udp -m state --state NEW -m udp --dport 2049 -j ACCEPT