安装:
# 服务端 yum -y install nfs-utils rpcbind # 客户端 yum -y install nfs-utils
服务端:
- 配置共享目录:
vim /etc/exports
/path/to/dir xx.xx.xx.*(rw,async,no_root_squash)
- 更改目录权限:
chmod -R +w /path/to/dir
- 启动服务:
systemctl start rpcbind && systemctl enable rpcbind systemctl start nfs && systemctl enable nfs
- 开放防火墙端口:
# rpcbind的端口 iptables -I INPUT -p udp --dport 111 -j ACCEPT iptables -I INPUT -p tcp --dport 111 -j ACCEPT # nfs的端口 iptables -I INPUT -p udp --dport 2049 -j ACCEPT iptables -I INPUT -p tcp --dport 2049 -j ACCEPT
- 配置共享目录:
客户端:
- 查看服务端挂载状态:
showmount -e xx.xx.xx.xx
- 挂载:
mount xx.xx.xx.xx:/path/to/dir /path/to/dir
- 开机自动挂载:
echo "xx.xx.xx.xx:/path/to/dir /path/to/dir nfs defaults 0 0" >> /etc/fstab
- 查看服务端挂载状态:
文档更新时间: 2024-04-19 15:11 作者:lee