I have previously introduced to you the configuration method of MySQL database dual-machine hot standby. Friends who are interested can refer to it. In this section, we focus on summarizing and analyzing the important links and areas that need attention. I. Introduction mysql version: 5.7.20 The first main server ip:192.168.71.139 The second main server ip:192.168.71.141 2. Configuration The first primary server 192.168.71.139 1: Modify the /etc/mysql/my.cnf file. Note that # here is a comment. Do not write it into the configuration file. server-id = 141 #Server id, cannot be repeated, it is recommended to use the last three digits of the IP. 2: Log in to MySQL and create an account that allows other servers to replicate GRANT REPLICATION SLAVE ON *.* to 'mysql account'@'%' identified by 'password'; 3: Use show master status to query the status The second primary server is 192.168.71.139 1: Modify the /etc/mysql/my.cnf file, where server-id = 139, and the rest remain unchanged. Use show master status to query the status At this point, you need to restart mysql on both servers Execute synchronization statements at 192.168.71.141 The master_log_file value comes from the 139 server, the File field after executing show master status change master to master_host='192.168.71.139',master_user='master2',master_password='123456',master_log_file='mysql-bin.000002',master_log_pos=154; Execute synchronization statements at 192.168.71.139 The master_log_file value comes from the 141 server, the File field after executing show master status The master_log_file value comes from the 141 server, the Position field after executing show master status change master to master_host='192.168.71.141',master_user='master1',master_password='123456',master_log_file='mysql-bin.000002', master_log_pos=154; This is the end of the configuration. Restart MySQL, log in to MySQL, and use show slave status\G to check the configuration status. It is found that Slave_IO cannot be started and the following error occurs. The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work. The log shows that the master and slave uuids are duplicated. Because the two servers are cloned, you need to modify /var/lib/mysql/auto.cnf Here I only changed the last letter, because if I changed too much, I couldn't start mysql. After the modification is completed, restart MySQL, log in to MySQL and execute show slave status\G, as shown below Three: Test Execute the following sql on any server create table tab141(id int primary key); create table tab139(id int primary key); Execute the following sql on the 139 server insert into tab139 values(1); Execute the following sql on the 141 server insert into tab141 values(2); The results are as follows: If you have any questions, please feel free to discuss in the comment area below. You may also be interested in:
|
<<: Three networking methods and principles of VMware virtual machines (summary)
>>: Vue implements video upload function
Table of contents Before MySQL 5.6 After MySQL 5....
Anyone who has a little knowledge of data operati...
To deploy multiple sites on a server, you need to...
MySQL8.0.22 installation and configuration (super...
I have installed various images under virtual mac...
1. Download the RPM package corresponding to Linu...
This article introduces the sample code for imple...
Mysql sets boolean type 1. Tinyint type We create...
The project scaffolding built with vue-cli has al...
Table of contents Install CentOS7 Configuring Sta...
In the actual project development process, the pag...
Preface: The most commonly used MySQL logical bac...
Preface: In MySQL, views are probably one of the ...
This article example shares the specific code of ...
= Only when setting and updating does it have the...