MySQL database cluster, mysql-5.7.24 version, master-slave replication, master-master mutual backup configuration, CentOS8 server

First install the mysql database on the two servers:

Linux common users install MySQL database, mysql-5.7.24 version, ContOS8 version server

The server-id in the my.cnf file of the two installed databases must be unique, and the my.cnf configuration file needs to be modified if it is repeated:

Server 1: 10.0.84.25
Server 2: 10.0.84.26
insert image description here
After the installation is complete, restart the two mysql databases:

service mysql restart

insert image description here
Log in to the mysql database:

mysql -uroot -p

View the status of the MySQL master database on server 10.0.84.26:

show master status;

insert image description here
Change the corresponding data:
#MASTER_LOG_FILE='binlog.000002', (it is the File in the status information)
#MASTER_LOG_POS=154; (it is the Position in the status information)

CHANGE MASTER TO
MASTER_HOST='10.0.84.26',
MASTER_PORT=3306,
MASTER_USER='mysql',
MASTER_PASSWORD='mysql123',
MASTER_LOG_FILE='binlog.000002',
MASTER_LOG_POS=154;

Log in to the MySQL database on the server 10.0.84.25 to execute:
insert image description here
start the I/O thread and the SQL thread:

start slave;

insert image description here
View the status of the MySQL master library on server 10.0.84.25:

show master status;

insert image description here
Change the corresponding data:
#MASTER_LOG_FILE='binlog.000005', (it is the File in the status information)
#MASTER_LOG_POS=154; (it is the Position in the status information)

CHANGE MASTER TO
MASTER_HOST='10.0.84.25',
MASTER_PORT=3306,
MASTER_USER='mysql',
MASTER_PASSWORD='mysql123',
MASTER_LOG_FILE='binlog.000005',
MASTER_LOG_POS=154;

Log in to the MySQL database on server 10.0.84.26 to execute:
insert image description here
start the I/O thread and SQL thread:

start slave;

insert image description here
Use the command to view the status of the two machines separately:

show slave status\G;

Both machines have the following two states, which means they are normal:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
insert image description here
Exit, and log in to each other's database to see if they are connected:

mysql -umysql -p -h10.0.84.26
mysql -umysql -p -h10.0.84.25

insert image description here
Finally, connect with a visualization tool to create a database table, and test to see if the two databases are synchronized.

Guess you like

Origin blog.csdn.net/qq_41619841/article/details/123104618