在Kubernetes上安装MySQL-PXC集群
2024-09-05 23:55:31
官方部署文档地址:https://www.percona.com/doc/kubernetes-operator-for-pxc/kubernetes.html
一、部署方式
示例在k8s集群(至少3个节点)中部署Percona XtraDB Cluster集群
- clone项目
git clone https://gitee.com/Aaron-23/percona-xtradb-cluster-operator.git
cd percona-xtradb-cluster-operator
- 准备存储
当前环境具有三个k8s node节点,每个node节点/var/lib/data目录有100GB存储空间
所有存储均使用本地存储
创建local-storageclass
cd storage
kubectl create -f local-sc.yaml
创建pv
修改values值为各pxc节点ip,spec.local.path
路径根据实际情况自定义,
kubectl create -f pv-data-172.yaml
kubectl create -f pv-data-173.yaml
kubectl create -f pv-data-174.yaml
- 创建crd资源
kubectl apply -f deploy/crd.yaml
- 创建ns
kubectl create namespace pxc
kubectl config set-context $(kubectl config current-context) --namespace=pxc
- 赋予rbac权限
kubectl apply -f deploy/rbac.yaml
- 在Kubernetes中启动operator
kubectl apply -f deploy/operator.yaml
- 使用secrets.管理Percona XtraDB集群相关秘钥
需要设置数据库密码的修改secrets
中密码即可
kubectl create -f deploy/secrets.yaml
- 创建Percona XtraDB Cluster
kubectl apply -f deploy/cr.yaml
创建过程将花费一些时间。当po和副本数都达到“Running”状态时,该过程结束:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
cluster1-haproxy-0 1/1 Running 0 5m
cluster1-haproxy-1 1/1 Running 0 5m
cluster1-haproxy-2 1/1 Running 0 5m
cluster1-pxc-0 1/1 Running 0 5m
cluster1-pxc-1 1/1 Running 0 4m
cluster1-pxc-2 1/1 Running 0 2m
percona-xtradb-cluster-operator-dc67778fd-qtspz 1/1 Running 0 6m
- 检查与新创建集群的连接
$ kubectl run -i --rm --tty percona-client --image=percona:8.0 --restart=Never -- bash -il
percona-client:/$ mysql -h cluster1-haproxy -uroot -proot_password
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1976
Server version: 8.0.19-10 Percona XtraDB Cluster (GPL), Release rel10, Revision 727f180, WSREP version 26.4.3
Copyright (c) 2009-2020 Percona LLC and/or its affiliates
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
最新文章
- 关于我-dinphy简介
- 【实时】DevExpress内存监视
- Gradle笔记系列(一)
- word-wrap&;&;word-break,奇偶行、列设置样式
- 如何让WordPress支持上传更多文件类型
- RHEL5.8设置OpenSSH的X11 Forwarding功能
- virtualbox 中ubantu虚拟机范文win7文件夹
- Bind[Exclude|Include]排除字段或只允许字段验证
- 001.XE3添加TPerlRegEx
- android玩耍(-) adbshell安装
- (转)ios限制控制器旋转
- linux下修改hostid
- 关于C++中ios::sync_with_stdio(false)
- Lab 10-3
- PHP 通过带SSL的SMTP 发送邮件的处理
- 自然语言交流系统 phxnet团队 创新实训 项目博客 (六)
- 不是最强大的vimrc
- ActiveMQ开发注意要点
- Linux ulimit命令详解
- c++getline()、get()等
热门文章
- 贪心-Saruman‘s Army POJ - 3069
- uni-app(Vue)中(picker)用联动(关联)选择以至于完成某些功能
- prometheus(1)之核心概念
- 使用BadBoy录制JMeter脚本
- 【Python+postman接口自动化测试】(3)什么是接口测试?
- Vuex状态管理——任意组件间通信
- git stash 存储命令
- [cf566C]Logistical Questions
- [hdu7035]Game
- [cf1168E]Xor Permutations