时间:2021-07-01 10:21:17 帮助过:36人阅读
锁一下表,追平两台机器数据,然后解锁。
先看看GTID是否打开
1234567891011 | mysql> show global variables like ‘%gtid%‘ ; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | enforce_gtid_consistency | ON | | gtid_executed | | | gtid_mode | ON | | gtid_owned | | | gtid_purged | | +--------------------------+-------+ 5 rows in set (0.10 sec) |
#说明gtid功能已启动。
GTID同步数据不用再记录对方的log文件和位置了,用master_auto_position=1就行,不过你用老的方法查看master的logfile和logpos,同步也是可以的。
#在两台Mysql上都运行,IP得互指
mysql> change master to master_host=‘192.168.1.201‘, master_user=‘repl‘,master_password=‘123456‘,master_auto_position=1;
mysql> start slave;
show slave status\G ;
#表示同步的文件和位置
Master_Log_File:
Read_Master_Log_Pos: 4
#显示下面表示工作正常
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
#表示当前同步的数据库
Replicate_Do_DB: nzabbix,szabbix
过程中可能遇到的错误及解决方法:
错误一:
mysql> start slave;
ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository
解决方法:
mysql> reset slave;
错误二:
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
解决方法:
修改my.cnf配置文件中,slave_skip_errors = all
本文出自 “小飞侠” 博客,请务必保留此出处http://jack88.blog.51cto.com/12348665/1901252
MySQL主主复制
标签:mysql主主fu'zhu