MySQL supports one-way, asynchronous replication, in which one server acts as the primary server and one or more other servers act as the server. The master server writes the update to the binary log file and maintains an index of the log file to track the log loop.
When a server connects to the primary server, it notifies the primary server of the location of the last successful update that was read from the server in the log. Receive any updates from the server that have occurred since then, and then block and wait for the master server to notify the next update.
In the actual project, the two distributed in the remote host installed MySQL database, two servers are based on each other, customer requirements when one of the machine failure, the other can take over the application of the server, which requires two database data to be consistent in real time, Use MySQL's sync function here to achieve synchronous replication of two machines.
The following are examples of actions:
1. Database synchronization Settings
Host operating system: RedHat Enterprise Linux 5
Database version: MySQL Ver 14.12 Distrib 5.0.22
Prerequisite: MySQL database start normally
Suppose the two host addresses are:
serva:10.240.136.9
servb:10.240.136.149
1.1 Configure Sync Account
Add an account on the Serva that servb can log on to:
MySQL>GRANT all privileges ON *.* TO tongbu@'10.240.136.149' IDENTIFIED BY '123456';
Add an account on the servb that Serva can log on to:
MySQL>GRANT all privileges ON *.* TO tongbu@'10.240.136.9' IDENTIFIED BY '123456';