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

Implementation scheme of dual-computer hot backup for mysql [testable]

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

Share

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

I. concept

1. The difference between hot backup and backup

Hot backup refers to: High Available (HA) is highly available, while backup refers to Backup, a kind of data backup. These are two different concepts, and the products they deal with are also two products with completely different functions. Hot backup mainly ensures the continuity of business, which is realized by the transfer of the point of failure. The main purpose of backup is to make a copy to prevent data loss, so backup emphasizes data recovery rather than application failover.

2. What is dual-computer hot backup?

In a broad sense, dual-computer hot backup means that for important services, two servers are used to back up each other and execute the same service together. When one server fails, another server can undertake the service task, so as to automatically ensure that the system can provide continuous service without human intervention.

In a narrow sense, dual hot backup means that two servers that are backup to each other are used to perform the same service together, one of which is a work machine (Primary Server) and the other is a backup host (Standby Server). Under the normal condition of the system, the working machine provides services for the application system, and the backup machine monitors the operation of the working machine (usually through heartbeat diagnosis, and the working machine is also testing whether the backup machine is normal or not). When the working machine is abnormal and cannot support the operation of the application system, the backup machine takes over the work of the working machine actively and continues to support key application services to ensure the uninterrupted operation of the system. Dual-computer hot backup is a high-availability solution for the failure of IT core servers, storage, and network routing switching.

II. Description of the environment

1 、 master

System: windows 7

Database: mysql5.5

Ip:192.168.0.123

2 、 slave

System: windows 7

Database: mysql5.5

Ip:192.168.0.105

(note: the version of the master server cannot be higher than that of the slave server, and the two servers must be on the same LAN)

Third, the realization of master-slave hot standby

1. Account preparation

① establishes a connection account on the master server from the server, which must be granted REPLICATION SLAVE permissions. Enter the mysql interface and enter the following SQL:

Grant replication slave on *. * to 'replicate'@'192.168.0.105' identified by' 123456

The operation is shown in the figure:

② verifies the connection account

Use the replicat account on the slave server (slave) to access the master server (master) database to see if you can connect successfully.

When opening a command prompt from the server, enter the following command:

Mysql-h292.168.0.123-ureplicate-p123456

If the following result appears, it means that the login is successful, which means that the two servers can be operated by dual-server hot backup.

2. Master configuration

① modifies the mysql configuration file. After finding the my.ini configuration file and opening it, you can modify it under [mysqld]:

[mysqld]

Server-id = 123 # Master ID, which cannot be the same as slave ID

Log-bin=mysql-bin# settings generate log file name

Binlog-do-db = test_db # sets the synchronization database name

Replicate-do-db=test_db # synchronize database names from the server

Binlog-ignore-db = mysql# avoid synchronizing mysql user configuration

② restarts the mysql service

Open a command prompt and enter the following two commands to complete the restart:

Net stop mysqlnet start mysql

③ to view the status of master server

Show master status

④ lock table

The purpose is to generate no new data in the environment, so that the synchronization location can be located from the server, and remember to unlock it after the first synchronization is completed.

Flush tables with read lock

The step ③④ operation is shown in the figure:

3. Slave configuration

① modifies my.ini configuration file

Log-bin=mysql-bin # sets the name of the generated log file

Server-id=105# slave ID, cannot be the same as master ID

Binlog-do-db=test_db # set the synchronization database name

Binlog-ignore-db=mysql # avoid synchronizing mysql user configuration

Replicate-do-db=test_db# synchronizes the database name from the server

Replicate-ignore-db = mysql,information_schema,performance_schema

② restarts the mysql service

③ uses the change mster statement to specify the synchronization location

After entering the mysql interface, enter the following instructions:

Stop slave;reset slave;change master to master_host='192.168.0.123',master_user='replicate',master_password='123456',master_log_file='mysql-bin.000124',master_log_pos=107;start slave

Note: the master_log_file and master_log_pos here must be consistent with the previous show master status query results

The operation is shown in the figure:

4. Unlock master table

Unlock tables

At this point, the master-slave hot standby implementation is completed, and the test operation can be carried out.

Summary

The above is the implementation scheme of mysql dual-computer hot standby introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!

If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!

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