1.准备3台机器
192.168.10.50 (服务端)
192.168.10.51 (客户端)
192.168.10.52 (客户端)
2.安装前基础环境配置(所有主机)
#(1)关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
#(2)关闭selinux
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config
3.安装 NFS 和 RPC(所有主机)
yum install -y nfs-utils rpcbind
4.创建共享文件夹(服务端)
# 创建共享存储文件夹
mkdir -p /nfs/data
#配置nfs
echo "/nfs/data *(rw,sync,no_root_squash)" >> /etc/exports #表示所有客户端可挂载
# 1.使NFS配置生效
exportfs -r
# 2.设置开机自启动
systemctl enable rpcbind && systemctl start rpcbind
systemctl enable nfs && systemctl restart nfs
# 3.查看服务状态
systemctl status rpcbind
systemctl status nfs
# 5.查看是否成功和可用的nfs地址:
[root@k8s-master1 ~]# showmount -e localhost
Export list for localhost:
/nfs/data *
5.创建挂载文件(客户端执行)
#创建目录
mkdir -p /data/nfs
#查看挂载ip
showmount -e 192.168.10.50
Export list for 192.168.2.245:
/nfs/data *
#挂载
mount -t nfs 192.168.10.50:/nfs/data /data/nfs
6.验证
#在服务端.两个客户端的共享目录下分别创建不同名的文件夹或文件查看其他两台主机的共享目录下是否同步新建内容。
cd /nfs/data
mkdir a