MySQL Primary master replication
background:
Make a note of the MySQL master replication method that you learned.
Introduction:
The so-called primary master replication, which is two MySQL servers, can provide read-write services to the outside, and is simultaneously service.
Realize:
Step 1, install the MySQL service and the Customer service tool on both servers
Yum install mysql-server MySQL
Step 2, edit the configuration file
1) Mutual main from: two nodes each to open binlog and relay log;
2) server_id must use different values;
3) both Binlog and relay log are enabled;
4) A table with an automatic growth ID, in order to make the ID does not conflict, need to define its automatic growth mode;
auto-Grow ID;
Define a node with an odd ID
Auto_increment_offset=1
auto_increment_increment=2
The other node uses an even ID
auto_increment_offset=2
auto_increment_increment=2
650) this.width=650; "src=" Https://s5.51cto.com/oss/201711/14/2568b5c5f15c7205d869199c68911de1.png "title=" 1.png " alt= "2568b5c5f15c7205d869199c68911de1.png"/>
Step 3, open the MySQL service, add both sides sync account
Command: GRANT REPLICATION slave,replication CLIENT on * * to ' test ' @ ' 172.18.76.% ' identified by ' 123456 ';
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/14/746877adbb4dba408167c0ab1c672081.png "title=" 2.png " alt= "746877adbb4dba408167c0ab1c672081.png"/>
Step 4, start the service and view both log files and offsets
Service mysqld Start
First Host:
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/14/e3b2e691543c8c8e833f537963b195c3.png "title=" 3.png " alt= "E3b2e691543c8c8e833f537963b195c3.png"/>
Second Host:
650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/14/cb48c14d27883a5ee41ca246feb8e550.png "title=" 4.png " alt= "Cb48c14d27883a5ee41ca246feb8e550.png"/>
Step 5, add the other side for their own master node server, open from the node
650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/14/b1477e29f8c7c9374ec957afb1c67764.png "title=" 5.png " alt= "B1477e29f8c7c9374ec957afb1c67764.png"/>
650) this.width=650; "src=" Https://s2.51cto.com/oss/201711/14/a48737d92b14877d61787ec6a84c19b4.png "title=" 6.png " alt= "A48737d92b14877d61787ec6a84c19b4.png"/>
Step 6, Test
On the two hosts to build a database to see if the other side is successful synchronization;
650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/14/930e649c221d117cd5247957ff5a9f07.png "title=" 7.png " alt= "930e649c221d117cd5247957ff5a9f07.png"/>
Also see if the database is synchronized in the second database
650) this.width=650; "src=" Https://s2.51cto.com/oss/201711/14/ee728fdaf3f52d6865bdea42264cdc0f.png "title=" 8.png " alt= "Ee728fdaf3f52d6865bdea42264cdc0f.png"/>
Primary master replication to this MySQL database is complete
MySQL Primary master replication