MySQL5.7 from the main building -GTID-mysqldump, xtrabackup

1, two empty library, are row + gtid, version MySQL5.7.22
mydb1 execution:
(dba_user @ localhost) [(none)]> Show Master Status;
+ ------------- ----- ------------------ + ---------- + -------------- + + ------------------------------------------ +
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+ ------------------ + ---------- + -------------- + ------------------ + ------------------------------ + -----------------------
| MySQL-bin.000005 | 154 | | | 9831a804-8c25-11e8-9a69-000c2983201e: 1-3 |
+ ----------- ------- + ---------- + -------------- + ---------------- - + ------------------------------------------ +
1 in the SET Row (0.01 sec)
mydb2执行:
(dba_user@localhost) [(none)]> reset master;
(dba_user@localhost) [(none)]> set global GTID_PURGED='9831a804-8c25-11e8-9a69-000c2983201e:1-3';
(dba_user@localhost) [(none)]> change master to master_host='192.168.1.101',master_port=3306,master_user='dba_user',master_password='msds007',master_auto_position=1;
(dba_user@localhost) [(none)]> start slave;
(dba_user@localhost) [(none)]> show slave status\G
(dba_user@localhost) [(none)]> set global read_only=on;
(dba_user@localhost) [(none)]> set global super_read_only=on;
 
2, the main library for the existing database, set up a new way of using mysqldump from the library, all row + gtid, version MySQL5.7.22
mydb1 perform:
[root @ mydb1 ~] # mysqldump -h192.168.1.101 -p3306 -udba_user - pmsds007 --single-transaction --master-data = 2 test> test.sql
appear warning ignore
mydb2执行:
(dba_user@localhost) [test]> source /root/test.sql
(dba_user@localhost) [test]> reset master;
(dba_user@localhost) [test]> SET @@GLOBAL.GTID_PURGED='9831a804-8c25-11e8-9a69-000c2983201e:1-433';
(dba_user@localhost) [(none)]> change master to master_host='192.168.1.101',master_port=3306,master_user='dba_user',master_password='msds007',master_auto_position=1;
(dba_user@localhost) [(none)]> start slave;
(dba_user@localhost) [(none)]> show slave status\G
(dba_user@localhost) [(none)]> set global read_only=on;
(dba_user@localhost) [(none)]> set global super_read_only=on;
 
3, the main library for the existing database, use xtrabackup way from the library to build a new, all row + gtid, version MySQL5.7.22
use my_full_backup.sh for backup
use my_full_recover.sh recovery
mydb2执行:
(dba_user@localhost) [test]> reset master;
(dba_user@localhost) [test]> SET @@GLOBAL.GTID_PURGED='9831a804-8c25-11e8-9a69-000c2983201e:1-433';
(dba_user@localhost) [(none)]> change master to master_host='192.168.1.101',master_port=3306,master_user='dba_user',master_password='msds007',master_auto_position=1;
(dba_user@localhost) [(none)]> start slave;
(dba_user@localhost) [(none)]> show slave status\G
(dba_user@localhost) [(none)]> set global read_only=on;
(dba_user@localhost) [(none)]> set global super_read_only=on;
 
 
 
 
 
 
 

Guess you like

Origin www.cnblogs.com/allenhu320/p/11316682.html