Master-Slave replication Construction based on GTID
Pre-inspection
Server-id = 10 Masterstroke does not allow repetition
Log-bin
Gtid-mode = ON
Enforce-gtid-consistency = ON
1. Use mysqlpump to copy master data to slave, and build master-slave replication based on GTID. Lack of GTID processing method, it is not successful for the time being.
Mysqlpump-host=-user=-password=-single-transaction-default-parallelism=4-compress-output=LZ4 "dbname" > / home/dbname.sql.lz4
Lz4-d inputfile outputfile
Mysql-u-p
< /home/dbname.sql 常见错误:Message: Got a packet bigger than 'max_allowed_packet' bytes max_allowed_packet过小,调大到32M,默认4M。 CHANGE MASTER TO MASTER_HOST = 'host_name', MASTER_USER = 'user_name', MASTER_PASSWORD = 'password', MASTER_AUTO_POSITION = 1; start slave; ERROR 1776 (HY000) at line 30: Parameters MASTER_LOG_FILE, MASTER_LOG_POS, RELAY_LOG_FILE and RELAY_LOG_POS cannot be set when MASTER_AUTO_POSITION is active. mysqlpump 备份文件缺少SET @@GLOBAL.GTID_PURGED='XXX:1-XXX';相关语句。 暂无解决方法。 2,使用mysqldump复制master数据到slave,搭建基于GTID的主从复制。 mysqldump --host= --user= --password= --single-transaction --routines --events "dbname" |gzip >/ home/dbname.sql.gz
Common error: mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table.
Network write timed out, change net_write_timeout to 600, default is 60.
Gzip-cd inuptfile > outputfile
Mysql-u-p < / home/dbname.sql
CHANGE MASTER TO
MASTER_HOST = 'host_name'
MASTER_USER = 'user_name'
MASTER_PASSWORD = 'password'
MASTER_AUTO_POSITION = 1
Start slave
3. Use mysqldbcompare for data consistency verification
Compare all databases with the same name between two servers
Ignore the following databases: INFORMATION_SCHEMA, PERFORMANCE_SCHEMA, mysql, and sys.
Mysqldbcompare-server1=user:password@localhost-server2=user:password@localhost-changes-for=server1-a
Databases are consistent. The check passed.
Complete the master-slave construction.