服务端配置:
yum -y install nfs-utils rpcbind
建立同步文件夹
mkdir -p /app/file
对同步文件夹进行授权
最好跟客户机器使用同样的用户组,不然会有权限问题
[root@localhost redis-6.2.6]# groups zwy
zwy : zwy wheel
chown -R zwy:wheel /app/file
创建配置文件
# cat /etc/exports
/app/file *(rw,sync)
执行exportfs -rv让配置立即生效。
#将NFS和rpcbind加入开机启动
systemctl enable nfs
systemctl enable rpcbind
#启动NFS和rpcbind
systemctl start nfs
systemctl start rpcbind
端口开放
firewall-cmd --zone=public --add-port=111/tcp --permanent
firewall-cmd --zone=public --add-port=111/udp --permanent
firewall-cmd --zone=public --add-port=2049/tcp --permanent
firewall-cmd --zone=public --add-port=2049/udp --permanent
客户端配置:
安装NFS
yum install nfs-utils rpcbind -y
将NFS加入开启启动
systemctl enable nfs
将rpcbind加入开启启动
systemctl enable rpcbind
启动NFS
systemctl start nfs
启动RPCbind
systemctl start rpcbind
将应用文件夹挂载到服务器上
mkdir /app/file
mount –t nfs 172.31.63.132:/app/file /app/file
挂载完成后可以使用mount | grep file命令查看挂载情况
取消挂载
sudo fuser -m -v -i -k /app/file
sudo umount /app/file
引用
https://www.cnblogs.com/ximu/archive/2012/05/04/2482345.html
https://www.cnblogs.com/cheyunhua/p/12033457.html
https://blog.csdn.net/jianzhang11/article/details/104269967
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.101.201” port protocol=“tcp” port=“2049” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.101.201” port protocol=“udp” port=“2049” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.101.202” port protocol=“tcp” port=“2049” accept”
firewall-cmd --permanent --add-rich-rule=“rule family=“ipv4” source address=“192.168.101.202” port protocol=“udp” port=“2049” accept”
firewall-cmd --permanent --remove-port=2049/udp
firewall-cmd --permanent --remove-port=2049/tcp
firewall-cmd --reload