How to realize Mutual Master-Slave replication in mysql
This article is about how to achieve mutual master-slave replication in mysql. Xiaobian thinks it is quite practical, so share it with you to learn. I hope you can gain something after reading this article. Let's not say much. Let's take a look at it together with Xiaobian.
Error:
1)
The change master caused:
Last_IO_Error: error connecting to master - retry-time: 60 retries
2)
Stop the slave process without unlocking:
> stop slave;
ERROR 1192 (HY000): Can't execute the given command because you have active locked tables or an active transaction
3)
change master syntax error, falling comma
mysql> change master to
-> master_host='IP'
-> master_user='USER',
-> master_password='PASSWD',
-> master_log_file='mysql-bin.000002',
-> master_log_pos=106;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'master_user='USER',
master_password='PASSWD',
master_log_file='mysql-bin.000002' at line 3
4)
Change master without stopping slave processes
mysql> change master to master_host=‘IP', master_user='USER', master_password='PASSWD', master_log_file='mysql-bin.000001',master_log_pos=106;
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
5)
A B's server-id is the same:
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).
View server-id
mysql> show variables like 'server_id';
Modify server-id manually
mysql> set global server_id=2; #The value here is the same as that set in my.cnf
mysql> slave start;
6) After changing master, check slave status and find slave_IO_running is NO
The above is how to realize mutual master-slave replication in mysql. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.