Kubernetes(K8S) 之 搭建 NFS 为 K8S 提供持久化存储
搭建NFS存储为K8S提供持久化存储环境说明:在节点192.168.2.3上安装NFS服务,并共享数据⽬录:/home/k8s-nfs安装NFS服务器1.关闭防⽕墙$ systemctlstop firewalld && systemctldisablefirewalld2.安装配置nfs$ yum -y install nfs-utils rpcbind3.创建共享⽬录设置权限:
搭建NFS为K8S提供持久化存储
环境说明:
在节点192.168.2.3上安装NFS服务,并共享数据⽬录:/home/k8s-nfs
安装NFS服务器
1.关闭防⽕墙
[root@nfs-server ~]# systemctl stop firewalld && systemctl disable firewalld
2.安装nfs
[root@nfs-server ~]# yum -y install nfs-utils rpcbind
3.创建共享⽬录设置权限:
[root@nfs-server ~]# mkdir -p /home/k8s-nfs
[root@nfs-server ~]# chmod 755 /home/k8s-nfs
4.配置nfs:
nfs的默认配置⽂件在/etc/exports⽂件下,在该⽂件中添加下⾯的配置信息:
[root@nfs-server ~]# vi /etc/exports
/home/k8s-nfs *(rw,sync,no_root_squash)
配置说明:
/home/k8s-nfs:是共享的数据⽬录
*: 表示任何⼈都有权限连接,当然也可以是⼀个⽹段,⼀个 IP,也可以是域名
rw: 读写的权限
sync:表示⽂件同时写⼊硬盘和内存
no_root_squash:当登录NFS主机使⽤共享⽬录的使⽤者是root时,其权限将被转换成为匿名使⽤者,通常它的UID与GID,都会变成nobody身份
5.启动服务
nfs需要向rpc注册,rpc⼀旦重启了,注册的⽂件都会丢失,向他注册的服务都需要重启
[root@nfs-server ~]# systemctl start rpcbind && systemctl enable rpcbind
[root@nfs-server ~]# systemctl start nfs && systemctl enable nfs
[root@nfs-server ~]# rpcinfo -p | grep nfs
6.查看具体⽬录挂载权限:
[root@nfs-server ~]# cat /var/lib/nfs/etab
/home/k8s-nfs *(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,no_subtr
ee_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,secure,no_root_squas
h,no_all_squash)
在K8S所有节点上安装nfs客户端
1.关闭防⽕墙
$ systemctl stop firewalld && systemctl disable firewalld
2.安装配置nfs
$ yum -y install nfs-utils rpcbind
3.启动服务
$ systemctl start rpcbind && systemctl enable rpcbind
$ systemctl start nfs && systemctl enable nfs
4.检查下nfs是否有共享⽬录:
$ showmount -e 192.168.2.3
Export list 192.168.2.3:
/home/k8s-nfs *
5、维护NFS服务的输出目录列表
exportfs命令:
-a 输出在/etc/exports文件中所定义的所有目录;
-r 重新读取/etc/exports文件,不需要重起服务;
-u 停止输出某一目录;
-v 在屏幕上显示过程;
1).重新输出共享目录
# exportfs -rv
2).查看NFS服务输出的共享目录
# showmount -e 192.168.2.3
3).停止输出所有共享目录
# exportfs -auv
更多推荐
所有评论(0)