1 Star 0 Fork 0

宁凡/mysql_cluster_k8s

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mysql8.0-cm.yaml 3.07 KB
一键复制 编辑 原始数据 按行查看 历史
puzhi 提交于 2024-06-14 12:21 . 增加腾讯云TKE适配yaml
---
# MySQL Conf
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-conf
namespace: mysql-test
data:
mysql-master.cnf: |
[mysqld]
skip-name-resolve
datadir = /var/lib/mysql
socket = /var/run/mysqld/mysqld.sock
secure-file-priv = /var/lib/mysql-files
pid-file = /var/run/mysqld/mysqld.pid
user = mysql
secure-file-priv = NULL
default_authentication_plugin = mysql_native_password
gtid_mode = on
enforce_gtid_consistency = on
server-id = 1
log-bin = master-bin
log_bin_index = master-bin.index
binlog_ignore_db = information_schema
binlog_ignore_db = performance_schema
binlog_ignore_db = sys
binlog-format = ROW
long_query_time = 0.1
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
lower_case_table_names = 1
default-time_zone = '+8:00'
mysql-slave.cnf: |
[mysqld]
skip-name-resolve
datadir = /var/lib/mysql
socket = /var/run/mysqld/mysqld.sock
secure-file-priv = /var/lib/mysql-files
pid-file = /var/run/mysqld/mysqld.pid
user = mysql
secure-file-priv = NULL
default_authentication_plugin = mysql_native_password
gtid_mode = on
enforce_gtid_consistency = on
slave-skip-errors = 1007
log-bin = slave-bin
relay-log = slave-relay-bin
relay-log-index = slave-relay-bin.index
binlog_ignore_db = information_schema
binlog_ignore_db = performance_schema
binlog_ignore_db = sys
long_query_time = 0.1
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
lower_case_table_names = 1
default-time_zone = '+8:00'
init-master.sql: |
CREATE USER 'repl'@'%' IDENTIFIED WITH mysql_native_password BY 'Mogujie@repl';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
flush privileges;
init-slave.sql: |
CHANGE MASTER TO MASTER_HOST='mysql-master-0.mysql-master', MASTER_USER='repl', MASTER_PASSWORD='Mogujie@repl', master_auto_position=1;
start slave;
reset-slave.sh: |
#!/bin/sh
# wait mysqld startup
until mysql -uroot -p$$MYSQL_ROOT_PASSWORD -e "SELECT 1"; do sleep 1; done
# reset slave
mysql -uroot -p$$MYSQL_ROOT_PASSWORD <<EOF
stop slave;
reset slave;
CHANGE MASTER TO MASTER_HOST='mysql-master-0.mysql-master', MASTER_USER='repl', MASTER_PASSWORD='Mogujie@repl', master_auto_position=1;
start slave;
EOF
check_slave_status.sh: |
#!/bin/sh
# wait mysqld startup
until mysql -uroot -p$$MYSQL_ROOT_PASSWORD -e "SELECT 1"; do sleep 1; done
# Check slave status
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "SHOW SLAVE STATUS\G" | grep -q "Slave_IO_Running: Yes"
if [ $? -ne 0 ]; then
exit 1
fi
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "SHOW SLAVE STATUS\G" | grep -q "Slave_SQL_Running: Yes"
if [ $? -ne 0 ]; then
exit 1
fi
mysql -u root -p$MYSQL_ROOT_PASSWORD -e "SHOW SLAVE STATUS\G" | grep -q "Seconds_Behind_Master: 0"
if [ $? -ne 0 ]; then
exit 1
fi
exit 0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
YAML
1
https://gitee.com/joeye0819/mysql_cluster_k8s.git
git@gitee.com:joeye0819/mysql_cluster_k8s.git
joeye0819
mysql_cluster_k8s
mysql_cluster_k8s
master

搜索帮助