安装NFS软件包
dnf install nfs-utils
配置防火墙,或者直接关闭防火墙
iptables -F
iptables-save
firewall-cmd --permanent
#直接关闭防火墙
systemctl stop firewalld
在NFS服务器上建立用于NFS文件共享的目录,并设置足够的权限
mkdir /nfsfile
chmod -R 777 /nfsfile
echo "welcome to " > /nfsfile/readme
在NFS服务程序的配置文件中写入其他主机的读写权限
vim /etc/exports
#写入以下内容
/nfsfile 172.20.10.*(rw,sync,root_squash)
启动nfs服务程序,顺带重启recbind服务程序
systemctl restart rpcbind
systemctl enable rpcbind
systemctl start nfs-server
systemctl enable nfs-server
接下来就是配置客户端了
查看一下服务器是否🆗
showmount -e 172.20.10.3
#然后创建一个挂载目录
mkdir /nfsfile
#开始挂载
mount -t nfs 172.20.10.3:/nfsfile /nfsfile
#查看是否成功
df -h
#想要一直有效写入fstab文件中
vim /etc/fstab
#写入以下内容
172.20.10.3:/nfsfile /nfsfile nfs defaults 0 0