在mysql5.6下创建新slave,innobackupex
MySQL 5.6 introduced the new Global Transaction ID (GTID) support in replication.
Percona XtraBackup from 2.1.0 version, automatically stores the GTID value in the xtrabackup_binlog_info when doing the backup of MySQL and Percona Server 5.6 with the GTID mode enabled. This information can be used to create a new (or repair a broken) GTID based slave.
直接看命令吧
```
innobackupex -host HHH --user=UUU --password=PPP /backup/
rsync -av --protocol=29 --rsh="ssh -p22 -carcfour" --exclude=logs/ --exclude=lost+found/ --delete uuu@ip:/dir/ ./
innobackupex --apply-log --use-memory=6G ./
chown -R mysql:mysql ./data
/etc/init.d/mysql start
cat xtrabackup_binlog_info
#mysql-bin.000002 1232 aaaa-bbbb-cccc-dddd-080027635ef5:1-4
mysql -u uuu -p
```
Mysql client:
```
SET GLOBAL gtid_purged="aaaa-bbbb-cccc-dddd-080027635ef5:1-4";
reset slave;
CHANGE MASTER TO MASTER_HOST="$masterip", MASTER_USER="repl", MASTER_PASSWORD="$slavepass", MASTER_AUTO_POSITION = 1;
show slave status \G
start slave;
show slave status\G
[..]
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
[...]
Retrieved_Gtid_Set: aaaa-bbbb-cccc-dddd-080027635ef5:5
Executed_Gtid_Set: aaaa-bbbb-cccc-dddd-080027635ef5:1-5
```
更新于 2023年03月28日 20:53:54