本文将演示如何在 KubeSphere[1] 上部署 RadonDB MySQL on Kubernetes 2.1.2 ,快速实现高可用的 MySQL on K8s。
若已在 KubeSphere 部署过历史版本 Operator,可以选择如下方式更新到最新版本。
可任选一个 RadonDB MySQL 配置示例[5] 部署,或自定义配置部署。
以 mysql_v1alpha1_mysqlcluster.yaml 模版为例,创建一个 RadonDB MySQL 集群。
注意
未指定项目时,集群将被默认安装在 kubesphere-controls-system 项目中。若需指定项目,安装命令需添加 --namespace=<project_name>。
预期结果
预期结果
在 demo-project 项目中,查看 RadonDB MySQL 集群状态。
至此,完成在 KubeSphere 中部署 RadonDB MySQL 集群。
[1]:KubeSphere: https://kubesphere.com.cn
[2]:OpenPitrix: https://kubesphere.io/zh/docs/pluggable-components/app-store
[3]:创建 *** 作: https://kubesphere.io/zh/docs/quick-start/create-workspace-and-project
[4]:项目网关: https://kubesphere.io/zh/docs/project-administration/project-gateway
[5]:配置示例: https://github.com/radondb/radondb-mysql-kubernetes/blob/main/config/samples
目的使用docker安装mysql主从集群
docker pull mysql:5.7.33
mkdir -p mydata/mysql/master/log
mkdir -p mydata/mysql/master/data
mkdir -p mydata/mysql/master/conf
docker run -p 3307:3306 --name mysql-master -v /mydata/mysql/master/log:/var/log/mysql -v /mydata/mysql/master/data:/var/lib/mysql -v /mydata/mysql/master/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.33
docker run -p 3308:3306 --name mysql-slave1 -v /mydata/mysql/slave1/log:/var/log/mysql -v /mydata/mysql/slave1/data:/var/lib/mysql -v /mydata/mysql/slave1/conf:/etc/mysql --link mysql-master:master -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.33
docker run -p 3309:3306 --name mysql-slave2 -v /mydata/mysql/slave2/log:/var/log/mysql -v /mydata/mysql/slave2/data:/var/lib/mysql -v /mydata/mysql/slave2/conf:/etc/mysql --link mysql-master:master -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.33
映射文件夹修改配置
vi /mydata/mysql/conf/my.conf
下面是my.conf配置文件内容
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
再修改my.cnf配置
vi /mydata/mysql/conf/my.cnf
下面是my.cnf配置文件内容
[mysqld]
log-bin=/var/lib/mysql/mysql-bin
server-id=1001
expire_logs_days = 30
docker restart mysql
docker exec -it mysql bash
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Lens2022'
grant replication slave on . to 'upstream'@'%' identified by '123456'
flush privileges
show variables like '%log_bin%'
show master status\G
stop slave
change master to master_host='master', master_user='slave', master_password='123456', master_port=3307, master_log_file='mysql-bin.000001', master_log_pos=154, master_connect_retry=30
start slave
show slave status\G
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)