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

MySQL5.7 Master-Slave replication-GTID replication Building

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Two servers, the system is Redhat6.5,MySQL version 5.7.18.

1. On the main library, create a user for replication and grant replication slave permission. The user repl is created here, and you can connect from the host with IP 10.10.10.210.

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

2. Modify the configuration of the master server and add the following configuration:

Cat / etc/my.cnf

[mysqld]

Server-id=1

Log-bin=mysql-bin

Log-bin-index=mysql-bin.index

Binlog_format=mixed

Log_slave_updates=on

Gtid-mode = ON

Enforce-gtid-consistency = ON

3. Set a read lock on the main database to ensure that there is no data operation and get a consistent snapshot.

Flush tables with read lock

4. Export the data using mysqldump and copy it to the slave server.

5. Backup of the main database is completed, and write operation is resumed.

Unlock tables

6. Modify the configuration file of the slave library and add the following parameters. Note that the server-id must be unique and cannot be the same as the master library. If there are multiple slave libraries, the server-id cannot be duplicated.

Cat / etc/my.cnf

[mysqld]

Server-id=2

Log-bin=mysql-bin

Log-bin-index=mysql-bin.index

Binlog_format=mixed

Log_slave_updates=on

Gtid-mode = ON

Enforce-gtid-consistency = ON

7. On the slave library, start the database with-- skip-slave-start, so that the replication process on the slave library will not be started immediately, which is convenient for us to proceed to the next step of configuration.

. / bin/mysqld_safe-- skip-slave-start &

8. Point at the top of the library

Change master to

Master_host='10.10.10.200'

Master_port=3306

Master_user='repl'

Master_password='mysql'

Master_auto_position=1

9. Slave threads from the top of the library

Start slave

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