指定数据目录信息,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

change master to
master_host='10.12.7.173',
master_user='group',
master_password='group_123456',
master_port=3307,
master_auto_position=1;

start slave;

标签: none

添加新评论