Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Mutual Master-Slave replication in mysql

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report