# 安装
sudo yum install -y nfs-utils rpcbind
# 启动
sudo systemctl start nfs-server
sudo systemctl start nfs-server
# 开机自启
sudo systemctl enable nfs-server
sudo systemctl enable rpcbind
# 创建共享目录并赋权
mkdir /var/nfsshare
chmod 755 /var/nfsshare
# 编辑共享配置 /etc/exports 参数含义请移步文章结尾
/var/nfsshare/ 135.123.56.98(ro,sync,no_root_squash)
# 重启nfs
sudo systemctl restart nfs-server.service
# 查看nfs状态
sudo systemctl status nfs-server.service
# 监听端口
netstat -ntpl|grep 2049
# 配置防火墙
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='135.123.56.98' port protocol='tcp' port='2049' accept"
# 重启防火墙
firewall-cmd --reload
# 查看规则
firewall-cmd --zone=public --list-rich-rules
# 客户端配置
# 安装
sudo yum install nfs-utils
# 启动
sudo yum install nfs-utils
mkdir /mnt/nfs
# 此处IP为NFS服务端IP
sudo mount -t nfs 112.181.152.86:/var/nfsshare /mnt/nfs