1 服务器搭建
1.1 安装nfs server
yum -y install nfs-utils rpcbind
1.2 启动服务
systemctl enable rpcbind nfs-server nfs-lock nfs-idmap --now
1.3 创建需要共享的目录
mkdir -p /nas/k8s
chmod -R 777 /nas/k8s
1.4 配置共享目录
配置需要共享的目录到 /etc/exports下,xxx.xxx.xxx.xxx为需要共享的对象ip地址
echo "/nas/k8s 192.168.3.0/24(insecure,rw,async,no_root_squash)" >> /etc/exports
exportfs -a # 使exports的修改生效
1.5 检查共享目录是否设置正确
# showmount -e 192.168.3.81
Export list for 192.168.3.81:
/nas/k8s 192.168.3.0/24
2 客户端配置
2.1 安装nfs client
yum -y install nfs-utils
2.2 检查服务器共享目录
检查共享目录是否设置正确,xxx.xxx.xxx.xxx 为共享服务器地址
# showmount -e 192.168.3.81
Export list for 192.168.3.81:
/nas/k8s 192.168.3.0/24
2.3 挂载远程服务器NFS分区到本地挂载点
# mount -t nfs 192.168.3.81:/nas/k8s /mnt