kubernetes资源使用glusterfs卷进行数据持久化
2024-09-02 05:48:13
1、GlusterFS部署
安装GlusterFS集群的主要目的是为k8s集群提供分布式持久化存储。
GlusterFS部署使用2台服务器,服务名称与IP如下:
1 db-storagea 10.1.70.29
2 db-storageb 10.1.70.30
Ubuntu系统服务安装及启动
apt-get install glusterfs-server
systemctl start glusterd
systemctl enable glusterd
systemctl status glusterd
集群认证
服务器10.1.70.29
gluster peer probe 10.1.70.30
查看集群集群状态
服务器10.1.70.29
命令:gluster peer status
反馈:Number of Peers: 1
服务器10.1.70.30
命令:gluster peer status
反馈:Number of Peers: 1
分别在服务器10.1.70.29,10.1.70.30创建目录
mkdir -p /data/gluster /data/portal-files /data/portal-private /data/portal-config
创建gluster卷并启动卷
创建名称为 : mamm-volume 路径为 :/data/gluster
gluster volume create mamm-volume repl 2 10.1.70.29:/data/gluster 10.1.70.30:/data/gluster
启动mamm-volume卷
gluster volume start mamm-volume
gluster volume create portal-files repl 2 10.1.70.29:/data/portal-files 10.1.70.30:/data/portal-files force
gluster volume start portal-files
gluster volume create portal-private repl 2 10.1.70.29:/data/portal-private 10.1.70.30:/data/portal-private force
gluster volume start portal-private
gluster volume create portal-config repl 2 10.1.70.29:/data/portal-config 10.1.70.30:/data/portal-config force
gluster volume start portal-config
查看卷空间
命令: gluster volume info
Gluster 测试 找台服务器测试
客户端安装 glusterfs-client
mkdir /opt/clusterfstest
挂载
mount -t glusterfs 10.1.70.29:/mamm-volume /opt/clusterfstest
2、Kubernetes使用glusterfs持久化
先决条件
- 设置 GlusterFS 服务器集群
- 创建 GlusterFS 卷
创建 endpoints
apiVersion: v1
kind: Endpoints
metadata:
name: glusterfs-cluster
subsets:
- addresses:
- ip: 10.1.70.29
ports:
- port: 24007
- addresses:
- ip: 10.1.70.30
ports:
- port: 24007
该subsets
字段应填充 GlusterFS 集群中节点的地址。可以在字段中提供任何有效值(从 1 到 65535)端口。
kubectl get endpoints
还需要为这些端点创建一个服务,以便它们能够持久存在
apiVersion: v1
kind: Service
metadata:
name: glusterfs-cluster
spec:
ports:
- port: 20447
3、使用控制器进行挂载
volumeMounts:
- mountPath: "/var/www/html/web/sites/default/files"
name: portal-files
- mountPath: "/var/www/html/private"
name: portal-private
- mountPath: "/var/www/html/config"
name: portal-config
volumes:
- name: portal-files
glusterfs:
endpoints: glusterfs-cluster
path: portal-files
readOnly: false
- name: portal-private
glusterfs:
endpoints: glusterfs-cluster
path: portal-private
readOnly: false
- name: portal-config
glusterfs:
endpoints: glusterfs-cluster
path: portal-config
readOnly: false
4、在pod内测试
在pod内相关目录创建文件,然后在gluster服务器卷目录查看该文件是否存在
最新文章
- 车销宝无线开单PDA 一款互联网+POS神器 无缝与电脑数据同步 无线POS开单解决方案
- 无法找到类:java.lang.ClassNotFoundException: com.tt.javaweb.HttpServletRequest问题解决
- Excel01-不同的单元格输入同一数据
- Laravel-数据库操作笔记
- 一道有关球赛队员分配的C++程序题目
- 14.5.4 InnoDB File-Per-Table Tablespaces 每个表一个文件
- [Android学习笔记]SeekBar的使用
- 4.mysql数据库创建,表中创建模具模板脚本,mysql_SQL99标准连接查询(恩,外部连接,全外连接,交叉连接)
- HDU 4408 Minimum Spanning Tree 最小生成树计数
- typedef和define的详细区别
- Linux系统KVM虚拟化技术
- xxx.jar或者xxx.war中没有主清单属性和spring-boot-maven-plugin的作用
- MVC中如何避免POST请求中出现的重复提交
- LeetCode 42 Trapping Rain Water(积水体积)
- Castle DynamicProxy creation出现COMException(0x800703fa)错误的解决方案
- OGG FOR BIGDATA 安装(修正)
- NSURLSession下载和断点续传
- luogu p3366 最小生成树模板
- FastReport.Net使用:[24]其他控件(邮政编码(Zip Code),网格文本(Cellular Text)以及线性刻度尺(Linear Gauge))
- struts2学习(15)struts2防重复提交