-
一、部署说明
NFS 服务需要依赖 RPC 服务,所以这里 NFS 服务端需要安装 rpcbind 和 nfs-utils,客户端只需要安装 nfs-utils 即可. -
二、部署
1、安装NFS服务端
查看是否安装nfs-utils、rpcbind,若为空,则说明未安装。rpm -qa nfs-utils rpcbind
安装nfs-utils、rpcbind,如为无网环境需要使用功能yum安装,请参考:https://blog.csdn.net/weixin_43135696/article/details/112306974yum install -y nfs-utils rpcbind
2、NFS 配置及使用
一个共享目录 /share/nfs ,作为客户端挂载的远端入口,然后设置权限
mkdir -p /share/nfs
chmod 666 /share/nfs
修改 NFS 配置文件
vim /etc/exports
/share/nfs 10.40.21.0/24(rw,sync,no_root_squash)
将 /usr/lvmdate/nfs 文件目录设置为允许 IP 为该 10.40.21.0/24 区间的客户端挂载,当然,如果客户端 IP 不在该区间也想要挂载的话,可以设置 IP 区间更大或者设置为 * 即允许所有客户端挂载;
Rw;可读可写
Async;同步,服务端只有接受到客户端的回应,才进行下一步,以确保连接更可靠
No_root_squash;不压缩root用户的权限,如要更安全请用roo_squash
3、启动 RPC 服务
systemctl start rpcbind
systemctl status rpcbind
4、启动 NFS 服务
systemctl start nfs
systemctl status nfs
在客户端输入以下命令验证是否可以挂载
showmount -e 10.40.21.xx
5、客户端挂载
安装客户端
yum install -y nfs-utils
挂载点 /share 目录必须已经存在,而且目录中没有文件或子目录
mkdir -p /share
#将共享文件夹10.40.21.xx:/share/nfs挂载到本地
mount 10.40.21.xx:/share/nfs /share
#查看磁盘状态
df -h
6、配置开机自动挂载
vi /etc/fstab
添加:
10.40.21.148:/nfs /share nfs defaults 0 0
说明:
第1个0表示不备份文件系统;
第2个0表示是否从/分区的顺序开始fsck磁盘检测,0表示不检测,1表示检测。