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 complete the MySQL master-slave hot backup in linux?

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

Share

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

With the advent of the era of big data, data is particularly important. The loss or destruction of data can even destroy a company.

The master-slave hot backup under Linux is actually very simple.

1. As the primary server Master, it records every change in its binary log Binarylog. (it is the responsibility of the server to read the log and then execute it again at your own place. ) 2. As a slave server Slave, it logs in to master with the account on master, reads master's Binarylog, writes to its own relay log Relaylog, and then its own SQL thread reads the relay log and executes it again. At this point, the changes on the master server are synchronized to the slave server. The following specific configuration methods are described below: master and slave means that there are no less than two servers. Here, 192.168.0.1 (master server database) 192.168.0.2 (slave server database) is taken as an example:

Master server master configuration [mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

User=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

Symbolic-links=0 server-id=1

Log-bin=mysql-bin

Relay-log=relay-bin

Relay-log-index=relay-bin-index [mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

Configure currency symbols from server Slave

[mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

User=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

Symbolic-links=0

Server-id=2 # cannot be the same as the primary server

Log-bin=mysql-bin

Replicate-do-db=test # Select a hot backup database

Log-slave-updates=1 [mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

When the configuration is complete, login Slave, and then execute the following command: mysql > stop slave

Mysql > change master to master_host='192.168.0.1',master_user='root',master_password='123456'

# configuration of the master database

Mysql > start slave

Mysql > show slave status\ G

Financial question and answer http://www.gendan5.com/topic/businessnews.html

Check whether the relevant configuration is working properly: yes is normal.

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

If either of the above two configurations is No. The hot standby cannot be carried out normally, and the specific reasons need to be checked.

Finally, when the test does anything in the test library of the master data, the test in the database of the slave server will be synchronized to this point, and the Linux master-slave hot backup data will be completed.

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