MySQL database two hosts synchronized combat

Source: Internet
Author: User
Tags log mysql database

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';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.