MySQL Dual master replication Centos7

Source: Internet
Author: User

MySQL installation See: http://www.cnblogs.com/leohe/p/6839705.html

Dual master replication settings

1. Two virtual machines, all CENTOS7

Master: 10.1.1.115

From: 10.1.1.116

2. Modify the configuration file

2.1 Find/etc/my.cnf in 10.1.1.115 , add the following properties under [Mysqld]

server-id=10log-bin=mysql-binbinlog-do-db=retail  #需要同步的数据库名, if you have more than one database, repeat this parameter , one row per database replicate-do-db=retailauto-increment-increment=2   #字段变化增量值Auto- Increment-offset=1   #初始字段ID

2.2 Start the MySQL service and log in, then run show Master status;

2.3 Creating a Replication account

Each slave uses a standard MySQL username and password to connect to master. The user who makes the copy operation grants replication slave permissions. The password for the user name is stored in the text file master.info, eg:
Mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT on * * to [e-mail protected] '% ' identified by ' 123456 ';

2.4 Find/etc/my.cnf in 10.1.1.116, add the following properties under [Mysqld]

server-id=20log-bin=mysql-binbinlog-do-db=retail  #需要同步的数据库名, if you have more than one database, repeat this parameter , one row per database replicate-do-db=retailauto-increment-increment=2auto-increment-offset= 2

2.5 Start the MySQL service and log in, start slave

mysql> change MASTER to master_host= ' 10.1.1.115 ',         master_user= ' backup ',          master_password= ' 123456 ',         master_log_file= ' mysql-bin.000005 ', #上面的File字段          - > master_log_pos=2990;     
Mysql> START SLAVE;   # Run
Mysql> show SLAVE status\g # View slave_ioslave_sql Description Master Master Sync succeeded

If the above steps succeed, the master-slave replication of 10.1.1.115 to 10.1.1.116 has been configured, that is, 10.1.1.115 corresponding database modification, 10.1.1.116 the corresponding database is also modified accordingly.

10.1.1.116 to 10.1.1.115 the master-slave copy back to Lebanon operation is, you can refer to the Windows version of the dual-master replication.

MySQL Dual master replication Centos7

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.