Linux下实现NFS挂载


1.判断linux是否安装了nfs服务 rpm -qa|grep nfs
2.配置/etc/exports文件。
    添加:
     /root/script 192.168.1.204(insecure,rw,async,no_root_squash)
3.关闭防火墙:service iptables stop 可能使用的端口号
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
4.设置被远程访问文件的读写权限:chmod 755 /root/script
5.启动服务:
    service rpcbind start
    service nfs start

204客户端
1.创建空文件夹file,用于挂载服务器文件
2.使用mount命令挂载文件:mount 192.168.1.223:/root/script /filePath

两个nfs服务不能挂载到同一路径下

服务器在关闭nfs之前,应先取消客户端的挂载,否则客户端访问会出现卡死情况:umount /filePath
如果客户端取消挂载失败:fuser -km /filePath 取消连接
然后连接客户端执行命令 :umount /filePath
最后关闭服务器nfs服务

猜你喜欢

转载自blog.csdn.net/guandongsheng110/article/details/71173152