生产案例二(重建master):

指定数据目录信息,docker环境在容器外备份需要。

vim /soft/mysql.cnf
[mysqld]
datadir=/root/.data/mysql/data
log-bin=/root/.data/mysql/data/mysql-bin
log-bin-index=/root/.data/mysql/data/mysql-bin.index

备份

./xtrabackup --defaults-file=/soft/mysql.cnf --host=10.12.6.229 --user=root --password='MGR_12345678' --port=3308 --backup --target-dir /soft/full-database-20221017

转移

scp -r /soft/full-database-20221017 root@10.12.6.233:/soft/

从库还原

./xtrabackup --prepare --target-dir=/soft/full-database-20221017
docker stop mysql-mgr-m
rm -rf /root/.data/mysql/data/*
rsync -avrP /soft/full-database-20221017/ --exclude='xtrabackup_*' /root/.data/mysql/data/ > /soft/rsync.log
docker start mysql-mgr-m

查看最后一条GTID事物

cat /soft/full-database-20221017/xtrabackup_binlog_info

mysql-bin.000515 224 aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1-182146236:182880967-182916144

进入数据开启组复制

docker exec -it mysql-mgr-m /bin/bash

mysql -uroot -p'xxxxxxxx'

stop group_replication;
SET SQL_LOG_BIN=0;
reset master;
set @@GLOBAL.GTID_PURGED= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1-182146236:182880967-182916144';
SET SQL_LOG_BIN=0;
start group_replication;

检查

select * from performance_schema.replication_group_members;

标签: none

添加新评论