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

How to configure master/slave data synchronization for MYSQL

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces MYSQL how to configure master/slave data synchronization, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Redhat 9.0

Mysql3.23.57

Mysql data synchronous backup

A server: 192.168.1.2 main server master

Server B: 192.168.1.3 secondary server slave

A server settings

# mysql-u root-p

Mysql > GRANT FILE ON *. * TO backup@192.168.1.3 IDENTIFIED BY '1234'

Mysql > exit

Above, Master opens an account, backup password 1234, and gives IP:192.168.1.3 permission to process files.

Mysqladmin-u root-p shutdown

Back up all Master databases.. Tar instructions are usually used.

# tar-cvf / tmp/mysql.tar / var/lib/mysql

Note: when tar, MySQL is in the case of stop

Modify / etc/my.cnf on machine A

Add parameters in the [mysqld] section

Log-bin

Server-id=1

Sql-bin-update-same

Binlog-do-db=vbb

Restart server A mysql

At this time, because of the addition of the log-bin parameter, index begins to be generated, and there is an abnormal log of the .index file record database in the / var/lib/mysql directory.

B server settings

Settings / etc/my.cnf

Add in the [mysqld] section

Master-host=192.168.1.2

Master-user=backup

Master-password=1234

Master-port=3306

Server-id=2

Master-connect-retry=60 preset retry interval of 60 seconds

Replicate-do-db=vbb told slave to update only the vbb database.

Log-slave-updates

Transfer the mysql.tar copy from A to B

Transmit B's / tmp by ftp

9. Decompress

# cd / var/lib/

Condition test

1. When both An and B networks and services are normal, after changing the data from side A, browse the data from side B to check whether there is any replication!

two。 Simulate B down, or B doesn't have to be connected to An all the time.

After the data will be changed by side A, the data will be browsed on the side B, and there should be no data change at point B.

# tar xvf / tmp/mysql-snapshot.tar

# chown-R mysql:mysql mysql

1 restart the mysql of server B

Master.info appears in the / var/lib/mysql directory, and this file records the information of Master MySQL server.

Condition test

1. When both An and B networks and services are normal, after changing the data from side A, browse the data from side B to check whether there is any replication!

two。 Simulate B down, or B doesn't have to be connected to An all the time.

After the data will be changed by side A, the data will be browsed on the side B, and there should be no data change at point B.

Thank you for reading this article carefully. I hope the article "how to configure master/slave data synchronization in MYSQL" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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