Copy GTID

What is GTID it, in a nutshell, is the global transaction ID (global transaction identifier), originally implemented by google, only joined the official MySQL 5.6 features.
GTID create a unique identifier assigned when the transaction commits, all transactions are with one mapping GTID.

MySQL5.7 GTID achieve the
first normal mode from the main building
added after the following parameters
gtid_mode = ON
log-Slave-Updates = ON
Enforce Consistency-gtid-ON =
 
The online mode GTID copy mode to copy the conventional
1, as the master library set READ_ONLY, see the position of the copy
(the root @ localhost) [(none)]> = ON SET @@ global.read_only;
Query the OK, 0 rows affected ( sec 0.00)
(the root @ localhost) [(none)]> Show Master Status;
+ ------------------ + ---------- + - ------------- + ------------------ + ----------------- + -------------------------
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+ ------------ + ------ + -------------- + ----------------- ---------- - + ------------------------------------------ +
| MySQL-bin. 000007 | 688 | | | 766d5362- c923-11e6-85b5-000c29de38de: 1-2 |
+ ------------------ + ---------- + -------------- + ---- ----------------------------------- -------------- + + -------
. 1 in Row SET (0.00 sec)
2, in a closed mode GTID based replication from the library, adjusted to traditional replication
(the root @ localhost) [(none)]> STOP Slave;
Query the OK, affected rows 0 (0.00 sec)
(the root @ localhost) [(none)]> = 0 Change Master to master_auto_position, MASTER_LOG_FILE = 'MySQL-bin.000007', MASTER_LOG_POS = 688;
Query the OK, 0 rows affected (0.01 sec)
( @ localhost the root) [(none)]> Slave Start;
Query the OK, 0 rows affected (0.01 sec)
. 3, provided GTID mode ON_PERMISSIVE on each server
(root @ localhost) [(none )]> set @@ = on_permissive global.gtid_mode;
Query the OK, 0 rows affected (0.01 sec)
. 4, is provided on each mode GTID server OFF_PERMISSIVE
(the root @ localhost) [(none)]> = SET @@ global.gtid_mode off_permissive;
Query the OK, 0 rows affected (0.02 sec)
. 5, waits for all server variables @@ global.gtid_owned is empty, it is represented by by a global set of threads of execution GTID
6, waits are copied on all SLAVE complete anonymity affairs
7, close GTID on each server
(root @ localhost) [(none)]> @@ global.gtid_mode the SET = OFF;
Query the OK, 0 rows affected (0.02 sec)
. 8, modify the configuration file, even restart the database, is arranged in force
gtid_mode = off
Enforce-Consistency = gtid-off
. 9, the main library read_only set to off
 
The traditional online copy mode to copy mode GTID
1, ENFORCE_GTID_CONSISTENCY = WARN disposed on each server
(the root @ localhost) [(none)]> = SET @@ global.enforce_gtid_consistency The warn;
Query the OK, 0 rows affected (0.00 sec)
after this step is set so that all transactions are allowed to violate gtid of consistency, prior to the next step, you need to make sure that no warnings in the error log
2, ENFORCE_GTID_CONSISTENCY = oN is set on each server
(root @ localhost) [(none)]> the sET @@ global.enforce_gtid_consistency = oN;
Query the OK, 0 rows affected (0.00 sec)
this step is to ensure that all transactions are not violate GTID consistency
3, set GTID_MODE on each server = oFF_PERMISSIVE
this step is a new transaction is anonymous, while allowing replication transactions are anonymous or GTID
(the root @ localhost) [(none)]> = SET @@ global.gtid_mode off_permissive;
Query the OK, 0 rows affected (0.04 sec )
4, is provided on each GTID_MODE = ON_PERMISSIVE server
(root @ localhost) [(none)]> = SET @@ global.gtid_mode on_permissive;
Query the OK, 0 rows affected (0.06 sec)
. 5, ONGOING_ANONYMOUS_TRANSACTION_COUNT wait state value is 0
in all the view from the library
(root @ localhost) [ (none)]> Show Status like 'ongoing_anonymous_transaction_count';
+ ------------------------------------- + ------- +
| variable_name | Value |
+ ----------------------------------- - + ------- +
| Ongoing_anonymous_transaction_count | 0 |
+ --------------------------------- + ------- + ----
. 1 in Row sET (0.01 sec)
. 6, provided GTID_MODE = oN on each server
(root @ localhost) [(none )]> set @@ global.gtid_mode ON =;
Query the OK, 0 rows affected (0.06 sec)
7, this time based Binlog copy or location, can be set by the option MASTER_AUTO_POSITION 1, adjusted based on the copy of copy mode GTID
(the root @ localhost) [(none)]> STOP Slave;
Query the OK, 0 rows affected ( 0.00 sec)
(the root @ localhost) [(none)]> Change Master to master_auto_position =. 1;
Query the OK, 0 rows affected (0.06 sec)
(the root @ localhost) [(none)]> Start Slave;
Query the OK, 0 rows affected (0.00 sec)
8, modify the configuration file, even restart the database, configuration is in effect
gtid_mode = ON
the Enforce-gtid-Consistency = ON
 
GTID master pattern using a rapid change from the replication relationship
is now based replication model 201, from 201 to 202, 203
to adjust 201 is based, from 202 to 201, 203 to 202, from
1, 203 to stop copying
(root @ localhost) [(none)]> STOP Slave;
Query the OK, 0 rows affected (0.00 sec)
2, adjust the copy relationship 203, modify the copy source 202 node
(root @ localhost) [(none )]> change master to master_host = '192.168.1.202', MASTER_PORT = 3306, = master_auto_position. 1;
Query the OK, 0 rows affected (0.06 sec)
. 3, 203 to start copying
(the root @ localhost) [(none)]> Slave start;
Query the OK, rows 0 affected (0.00 sec)

Guess you like

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