Nothing Special   »   [go: up one dir, main page]

CN109739685B - Master-slave hot backup data synchronization method and storage medium - Google Patents

Master-slave hot backup data synchronization method and storage medium Download PDF

Info

Publication number
CN109739685B
CN109739685B CN201811397660.2A CN201811397660A CN109739685B CN 109739685 B CN109739685 B CN 109739685B CN 201811397660 A CN201811397660 A CN 201811397660A CN 109739685 B CN109739685 B CN 109739685B
Authority
CN
China
Prior art keywords
server
slave
master
data
slave server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811397660.2A
Other languages
Chinese (zh)
Other versions
CN109739685A (en
Inventor
赵定金
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Baolun Electronics Co ltd
Original Assignee
Guangdong Baolun Electronics Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Baolun Electronics Co ltd filed Critical Guangdong Baolun Electronics Co ltd
Priority to CN201811397660.2A priority Critical patent/CN109739685B/en
Publication of CN109739685A publication Critical patent/CN109739685A/en
Application granted granted Critical
Publication of CN109739685B publication Critical patent/CN109739685B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Hardware Redundancy (AREA)

Abstract

The application discloses a master-slave hot backup data synchronization method and a storage medium, comprising the following steps: respectively backing up local data of the master server and the data of the slave server, and then synchronizing the data of the master server and the data of the slave server; the method for synchronizing the data of the master server and the slave server specifically comprises the following steps: the method comprises the steps of firstly synchronizing configuration files of a master server and a slave server, and then synchronizing data of the master server and the slave server based on a master-slave replication mechanism of a MariaDB. The application solves the problems of data backup and synchronization of the master server and the slave server, increases the data safety by a mode of carrying out remote synchronization simultaneously by local backup, and improves the stability of system operation.

Description

Master-slave hot backup data synchronization method and storage medium
Technical Field
The application relates to the field of data backup of a master server and a slave server of a system, in particular to a synchronization method and a storage medium of hot backup data of the master server and the slave server.
Background
Many projects are developed by taking a server as a center, the server is used as an operation core of the whole system, and is responsible for scheduling work of equipment management of the whole system, and normal operation of system services is important.
The normal operation of the system service needs to be supported by accurate data, so the automatic synchronization and automatic management of the data are the basic stones for the stable operation of the system. How to solve the data backup and synchronization problems of the main server and the standby server, increase the data security, and provide the stability of the system operation is still a difficulty in the development of computer technology.
Disclosure of Invention
In view of the above technical problems, the present application aims to provide a master-slave hot backup data synchronization method, which solves the problem of data backup and synchronization of a master server and a slave server, increases data security by a mode of performing remote synchronization simultaneously with local backup, and improves the stability of system operation.
The application adopts the following technical scheme:
a master-slave hot backup data synchronization method comprises the following steps:
respectively backing up local data of the master server and the data of the slave server, and then synchronizing the data of the master server and the data of the slave server;
the method for synchronizing the data of the master server and the slave server specifically comprises the following steps: the method comprises the steps of firstly synchronizing configuration files of a master server and a slave server, and then synchronizing data of the master server and the slave server based on a master-slave replication mechanism of a MariaDB.
Further, the method for synchronizing data between the master server and the slave server by using the master-slave replication mechanism based on the MariaDB comprises the following steps: when the data of the main server is operated, the related operation record of the main server is recorded in a binary log mode, and the recorded related operation record is sent to the auxiliary server in a command form, so that the auxiliary server executes the same operation as the main server on the auxiliary server according to the received command; when operating on the slave server data, a command of a related operation record of the slave server recorded in a binary log transmitted from the slave server is received, and the same operation as the slave server is performed according to the received command.
Further, the method for synchronizing the configuration files of the master server and the slave server specifically includes: setting configuration parameters of a master server and a slave server, synchronizing configuration files through a GO voice program, specifically, monitoring running states of the master server and the slave server by receiving instructions of the master server and the slave server, and sending instructions to the master server and the slave server according to the running states so as to synchronize the configuration files of the master server and the slave server.
Further, the method for synchronizing the data of the master server and the slave server further comprises the following steps: when the network reconnection is resumed after the connection of the master server and the slave server is disconnected, the data of the master server and the slave server are automatically synchronized by the heartbeat detection program.
Further, when the service is restored after the service of the master server and the slave server is terminated, the data of the master server and the slave server are automatically synchronized through the heartbeat detection program.
Further, when the master server and the slave server are synchronized with each other, the configuration file includes an ini file or an mp3 audio file.
Further, the method for backing up the local data of the master server and the slave server data specifically includes: backing up in a master server or a slave server database through an innoDB storage engine respectively, and setting the isolation level of dump process transactions as readable repeatedly; and enabling the selection-single-transaction in the inodb table of the inodb storage engine to reconcile the local data backups.
Further, the method for backing up the local data of the master server and the slave server data respectively further comprises: and backing up three local copies of the local data of the master server and the slave server in a lock table backup mode.
A computer storage medium having stored thereon a computer program which, when executed by a processor, implements the master-slave hot-standby data synchronization method described above.
Compared with the prior art, the application has the beneficial effects that:
the application solves the problems of data backup and synchronization of the master server and the slave server, increases the data safety by a mode of carrying out remote synchronization simultaneously by local backup, and improves the stability of system operation.
Further, by triggering the backup in a command manner, the redundancy of data synchronized in time in the prior art is avoided. The application can realize the bidirectional data synchronization of the master server and the slave server, the prior art is generally unidirectional, and the unidirectional synchronization is simpler, but the configuration data of the slave server can be covered by the old data of the master server when in use, thereby causing data loss. The prior art generally synchronizes according to time, the too long time interval can cause untimely synchronization, too short time and consume server resources, and the application performs the same command as the slave server or the master server according to the received command by the master server and the slave server respectively to perform operation command type triggering synchronization
Drawings
FIG. 1 is a flow chart of a master-slave hot backup data synchronization method according to the present application.
Detailed Description
The present application will be further described with reference to the accompanying drawings and detailed description, wherein, on the premise of no conflict, the following embodiments or technical features can be arbitrarily combined to form new embodiments:
examples:
referring to fig. 1, a master-slave hot backup data synchronization method includes the following steps:
step S100, backing up local data of the main server and the slave server data respectively;
specifically, the method for backing up the local data of the master server and the slave server data respectively specifically includes: backing up in a master server or a slave server database through an innoDB storage engine respectively, and setting the isolation level of dump process transactions as readable repeatedly; and enabling the selection-single-transaction in the inodb table of the inodb storage engine to reconcile the local data backups.
Specifically, after the master server and the slave server are installed, the corresponding IP addresses are set, the synchronous service is started, the monitoring port is set, the synchronous directory is set, and the data synchronous instruction is waited. The method comprises the following specific steps of: the method comprises the steps of firstly recording binlog and pos points of a main library in a dump process by utilizing an innoDB storage engine, setting the isolation level of a transaction as REPEATABLE READ, namely REPEATABLE READ, so that the same data can be READ in one transaction, namely the fact that during dump, if threads of other innoDB storage engines modify and submit data of a table, the data of the dump thread is not influenced, and an option-single-transaction is usually started to ensure consistency of the backup when the innoDB table is backed up, and the fact that data already submitted by other sessions can not be seen when the session (dump) is carried out.
Furthermore, the system also performs lock list backup, and three local copies are set for avoiding data pollution, so that the latest accurate version data can be restored when the data problem occurs.
And the local data is backed up for multiple times through automatic incremental synchronization of the local data, so that the safety of the system data is enhanced.
Step 200, synchronizing data of a master server and data of a slave server;
the method for synchronizing the data of the master server and the slave server specifically comprises the following steps:
step S2001, firstly, synchronizing configuration files of a master server and a slave server;
the method for synchronizing the configuration files of the master server and the slave server comprises the following steps: setting configuration parameters of a master server and a slave server, synchronizing configuration files through a GO voice program, specifically, monitoring running states of the master server and the slave server by receiving instructions of the master server and the slave server, and sending instructions to the master server and the slave server according to the running states so as to synchronize the configuration files of the master server and the slave server. When the master server and the slave server are subjected to configuration file synchronization, the configuration files comprise an ini file or an mp3 audio file.
In this way, the difference change of the main and standby service data is automatically found through the detection service written in the GO language by the data in the layer 1, namely the non-logic layer, and incremental synchronization is started within 1 second, so that the method has the advantages of low energy consumption and low delay; the step only needs to configure relevant parameters and start service, and file synchronization can be realized without installing other software. After the installation of the server (i.e. the master server) is completed, the service is automatically started, and after the installation of the client (the slave server), the master-slave relationship can be established with the master server by filling in the IP address information of the server.
And step S2002, the master server and the slave server are subjected to data synchronization based on a master-slave replication mechanism of the MariaDB.
The method for synchronizing data between the master server and the slave server by using the master-slave replication mechanism based on the MariaDB comprises the following steps: when the data of the main server is operated, the related operation record of the main server is recorded in a binary log mode, and the recorded related operation record is sent to the auxiliary server in a command form, so that the auxiliary server executes the same operation as the main server on the auxiliary server according to the received command;
when the slave server data is operated, a command of the related operation record of the slave server, which is recorded in a binary log manner and is sent by the slave server, is received, and the same operation as the slave server is executed according to the received command, so that bidirectional data synchronization of the master server and the slave server is realized.
The method for synchronizing the data of the master server and the slave server further comprises the following steps: when the network reconnection is resumed after the connection of the master server and the slave server is disconnected, the data of the master server and the slave server are automatically synchronized by the heartbeat detection program.
The heartbeat detection program in the application comprises the following steps: the slave server sends data packets to the master server at fixed once per second frequency, the master server replies a confirmation packet after receiving the data packets, when each packet has confirmation packet evidence, the master server is indicated to work well, and in order to reduce misjudgment, the master server is judged to be faulty when the slave server does not receive confirmation for 5 consecutive packets.
When the service is restored after the service of the master server and the slave server is terminated, the data of the master server and the slave server are automatically synchronized through the heartbeat detection program.
In this way, after the layer 2 logic service data is changed, the master-slave data synchronization function is adopted to automatically synchronize to the redundant database; under the condition of reconnection of disconnected network or service stop and restarting, the second-level automatic recovery data synchronization function can be realized without manual intervention; different from the existing configuration mode, by providing a master-slave configuration script, the service is automatically started after the installation of the server (i.e. the master server), the IP address information of the server is filled in after the installation of the client (slave server), and the master-slave relationship can be established with the master server, so that the function configuration can be completed by executing on the standby server and inputting the IP of the host, the configuration steps are greatly simplified, and the configuration difficulty and complexity are reduced.
Compared with the prior art, the method can realize bidirectional data synchronization of the master server and the slave server, the prior art is generally unidirectional, unidirectional synchronization is simpler, but configuration data of the slave server in use can be covered by old data of the master server, and data loss is caused.
In the prior art, the synchronization is generally performed according to time, the time interval is too long, the synchronization is not timely, the time is too short, and server resources are consumed. The application has low requirement on hardware, the prior art generally adopts a double-network card server, one network card is used for heartbeat detection, and the other network card is used for data backup. The configuration of the application is simple, only one-step configuration is needed by the slave server, the synchronization time is short, the incremental synchronization can be completed within 6 seconds generally, and the automatic detection is carried out after the network disconnection is automatically reconnected.
The application solves the data backup and synchronization problems of the master server and the slave server, increases the data safety by a mode of carrying out remote synchronization simultaneously by local backup, improves the stability of system operation, and further avoids the data redundancy synchronous according to time in the prior art by command type triggering backup.
A computer storage medium having stored thereon a computer program which, when executed by a processor, implements the master-slave hot-standby data synchronization method described above.
It will be apparent to those skilled in the art from this disclosure that various other changes and modifications can be made which are within the scope of the application as defined in the appended claims.

Claims (7)

1. A master-slave hot backup data synchronization method is characterized by comprising the following steps:
respectively backing up local data of the master server and the data of the slave server, and then synchronizing the data of the master server and the data of the slave server;
the method for synchronizing the data of the master server and the slave server specifically comprises the following steps: firstly, synchronizing configuration files of a master server and a slave server, and then synchronizing data of the master server and the slave server based on a master-slave replication mechanism of a MariaDB;
the step of synchronizing configuration files of the master server and the slave server is specifically as follows: firstly setting configuration parameters of a master server and a slave server, synchronizing configuration files through a GO voice program, specifically, monitoring the running states of the master server and the slave server by receiving instructions of the master server and the slave server, and transmitting instructions to the master server and the slave server according to the running states so as to synchronize the configuration files of the master server and the slave server;
the master-slave replication mechanism based on the MariaDB specifically performs data synchronization on the master server and the slave server: when the data of the main server is operated, the related operation record of the main server is recorded in a binary log mode, and the recorded related operation record is sent to the auxiliary server in a command form, so that the auxiliary server executes the same operation as the main server on the auxiliary server according to the received command; when operating on the slave server data, a command of a related operation record of the slave server recorded in a binary log transmitted from the slave server is received, and the same operation as the slave server is performed according to the received command.
2. The master-slave hot standby data synchronization method according to claim 1, wherein the method for synchronizing data of the master server and the slave server further comprises the steps of: when the network reconnection is resumed after the connection of the master server and the slave server is disconnected, the data of the master server and the slave server are automatically synchronized by the heartbeat detection program.
3. The master-slave hot-standby data synchronization method according to claim 1, wherein the data of the master server and the slave server are automatically synchronized by a heartbeat detection program when the service is restored after the service of the master server and the slave server is terminated.
4. The master-slave hot standby data synchronization method according to claim 1, wherein the configuration file comprises an ini file or an mp3 audio file when the master server and the slave server are synchronized.
5. The method for synchronizing data of master-slave hot backup according to claim 1, wherein the method for backing up local data of the master server and the slave server data respectively comprises: backing up in a master server or a slave server database through an innoDB storage engine respectively, and setting the isolation level of dump process transactions as readable repeatedly; and enabling the selection-single-transaction in the inodb table of the inodb storage engine to reconcile the local data backups.
6. The master-slave hot backup data synchronization method according to claim 5, wherein the method of backing up local data of the master server and the slave server data, respectively, further comprises: and backing up three local copies of the local data of the master server and the slave server in a lock table backup mode.
7. A computer storage medium having stored thereon a computer program which, when executed by a processor, implements a master-slave hot-standby data synchronization method as claimed in any one of claims 1 to 6.
CN201811397660.2A 2018-11-22 2018-11-22 Master-slave hot backup data synchronization method and storage medium Active CN109739685B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811397660.2A CN109739685B (en) 2018-11-22 2018-11-22 Master-slave hot backup data synchronization method and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811397660.2A CN109739685B (en) 2018-11-22 2018-11-22 Master-slave hot backup data synchronization method and storage medium

Publications (2)

Publication Number Publication Date
CN109739685A CN109739685A (en) 2019-05-10
CN109739685B true CN109739685B (en) 2023-10-20

Family

ID=66357023

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811397660.2A Active CN109739685B (en) 2018-11-22 2018-11-22 Master-slave hot backup data synchronization method and storage medium

Country Status (1)

Country Link
CN (1) CN109739685B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110351122B (en) * 2019-06-17 2022-02-25 腾讯科技(深圳)有限公司 Disaster recovery method, device, system and electronic equipment
CN113326318A (en) * 2021-05-28 2021-08-31 广州市炬元互联网科技有限公司 Method and system for data synchronization between two systems
CN113672681A (en) * 2021-07-29 2021-11-19 珠海许继芝电网自动化有限公司 Real-time synchronization method and system for power distribution network data
CN115509810B (en) * 2022-09-26 2024-04-05 广东保伦电子股份有限公司 Remote backup method and device for cloud data

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107911238A (en) * 2017-11-13 2018-04-13 郑州云海信息技术有限公司 One kind is based on IPSAN servers two unit standby method and system
CN108573006A (en) * 2017-06-06 2018-09-25 北京金山云网络技术有限公司 Across computer room data synchronous system, method and device, electronic equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050071391A1 (en) * 2003-09-29 2005-03-31 International Business Machines Corporation High availability data replication set up using external backup and restore

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108573006A (en) * 2017-06-06 2018-09-25 北京金山云网络技术有限公司 Across computer room data synchronous system, method and device, electronic equipment
CN107911238A (en) * 2017-11-13 2018-04-13 郑州云海信息技术有限公司 One kind is based on IPSAN servers two unit standby method and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
林思佳 ; 王玉林 ; 王平利 ; 卢建福 ; 刘彪 ; .GNSS CV精密时间服务系统的可靠性改进.时间频率学报.2013,(02),全文. *
闫映东 ; 文成玉 ; .中小企业OpenStack云平台高可用技术研究与实现.无线互联科技.2018,(05),全文. *

Also Published As

Publication number Publication date
CN109739685A (en) 2019-05-10

Similar Documents

Publication Publication Date Title
CN109739685B (en) Master-slave hot backup data synchronization method and storage medium
CN107291787B (en) Main and standby database switching method and device
CN103226502B (en) A kind of data calamity is for control system and data reconstruction method
US20110289056A1 (en) Method, node and system for controlling version in distributed system
US20070094467A1 (en) Method for rolling back from snapshot with log
CN106776121B (en) Data disaster recovery device, system and method
CN109189860A (en) A kind of active and standby increment synchronization method of MySQL based on Kubernetes system
US11947429B2 (en) Data disaster recovery method and site
CN110569269A (en) data synchronization method and system
CN115878384A (en) Distributed cluster based on backup disaster recovery system and construction method
CN113821376B (en) Cloud disaster recovery-based integrated backup disaster recovery method and system
CN104660386A (en) Method for improving DB2 disaster recovery high availability based on Itanium platform
CN112380062A (en) Method and system for rapidly recovering system for multiple times based on system backup point
CN105610566A (en) Real-time data synchronization method and system between main and standby nodes
CN115658390A (en) Container disaster tolerance method, system, device, equipment and computer readable storage medium
CN111984474B (en) Method, system and equipment for recovering double-control cluster fault
CN112631831A (en) Bare computer recovery method and system of service system
CN110489491B (en) Full data synchronization device suitable for A/B network double clusters
US10296517B1 (en) Taking a back-up software agnostic consistent backup during asynchronous replication
CN114579671A (en) Inter-cluster data synchronization method and device
CN112463458A (en) Remote copying method and equipment
CN110716828B (en) Database real-time backup method
CN116414915A (en) Distributed database cluster management and control method and device and database management and control platform
CN101155061B (en) Master/standby control method
CN107590024B (en) Data storage method and data storage system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: No. 56 Nanli East Road, Shiqi Town, Panyu District, Guangzhou City, Guangdong Province, 510000

Applicant after: Guangdong Baolun Electronics Co.,Ltd.

Address before: 511400 Building 1, industrial zone B, Zhongcun street, Zhongcun street, Panyu District, Guangzhou City, Guangdong Province

Applicant before: GUANGZHOU ITC ELECTRONIC TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant