搭建nfs服务器
1. 查看是否安装NFS
rpm -qa | grep nfs
rpm -qa | grep rpcbind
如未安需先安装服务
yum install -y nfs-utils rpcbind
2. 服务器配置
创建共享目录
mkdir /data/gx
赋予权限
chmod 777 /data/gx/
编辑配置文件
vim /etc/exports
内容:/data/gx 192.168.24.147/24(rw,no_root_squash,no_all_squash,sync)
配置生效
exportfs -r
开放nfs端口
firewall-cmd –permanent –add-service=nfs
端口生效
firewall-cmd –reload
重启服务
systemctl start nfs
systemctl start rpcbind
3. 客户端配置
创建挂载目录
mkdir /gx
将服务器共享目录挂载到本地
mount -t nfs 192.168.24.147:/data/gx /gx -o proto=tcp -o nolock #为了提高稳定性用tcp挂载
检查挂载结果
df -h
4. 验证
服务器编辑文件
echo “gongxiang” > gongxiang.txt
客户端查看
客户端写入
echo “23333” > /gx/gongxiang.txt
服务器查看
5. 解除挂载
到此结束