Server environment:
Main mysql:192.168.1.163
From mysql:192.168.1.126
vip:192.168.1.50
First, MySQL configuration master-Slave synchronization
1. Configure the primary MySQL server
Vim/etc/my.conf
Establish an account and authorize slave
Lock the main library, read and write only
View the Binlog file and location of the primary database
At this point, the main library operation is complete and the operation starts from the library
2. Configure from MySQL server
Modifying from a configuration file
Vim/etc/my.conf
Configuring slave from the server
Log in to the main library to unlock the main library lock status
View from server Status
Second, configure MySQL Master master synchronization
Put the above operation step, reverse in operation again
Third, configuration keepalived
1, two server installation keepalived
2, copy the configuration file (two servers do the following actions)
3. Modify the keepalived configuration file on the 192.168.1.163
Create a detect MySQL script
Start the keepalived service
4. Modify the keepalived configuration file on the 192.168.1.126 (red arrow is required to change)
Create a detect MySQL script
Start keepalived
5. View
Login 192.168.1.163 View VIP
Login 192.168.1.126 view, no VIP
6. Test MySQL for high availability
Create a user on any MySQL computer for testing
Turn off the primary master sync feature
Create a database on 192.168.1.63 with the user you just created
View the database on the 192.168.1.126 server without the database ABC you just created
Log in to the database from another server to see the database created
Stop the MySQL service on the 192.168.1.163 server
Login 192.168.1.126,vip has drifted over.
When you log in to a VIP from another server, view the database
Did not see the created ABC database
At this point, MySQL high-availability creation is complete
Mysql+keepalived Configuration High Availability