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

Test of 3-node master-slave synchronous replication scheme of MySQL

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Follow up "3-node master-slave synchronous replication scheme of MySQL" VI. Test master-slave synchronous replication

Now let's test the master-slave synchronization of mysql.

1. Insert test data into the main library

First insert and delete 2 pieces of data to the m_s_rep database on the main library MasterA. As follows:

Mysql > insert into test (id,content) values (3MagneData3'); mysql > insert into test (id,content) values (2mementdata2'); mysql > select * from test

two。 Log in to MasterB to view the results of data synchronization

3. Log in to the Slave node to view the results of data synchronization

From the figure above, we can see that the data are consistent between the m_s_rep database in the slave library slave and the m_s_rep database in the master library master. Indicates that the master and slave have replicated synchronously and successfully.

4. Now let's look at the information of MasterA's mysql-bin file # mysqlbinlog mysql-bin.000003 | tail

5. Now let's look at the information of MasterB's master.info file # cat master.info | more

6. Now let's take a look at the information of Slave's master.info file.

7. Master-slave synchronous replication test ends

Through the test, the pos location node of the binlog file of the main library is compared with master.info. We can find that the master.info file does record the binlog file name and pos location node of mysql when it is replicated synchronously.

seven。 Test each other master-slave synchronous replication 1. Create the second table m_s_rep in the m_s_rep library of MasterB

Let's create a test table to test the MasterA and MasterB master-slave synchronization tests.

two。 Check to see if the missus _ table table has been synchronized in the m_s_rep library of MasterA

3. Check to see if the missus _ table table has been synchronized in the m_s_rep library of Slave

4. End of test for synchronous replication of mutual master and slave

At this point, all the deployment tests of this solution have been completed, and I think: "No matter which node is down, MasterA and MasterB can still guarantee the master-slave relationship in the production environment." To ensure data consistency, MasterA and MasterB should and only if only one node is writable, regardless of the node state. Other nodes can prevent data from being written into the table by locking the table to avoid brain fissure.

Think about:

If in a production environment, as the business increases, the databases of different business units are also increasing. So how do you replicate a new database synchronously? The steps are as follows:

MasterA and MasterB master library lock table à modify the my.cnf configuration files in all nodes and add database names that need to be replicated synchronously. Restart the mysql service à export MasterA master database à only in the database files created from the library name à imported into the MasterA master database files from the library à MasterA and MasterB master library unlock à since then, changes in the master database will also be automatically synchronously copied to the slave database.

Reference blog: http://www.ilanni.com/?p=7992

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