Get the App
SLTechnology News&Howtos  ›  Database  › 

How to implement dual-master replication configuration in mysql

Shulou Source: shulou.com Published: 2022-05-31 15:30:56 11月27日 Update

This article mainly introduces mysql how to achieve dual-master replication configuration, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

Two machines, system version CentOS6.5, hostname master and slave,IP address 192.168.57 and 192.168.58, respectively

1. Create replication users on two nodes

At the active node:

Grant replication slave on *. * to 'repl'@'192.168.8.58' identified by' mysql'

At the passive node:

Grant replication slave on *. * to 'repl'@'192.168.8.57' identified by' mysql'

2. Modify the database configuration file

Add the following configuration to the active node:

Server-id = 1

Log-bin = / mysql/data/mysql-bin-3306

Relay-log = relay-log

Read-only = false

Log-slave-updates

Skip-slave-start

Add the following configuration to the passive node:

Server-id = 2

Log-bin = / mysql/data/mysql-bin-3306

Relay-log = relay-log

Read-only = true

Log-slave-updates

3. Configure replication stream

Configure the first replication stream:

Change master to

Master_host='192.168.8.57'

Master_port=3306

Master_user='repl'

Master_password='mysql'

Master_log_file='mysql-bin.000001'

Master_log_pos=154

Master_connect_retry=10

Configure the second replication stream:

Change master to

Master_host='192.168.8.58'

Master_port=3306

Master_user='repl'

Master_password='mysql'

Master_log_file='mysql-bin.000002'

Master_log_pos=154

Master_connect_retry=10

Thank you for reading this article carefully. I hope the article "how to achieve dual-host replication configuration of mysql" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Configuration node article active two host value interest at the same time name address data database file more friends machine version user knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn macOS Redmi MySQL Shulou Information