Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Concrete steps of dual master configuration of mysql database

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the specific steps of the dual-master configuration of mysql database, the contents of the article are carefully selected and edited by the author, with a certain pertinence, and is of great significance to everyone's reference, so let's work with the author to understand the specific steps of the dual-master configuration of mysql database.

Environment:

Host A (huangzp2): 172.16.115.157

Host B (huangzp3): 172.16.115.100

Description: two-way master-slave configuration, master and slave each other; two CVMs can be accessed by users (with redundancy). Tasks can be divided in half and cannot be specified.

one。 Mysql mysql-server is installed on both hosts

Yum install mysql mysql-server-y

two。 Edit configuration file / etc/my.cnf

The host A profile has been added:

Log-bin=mysql-bin

Server-id=157

Replicate-do-db=test

Binlog-ignore-db=mysql

Binlog-ignore-db=information_schema

Auto_increment_increment=2

Auto_increment_offset=1

Host B profile added:

Log-bin=mysql-bin

Server-id=100

Replicate-do-db=test

Binlog-ignore-db=mysql

Binlog-ignore-db=information_schema

Auto_increment_increment=2

Auto_increment_offset=2

Description:

Log-bin=mysql-bin # means to open binaries

Server-id=100 # server id

Replicate-do-db=test # means to synchronize only the test library, and replicate-do-table means to synchronize only the specified tables

Binlog-ignore-db=mysql # indicates that the binaries of the mysql library are not recorded

Auto-increment-increment=2 # means an increase of 2 in turn

Auto-increment-offset=1 # represents the starting point, and the final primary key id is 1, 3, 5.

Note: the other host is set to auto-increment-increment=2,auto-increment-increment=1, and the final primary key id is 2, 4, 6. Ensure that the primary key id does not conflict when the primary master is synchronized

three。 Restart the master-slave mysql and set two master-slave sets (the second master-slave CVM is set in the opposite direction)

[the first set of master-slave-host A-master]

Grant replication slave on *. * to 'silen'@'172.16.115.100' identified by' 123456'

Show master status

[the first set of master-slave-host B-slave]

[the second set of master-slave-host B-master]

Description: the authorized user name can be different

Grant replication slave on *. * to 'silen'@'172.16.115.157' identified by' 123456'

Show master status

[the second set of master-slave-host A-slave]

four。 The host turns on slave and checks the slave status show slave status\ G

Host A

Host B

five。 Create a table in the test library on the B CVM tb1,A CVM also generates tb1

Host B

Host A

six。 Create a table in the test library on CVM A tb2,B CVM also generates tb2

Host A

Host B

After reading the above specific steps about the dual-master configuration of mysql database, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report