服务端:
1.yum install -y nfs-utils rpcbind
2.vim /etc/exports
加入:
/mnt 192.168.1.0/24(rw,sync,all_ squash,anonuid=501,anongid=501) ----需要共享的目录和共享给谁 (读写权限, 同步权限, 全部指定用户和组为501,包含root)
no_root_squash---指定为root
3./etc/init.d/rpcbind start
4./etc/init.d/nfs start
客户端:
1.yum install nfs-utils
2.showmount -e 服务端ip ---可以查看服务端共享的目录
3.mount -t nfs -onolock,nfsvers=3 服务端ip:/mnt /opt ---挂载到本机的/opt目录下
exportfs -arv 重新加载配置
会遇到这个问题 (问题1)
[plain] view plaincopy
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified
和这个问题 (问题2)
[plain] view plaincopy
mount.nfs: requested NFS version or transport protocol is not supported
靠谱的办法是把服务端的3个服务都重启一遍
[plain] view plaincopy
service nfslock restart
service rpcbind restart
service nfs restart
现在运行命令,就能挂在正确
[plain] view plaincopy
mount -t nfs 192.168.0.13:/data/abc/bcd /data/abc/bcd
然后再给出一个解除绑定的方法
[plain] view plaincopy
umount -t nfs 192.168.0.13:/data/abc/bcd /data/abc/bcd