Get the App
SLTechnology News&Howtos  ›  Servers  › 

Mariadb primary master replication on centos7

Shulou Source: shulou.com Published: 2022-06-03 00:52:25 09月22日 Update

Mariadb1: 192.168.11.247

Mariadb2: 192.168.11.246

1 mariadb1 configuration

Vi / etc/my.cnf.d/server.cnf

[mysqld]

Server-id = 1

Log-bin = master-log

Relay-log = slave-log

Auto_increment_offset = 1

Auto_increment_increment = 2

2 mariadb2 configuration

Vi / etc/my.cnf.d/server.cnf

[mysqld]

Server-id = 2

Log-bin = master-log

Relay-log = slave-log

Auto_increment_offset = 2

Auto_increment_increment = 2

3 restart the mariadb service

Systemctl restart mariadb

4 mariadb1 master, mariadb2 slave configuration

Mariadb1 executes in sql:

MariaDB [(none)] > create user 'lan'@'192.168.11.%' identified by' 666666'

MariaDB [(none)] > grant replication slave on. To 'lan'@'192.168.11.%'

Show master status

Mariadb2 executes in sql:

# the data of log_file and log_pos are the data obtained by show master status on mariad1

Change master to master_host='192.168.11.247', master_user='lan', master_password='666666', master_log_file='master-log.000001', master_log_pos=498

Start slave

Show slave status\ G

5 mariadb2 master, mariadb1 slave configuration

Mariadb2 executes in sql:

MariaDB [(none)] > create user 'lan'@'192.168.11.%' identified by' 666666'

MariaDB [(none)] > grant replication slave on. To 'lan'@'192.168.11.%'

Show master status

Mariadb1 executes in sql:

# the data of log_file and log_pos are the data obtained by show master status on mariad2

Change master to master_host='192.168.11.246', master_user='lan', master_password='666666', master_log_file='master-log.000001', master_log_pos=498

Start slave

Show slave status\ G

At this point, the master and master synchronous replication configuration is complete.

[click]] (https://www.aigony.com/pages/viewpage.action?pageId=1376296)

Tags: Configuration data so far details synchronization services Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia Shulou Tech Info macOS Docker