kubernetes-nfs共享存储

发布时间 2023-04-15 09:24:28作者: Ranger-dev

搭建nfs服务端

#修改权限
chmod -R 777 /nfs/data

#编辑export文件
vim /etc/exports
/nfs/data *(rw,no_root_squash,sync)  (“*“代表所有人都能连接,建议换成具体ip或ip段,如192.168.20.0/24)

#配置生效
exportfs -r
#查看生效
exportfs

#启动rpcbind、nfs服务
systemctl restart rpcbind && systemctl enable rpcbind
systemctl restart nfs && systemctl enable nfs

#查看 RPC 服务的注册状况
rpcinfo -p localhost

#showmount测试
showmount -e 192.168.92.56

#所有node节点安装nfs客户端
yum -y install nfs-utils
systemctl start nfs && systemctl enable nfs

静态创建PV卷

#nfs服务器操作
#创建pv卷对应的目录
mkdir -p /nfs/data/pv001
mkdir -p /nfs/data/pv002

#配置exportrs
vim /etc/exports
/nfs/data *(rw,no_root_squash,sync)
/nfs/data/pv001 *(rw,no_root_squash,sync)
/nfs/data/pv002 *(rw,no_root_squash,sync)

#配置生效
exportfs -r
#重启rpcbind、nfs服务
systemctl restart rpcbind && systemctl restart nfs

原文链接 https://segmentfault.com/a/1190000040785500