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

Master-slave building

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

Share

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

1. Create a master-slave

1.1 prerequisites

Both master and slave MySQL enable binlog, and ensure that the server-id is unique

[mysqld]

Log-bin=mysql-bin

Server-id=10086

After making the changes, restart the server.

Restart service takes effect

Service mysqld restart

This process is associated with the following parameters:

Innodb_flush_log_at_trx_commit=1

Sync_binlog=1

Skip-networking = off

1.2 create a user in the main library for replication connections from the library

When there are multiple slave libraries, you can create only one replication user for all slave libraries, or one copy user for each slave library

CREATE USER 'repl'@'%.server' IDENTIFIED BY' password'

GRANT REPLICATION SLAVE ON. TO 'repl'@'%.server'

1.3 perform the action of connecting to the master library from the slave library

CHANGE MASTER TO

MASTER_HOST='master2.example.com'

MASTER_USER='replication'

MASTER_PASSWORD='password'

MASTER_PORT=3306

MASTER_LOG_FILE='master2-bin.001'

MASTER_LOG_POS=4

MASTER_CONNECT_RETRY=10

Start the slave library

Start slave

Check the status of the connection from the library and follow the following items

Show slave status\ G

Make sure the following three items, double yes, plus SBM is 0. If the SBM is not zero, you need to check the delay before analyzing to ensure that the SBM is zero is the best state.

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Seconds_Behind_Master: 0

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