MariaDB configuration for Dual master replication

Source: Internet
Author: User

Environment

Master1/master2 System Ip Database version
Master1 CentOS6.7 10.10.3.211 mariadb-10.1.19
Master2 CentOS6.7 10.10.3.212 mariadb-10.1.19

First, the configuration of Master1

(1) Modify the Master1 configuration file/etc/my.cnf, as follows:

Log-Bin= /Usr/Local/Mysqllogs/Binlogs/Master1-bin #启用二进制日志relay-Log = /Usr/Local/Mysqllogs/Relaylogs/Relay-bin #启用中继日志auto-Increment-Offset= 1#自增起始值auto-Increment-Increment= 2#自增步长server-Id= 1        

Restarting the database service

(2) Create a user with copy permission, the command is as follows

CREATE USER 'Luccy'@'10.10.3.212'Identified by '123456';REVOKE  All Privileges,GRANT OPTION  from 'Luccy'@'10.10.3.212';GRANTReload,lock TABLES,REPLICATIONCLIENT,REPLICATIONSLAVE on *.*  to 'Luccy'@'10.10.3.212'; FLUSHPrivileges;

Second, the configuration of Master2

(1) Modify the Master1 configuration file/etc/my.cnf, as follows:

Log-Bin= /Usr/Local/Mysqllogs/Binlogs/Master2-Binrelay-Log = /Usr/Local/Mysqllogs/Relaylogs/Relay-Binauto-Increment-Offset= 2Auto-Increment-Increment= 2Server-Id= 2

Restarting the database service

(2) Create a user with copy permission, the command is as follows

CREATE USER 'Jerry'@'10.10.3.211'Identified by '123456';REVOKE  All Privileges,GRANT OPTION  from 'Jerry'@'10.10.3.211';GRANTReload,lock TABLES,REPLICATIONCLIENT,REPLICATIONSLAVE on *.*  to 'Jerry'@'10.10.3.211'; FLUSHPrivileges;

Iii. viewing the status of Master1 and Master2

SHOW MASTER STATUS;

Master1

Master2

Four, pointing to each other

Change MASTER to Master_user= ' Jerry ', master_host= ' 10.10.3.212 ', master_password= ' 123456 ', master_log_file= ' master2-bin.000002', master_log_pos=982;

Change MASTER to Master_user= ' luccy ', master_host= ' 10.10.3.211 ', master_password= ' 123456 ', master_log_file= ' master1-bin.000001', master_log_pos=1473;

V. Start the Master1 and MASTER2 server replication process

START SLAVE;

Master1

Master2

VI. Testing

MariaDB configuration for Dual master replication

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.