MySQL master/Master synchronization Configuration

Source: Internet
Author: User

Practical Environment Introduction:

Server Name IP System MySQL
Odd.example.com 192.168.1.116 Rhel-5.8 5.5.16
Even.example.com 192.168.1.115 Rhel-5.8 5.5.16

Assume that the database to be synchronized is db_rocky.

(I) Create a synchronization user

On ODD

Mysql> grant replication slave on *. * to 'water' @ '192. 168.1.115 'identified by 'cdio2010 ';
Query OK, 0 rows affected (0.00 sec)

Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

On EVEN

Mysql> grant replication slave on *. * to 'water' @ '192. 168.1.116 'identified by 'cdio2010 ';
Query OK, 0 rows affected (0.11 sec)

Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

(Ii) modify the/etc/my. cnf configuration file and add the following content to it:

On ODD

[Mysqld]

Binlog-do-db = db_rocky # database for which logs need to be logged. If multiple databases are separated by commas (,), or multiple binlog-do-db options are used.
Binlog-ignore-db = mysql # databases that do not need to record hexadecimal logs. If multiple databases are separated by commas (,), or use the binlog-do-db option.
Replicate-do-db = db_rocky # the database to be synchronized. If multiple databases are separated by commas, or multiple replicate-do-db options are used.
Replicate-ignore-db = mysql, information_schema # databases that do not need to be synchronized. If multiple databases are separated by commas, or use multiple replicate-ignore-db options
# Synchronization parameters:
# Ensure that slave will receive write information from another master when it is mounted to any master.
Log-slave-updates
Sync_binlog = 1
Auto_increment_offset = 1
Auto_increment_increment = 2
Slave-skip-errors = all # filter out some errors without any major problems

On EVEN

[Mysqld]
Server-id = 2 # set a different id. Note that the default value in my. cnf is 1. Change the default value instead of adding a server-id.
Binlog-do-db = db_rocky # database for which binary logs need to be recorded. If multiple databases are separated by commas, or multiple binlog-do-db options are used
Binlog-ignore-db = mysql # database that does not need to record the hexadecimal log. If multiple databases are separated by commas, or multiple binlog-ignore-db options are used
# Databases to be synchronized
Replicate-do-db = db_rocky # the database to be synchronized. If multiple databases are separated by commas (,), or use the binlog-do-db option.
Replicate-ignore-db = mysql, information_schema # databases that do not need to be synchronized. If multiple databases are separated by commas, or use multiple binlog-do-db options
# Synchronization parameters:
# Ensure that slave will receive write information from another master when it is mounted to any master.
Log-slave-updates
Sync_binlog = 1
Auto_increment_offset = 2
Auto_increment_increment = 2
Slave-skip-errors = all # filter out some errors without any major problems

 

  • 1
  • 2
  • 3
  • 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.