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

MySQL master-slave synchronous deployment

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

Share

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

Master-slave synchronous deployment

1. Two mysql databases of the same version, one as the master database and one as the slave database

The main library opens binlog

Add log-bin=mysql-bin and server-id=1 to the [mysqld] module in the configuration file to ensure that the id of the two hosts is inconsistent

Restart the database

Log in to the database and create a new synchronization account, grant replication slave on. To 'rep'@'%' identified by' 123'

View the status of master show master status; record binlog file name and pos point

Make a full backup of the database of the master library and import it from the slave library

From the library

Check the server-id in the configuration file to ensure that it is not consistent with the main library

If there is a slave library under the library, you also need to turn on binlog and add the log-slave-updates parameter.

Restart the database. If there is no modification, there is no need to restart.

Log in to the database to perform change master authorization

Change master to master_host= "172.16.1.1", master_port=3306,master_user= "rep", master_password= "123", master_log_file=" mysqlbin.000001 ", master_log_pos=143

Stat slave; starts slave synchronization

Show slave status\ G; check Slave_IO_Running:YES and Slave_SQL_Running:YES, and the configuration synchronization is successful!

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