The global transaction identifier (Transactions Identifier) is a new feature of MySQL 5.6 replication.
Gtid is actually made up of Uuid+tid. Where the UUID is the unique identity of a MySQL instance. The TID represents the number of transactions that have been committed on the instance and is monotonically incremented as the transaction commits. Here is a concrete form of a gtid.
1, before the MySQL5.6 for master-slave replication problems sometimes need you to analyze Binlog find Pos point, and then in Chang MASTER to. It is easy for beginners to make mistakes, resulting in master-slave replication errors. In the new version, you don't have to look for Binlog and Pos points, You only need to know the master's IP, password, port, because MySQL will automatically find the synchronization point from the internal gtid mechanism.
2, multi-threaded replication, before MySQL5.6, replication is a single-threaded queue, only one run. Support for library-based multithreaded replication is supported in the new version, but the tables in the library cannot be multithreaded.
Main MySQL configuration file modification:
server-ID=185 #和从MySQL不同Log-bin=mysql-Binexpire-logs-days= -#二进制日志周期 (on-demand configuration) Binlog-format=Row #使用row格式log-slave-updates=trueGtid-mode=On #开启GTID模式slave_parallel_workers=4#开启基于库的多线程复制默认0不开启 Enforce-gtid-consistency=true#强制GTID的一致性master-Info-repository=table #主服信息记录库 = table/File Relay-log-Info-repository=TABLE #中继日志信息记录库Sync-master-Info=1#同步主库信息innodb_file_per_table=1#使用独立表空间
Master MySQL Create copy account:
' Repl ' @'10.205.22.186'password'; flush privileges;
Modify from MySQL configuration file:
server-ID=186 #和主MySQL不同Log-bin=mysql-Binexpire-logs-days= -#二进制日志周期 (on-demand configuration) Binlog-format=Row #使用row格式log-slave-updates=trueGtid-mode=On #开启GTID模式slave_parallel_workers=4#开启基于库的多线程复制默认0不开启 Enforce-gtid-consistency=true#强制GTID的一致性master-Info-repository=table #主服信息记录库 = table/File Relay-log-Info-repository=TABLE #中继日志信息记录库Sync-master-Info=1#同步主库信息innodb_file_per_table=1#使用独立表空间
from MySQL execution:
Change Master to master_host='10.205.22.185', master_port=3306, master_user= ' Repl ', master_password='password', master_auto_position=1; start Slave;
Write data on master MySQL to check whether the synchronization was successful from MySQL
MySQL5.6 Gtid-based master-slave replication configuration