一. 搭建环境(离线部署)
服务器A:10.10.10.130 主节点
服务器B: 10.10.10.129 客户端挂载节点
二. 搭建步骤
1. NFS服务搭建
下载地址:https://download.csdn.net/download/suntongxue100/12739587
(1) 解包:
tar zxvf filename.tar
(2) 进入解压后的temp文件夹,安装离线包:
rpm -ivh *.rpm --force –nodeps
(3) 启动nfs服务及设置开机启动:
systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind.service
systemctl enable nfs-server.service
(4) 关闭防火墙
停止防火墙:systemctl stop firewalld
关闭防火墙:systemctl disable firewalld
主节点130及客户端节点129都要进行以上1-4步操作。
2. 主节点设置开启共享
(1)创建待共享的文件夹
根目录创建nfsdata文件夹,赋予777权限
(2)编辑exports文件
vi /etc/exports
增加:
/nfsdata 10.10.10.129(rw,sync,no_root_squash)
或者:/nfsdata *(rw,sync,no_root_squash)
(3)重启服务:
systemctl restart nfs
systemctl restart rpcbind
3. 客户端节点挂载共享
(1)创建挂载同名文件夹
根目录创建nfsdata文件夹,赋予777权限
挂载: sudo mount -t nfs 10.10.10.130:/nfsdata /nfsdata
(如果需要取消挂载:sudo umount /nfsdata
)
(2)设置开机自动挂载
vi /etc/fstab
增加:
10.10.10.130:/nfsdata /nfsdata nfs rw,noac,suid,dev,exec,auto,nouser,async 0 0
至此,/nfsdata 已为共享文件夹,可以在客户端新建文件测试读写。