keepalived+mysql high availability cluster

1. MySQL master-slave configuration

MySQL Server1: 192.168.153.130
MySQL Server2: 192.168.153.131
Modify the configuration file of MySQL Server1 and add the following content
[root@localhost ~]# vim /etc/my.cnf
Insert picture description here
Modify the configuration file of MySQL Server2 and add the following content
[root@localhost ~]# vim /etc/my.cnf
Insert picture description here
Enter MySQL Server1, authorize MySQL Server2, and refresh the authorization table.
Insert picture description here
View the master status of MySQL Server1 and
Insert picture description here
enter MySQL Server2, turn off the replication function of the slave server, configure the slave server, and establish a connection with the master database. Then turn on the replication function of the slave server and
Insert picture description here
check the status of the replication function of the MySQL Server2 slave service. Double Yes means success.
Insert picture description here
Enter MySQL Server2, authorize MySQL Server1, and refresh the authorization table.
Insert picture description here
View the master status of MySQL Server2

Insert picture description here
Enter MySQL Server1, turn off the replication function of the slave server, configure the slave server, establish a connection with the master database, and then turn on the replication function of the slave server.

Insert picture description here
Check the status of the replication function of the MySQL Server1 slave service. Double Yes means success.
Insert picture description here
Verification:
Create a database on Server1, which can be seen
Insert picture description here
Insert picture description here
on Server2. Create a database on Server2, which can be seen on Server1.
Insert picture description here
Insert picture description here

2.keepalived configuration

Preemption mode

Install the keepalived software on both Server1 and Server2
Insert picture description here
Modify the keepalived configuration file of Server1
Insert picture description here
Insert picture description here
Modify the keepalived configuration file
Insert picture description here
of Server2 Verify the result on Server1:
Insert picture description here
View the log on Server2 Verify the result:
Insert picture description here
Stop the MySQL service on Server1:
Insert picture description here
View the active and standby on Server2 Successfully switched
Insert picture description here
Insert picture description here
to start MySQL and keepalived services on Server1

Insert picture description here
Insert picture description here
Check the success of preemption on Server1
Insert picture description here

Non-preemptive mode

Only one line of parameters is required in the configuration file, and the other parts are the same as the preemption mode
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_46674735/article/details/109597636
Recommended