NFS配置
服务器环境说明
服务端CentOS 7.5 IP:192.168.1.1
客户端CentOS 7.5 IP:192.168.1.8
1. 服务端安装 (192.168.1.1)
1.1 安装NFS相关包
# yum install nfs-utils
1.2 配置对外的目录和权限
# vi /etc/exports
添加一行,如下:
/data 192.168.1.8(rw,sync,no_root_squash,no_subtree_check)
参数说明
参数分为三部分:对外的目录,允许的Client IP,配置
export host(options)
/data :要对外的目录
192.168.1.8 :客户端的ip
(rw,sync,no_root_squash,no_subtree_check) :权限/参数配置
参数 | 参数说明 | 可选参数 | 说明 |
---|---|---|---|
rw | 可读写 | ro | ro为只读 |
sync | 同步写 | async | 异步写,写入内存就返回 |
no_root_squash | 允许root访问 | root_squash | 不允许root访问 |
no_subtree_check | 不检查目录 | 如果是卷的1部分对外,要检查Client的文件请求,是不是这个卷的一部分,如果是整个卷对外,就不检查 |
1.3 启动服务
# systemctl start rpcbind
# systemctl enable rpcbind
# systemctl start nfs
# systemctl enable nfs
2. 客户端配置 (192.168.1.8)
2.1 显示可以挂载的目录
# showmount -e 192.168.1.1
2.2 挂载目录
# mount -t nfs 192.168.1.1:\data \data
# echo "192.168.1.1:\data \data nfs auto,rw,vers=3,hard,intr,tcp,rsize=32768,wsize=32768" >> /etc/fstab
2.3 启动客户端服务
# systemctl start rpcbind
# systemctl enable rpcbind