MySQL 5.5 master-slave bidirectional Synchronization

Source: Internet
Author: User

On the Red Hat Enterprise Linux platform, the MySQL master-slave synchronization principle is used to achieve two-way MySQL synchronization.
MySQL version: 5.5.28
Operating System: RHEL 5.8 32bit

Server1: 192.168.1.1
Configuration: my. cnf

  1. Server-id = 1
  2. Binlog-do-db = testdb
  3. Binlog-ignore-db = mysql
  4. Log-slave-updates
  5. Replicate-do-db = testdb
  6. Replicate-ignore-db = mysql

Synchronize the testdb database. The mysql database is not synchronized here.
New synchronization users:

  1. Grant replication slave on *. * to slaveuser@192.168.1.2 identified by '2013 ';

Start Sever1;

  1. Service mysql start

View the binlog file name and pos value of MySQL synchronization:

  1. Show master status;

Server2: 192.168.1.2
Configuration: my. cnf

  1. Server-id = 2
  2. Binlog-do-db = testdb
  3. Binlog-ignore-db = mysql
  4. Log-slave-updates
  5. Replicate-do-db = testdb
  6. Replicate-ignore-db = mysql

The configuration is basically the same as that of Sever1, but the server-id is different and cannot be the same. Remember to enable the binary log record in the [mysqld] configuration area: log-bin = mysql-bin
New synchronization users:

  1. Grant replication slave on *. * to slaveuser@192.168.1.1 identified by '2013 ';

Start Server2:

  1. Service mysql start

Configuration synchronization:

  1. Mysql> change master to master_host = '192. 168.1.1 ',
  2. Mysql> master_user = 'slaveuser ',
  3. Mysql> master_password = '123 ',
  4. Mysql> master_log_file = 'mysql-bin.20.20 ',
  5. Mysql> master_log_pos = 107;
  6. Mysql> slave start;
  7. Mysql> show slave status \ G;
  • 1
  • 2
  • Next Page

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.