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

The realization of Multi-Master and one Slave in MySQL

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

In large-scale systems, databases are often separated on multiple computers according to business logic, but statistics often need to be related to each other. MySQL theoretically does not support the synchronization of multiple master databases to a slave database, so what if multiple masters and one slave are implemented to facilitate statistical query? I tried to make use of the simple file storage feature of MyISAM, and the process is as follows: [@ more@]

1 set up the main library, enable Binlog, and it is recommended to copy the account. The specific process is the same as one master and multiple slaves.

2 set up slave database, start multi-database instances using mysqld_multi in slave database, each instance corresponds to a master library, and set master-slave replication respectively. It should be noted that 1. Only the MyISAM engine is installed in the slave library, so that no matter what engine the master library uses, the slave library uses MyISAM. 2. Use the same data directory for several instances of the library, so that each instance can access the tables of other instances. 3. Use Crontab to execute Flush tables; every minute from the slave library so that each instance can see the changes made by other instances to the period data.

In this way, you can access the table of the library from any instance, and you can also do a table join query across the library, query statistics is very convenient, hehe.

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