注意:先配置好防火墙,或者试验阶段直接停用防火墙
# 停用防火墙
systemctl stop firewalld
systemctl stop iptables
服务端
################ ## 服务端配置 ## ################ mkdir -p /ycx/upload # 安装nfs yum -y install nfs-utils rpcbind # 启动服务 systemctl start nfs #CentOs7 nfs CentOS8 nfs-server systemctl start rpcbind # 开机启用 systemctl enable nfs #CentOS7 nfs CentOS8 nfs-server systemctl enable rpcbind # 配置共享文件夹,客户端IP vi /etc/exports /ycx/upload 10.176.22.98(rw,no_root_squash,no_all_squash,sync) # 重新挂载 exportfs -r # 检查共享目录是否设置正确 showmount -e
客户端#################
## 客户端配置 ## ################# mkdir -p /ycx/upload # 安装nfs yum -y install nfs-utils # 启动nfs systemctl start nfs #CentOS7 nfs CentOS8 nfs-server # 开机启用 systemctl enable nfs #CentOS7 nfs CentOS8 nfs-server # 检查共享目录是否设置正确,服务端IP showmount -e 10.176.22.132 # 挂载服务端硬盘到客户端服务器 mount -t nfs 10.176.22.132:/ycx/upload /ycx/upload # 取消挂载 umount 10.176.22.132:/ycx/upload
# 重新挂载赋权限
mount -o remount, rw /ycx/upload
# 开机自动挂载 vim /etc/fstab 10.176.22.132:/ycx/upload /ycx/upload nfs4 defaults 0 0
CentOS8
systemctl restart nfs-server systemctl enable nfs-server
exportfs 命令
-a 全部挂载或者全部卸载 -r 重新挂载 -u 卸载某一个目录 -v 显示共享目录