MySQL 基于 GTID 主从架构添加新 Slave 的过程

内容全部来自: How to create/restore a slave using GTID replication in MySQL 5.6


需求说明

需求: 对于已经存在的 MySQL 主从架构, 新增加 Slave 节点.

遇到的问题 : 主节点的 binlog 因为轮替原因, 当开启 Slave 的时候, 会报错: slave 需要的 binlog 已经被 purge.


MySQL 基于 GTID 的主从添加新 Slave 的过程

备份 master 数据

master>   mysqldump <database_name> --single-transaction --triggers --routines -hxx.xx.xx.xx -uxxxx -p > dump.sql


重置存库配置

slave> RESET MASTER;
slave> STOP SLAVE;
slave> RESET SLAVE;


灌入数据

slave> SOURCE dump.sql


配置 CHANGE MASTER

slave> CHANGE MASTER TO MASTER_HOST="xx.xx.xx.xx", MASTER_USER="xxxx", MASTER_PASSWORD="xxxx", MASTER_PORT=3306, MASTER_AUTO_POSITION = 1;


启动 slave

slave> START SLAVE;
slave> SHOW SLAVE STATUS \G

猜你喜欢

转载自www.cnblogs.com/tiantiandas/p/how-to-createrestore-a-slave-using-gtid-replication-in-mysql-5-6.html