环境:CentOS release 6.8 (Final)(不同版本可能有差异)

1.yum -y install nfs-utils

2./etc/init.d/rpcbind status 查看 rpcbind状态,如果没启动就service rpcbind start

3.chkconfig rpcbind on    chkconfig nfs on 开机启动

4.service nfs start

5.建立共享目录  mkdir /tmp/imgs   &&  chmod 777 -R  /tmp/imgs

5.修改配置文件:vi /etc/exports   加入 /tmp/imgs    *(rw,sync,no_root_squash,no_subtree_check,insecure)

6.重启service nfs start 并检查服务 cat /var/lib/nfs/etab  显示如下,证明已挂载。

/tmp/imgs *(rw,sync,wdelay,hide,nocrossmnt,insecure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,no_root_squash,no_all_squash)

7.本地测试挂载 showmount -e localhost 

Export list for localhost:
/tmp/imgs *

8.其他主机测试需要开放相关端口(mountd、rquotad设置固定端口),然后重启

参考:https://www.cnblogs.com/zhaojingyu/p/10529945.html

9.防火墙开启:

-A INPUT -p tcp --dport 111 -j ACCEPT
-A INPUT -p udp --dport 111 -j ACCEPT
-A INPUT -p tcp --dport 2049 -j ACCEPT
-A INPUT -p udp --dport 2049 -j ACCEPT
-A INPUT -p udp --dport 30001 -j ACCEPT
-A INPUT -p tcp --dport 30001 -j ACCEPT
-A INPUT -p udp --dport 30002 -j ACCEPT
-A INPUT -p tcp --dport 30002 -j ACCEPT
-A INPUT -p udp --dport 30003 -j ACCEPT
-A INPUT -p tcp --dport 30003 -j ACCEPT
-A INPUT -p tcp --dport 30004 -j ACCEPT
-A INPUT -p udp --dport 30004 -j ACCEPT

9创建挂载点 挂载 

 mount -t nfs *.*.*.*:/tmp/imgs/ /opt/test

10.df  一下 是否可以了 ,有问题留言讨论。

 

posted on 2020-06-02 17:33  virgree  阅读(153)  评论(0编辑  收藏  举报