The main master replication of MySQL is two MySQL nodes, mainly from each other. It is very easy to build up MySQL master-slave and then build the main master copy.
Video link: http://www.roncoo.com/course/view/658088f6e77541f5835b61800314083e
On the basis of the original master and slave to do the following operations:
1. Open the Binlog log from the original node
2. The original user who created the read replica from the node
3. In the primary node, point master to the slave node
4. Execute the start slave command on the primary node
The above steps can complete the configuration of the primary master node
Here is a problem to solve, that is, the problem of self-increment primary key, according to the above practice, if you insert data into two nodes, will cause the primary key duplication, here need a small trick
Here let the first node primary key take 1 3 5 7 ... The way to increment the second node is incremented by 2,4,6,8 so that it does not cause a primary key conflict.
auto_increment_increment=2auto_increment_offset=1
In MySQL5.7, you do not need to configure a primary key auto-increment policy, and each library's operations will increment the other library
MySQL Primary master replication