K8S mysql8.x主从

92 篇文章 6 订阅
66 篇文章 4 订阅
helm repo add bitnami https://charts.bitnami.com/bitnami

helm install mysql bitnami/mysql \
--set auth.rootPassword=123qwe \
--set architecture=replication \
--set secondary.replicaCount=1 \
--set secondary.persistence.storageClass=rook-ceph-block \
--set secondary.persistence.size=1G \
--set primary.persistence.storageClass=rook-ceph-block \
--set primary.persistence.size=1G

主库

mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 |      339 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

从库

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: mysql-primary
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 10
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 339
               Relay_Log_File: mysql-relay-bin.000006
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 

扩容从库

# kubectl  get pods | grep mysql-secondary
mysql-secondary-0                              1/1     Running   0              13h
mysql-secondary-1                              1/1     Running   0              4m15s
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| bbc                |
| information_schema |
| my_database        |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.01 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: mysql-primary
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 10
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 339
               Relay_Log_File: mysql-relay-bin.000006
                Relay_Log_Pos: 555
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 

一主两从

# kubectl  get pods | grep mysql
mysql-primary-0                                1/1     Running   0              13h
mysql-secondary-0                              1/1     Running   0              13h
mysql-secondary-1                              1/1     Running   0              6m42s

更多参数

https://github.com/bitnami/charts/tree/master/bitnami/mysql/#parameters
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值