服务器端:
- 查看nfs和rpcbind是否安装:
rpm -qa | grep "nfs"
rpm -qa | grep "rpcbind"
- 新建共享目录/root/opt/nfs/sharedir,并编译vi /etc/exports,设置服务端的共享目录
- /root/opt/nfs/sharedir *(rw,sync,no_root_squash)
- 重启rpcbind和nfs服务
- systemctl restart rpcbind
- systemctl restart nfs
- 查看nfs启动状态
- systemctl status nfs
客户端:
新建共享目录:mkdir /nfs/
查看服务端共享目录
showmount -e server_ip(如果是k8s集群,为内部ip)
mount -t nfs -o rw server_ip:share_dir shar_dir_client
开启rpcbind服务, systemctl start rpcbind
设置rpcbind开机启动:chkconfig rpcbind on
挂载共享目录
如:mount -t nfs -o rw 172.31.0.13:/root/opt/nfs/sharedir /nfs
查看挂载情况df
设置开机自动挂载:
vi /etc/fstab
添加:
172.31.0.13:/root/opt/nfs/sharedir /nfs nfs rw,udp 0 0
解除挂载:
umount /nfs
挂载中遇到错误查看服务器端log:
tail /var/log/messages
mount时报错:rpc.statd is not running but is required for remote locking
解决办法:客户端开启rpcbind:systemctl start rpcbind