CN112380056A - Master-slave backup method and device for database of information-guaranteeing master station - Google Patents

Master-slave backup method and device for database of information-guaranteeing master station Download PDF

Info

Publication number
CN112380056A
CN112380056A CN202011243748.6A CN202011243748A CN112380056A CN 112380056 A CN112380056 A CN 112380056A CN 202011243748 A CN202011243748 A CN 202011243748A CN 112380056 A CN112380056 A CN 112380056A
Authority
CN
China
Prior art keywords
database
master
configuration
vrrp
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.)
Withdrawn
Application number
CN202011243748.6A
Other languages
Chinese (zh)
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.)
SHANGHAI XJ ELECTRIC CO Ltd
State Grid Corp of China SGCC
Xuji Group Co Ltd
Original Assignee
SHANGHAI XJ ELECTRIC CO Ltd
State Grid Corp of China SGCC
Xuji Group 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 SHANGHAI XJ ELECTRIC CO Ltd, State Grid Corp of China SGCC, Xuji Group Co Ltd filed Critical SHANGHAI XJ ELECTRIC CO Ltd
Priority to CN202011243748.6A priority Critical patent/CN112380056A/en
Publication of CN112380056A publication Critical patent/CN112380056A/en
Withdrawn legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1479Generic software techniques for error detection or fault masking
    • G06F11/1482Generic software techniques for error detection or fault masking by means of middleware or OS functionality
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/142Reconfiguring to eliminate the error
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Abstract

The invention relates to a master-slave backup method and a master-slave backup device for a database of a trust-preserving master station.A master station is provided with two server databases, the two databases are both set as master databases through configuration, namely, a mode of backup of double master databases is formed, a keepalive virtual IP is adopted to provide external services, a program is connected with the virtual IP, and the virtual IP can detect the state of a MYSQL database to carry out drift between the master and slave servers, thereby solving the problem of hot switching of the servers and realizing the high availability of MYSQL database components.

Description

Master-slave backup method and device for database of information-guaranteeing master station
Technical Field
The invention relates to the technical field of power system relay protection, in particular to a database master-slave backup method and device of a communication protection master station.
Background
At present, a main station system of a new generation of relay protection fault information system (hereinafter referred to as a "main station for information protection") aims to realize high availability of the whole system, and when each component is forced to stop accidentally or a server is down, the system can be ensured to operate continuously and stably without being broken down, but because many components are involved in the main station for information protection, the main and standby servers need to be deployed in a distributed manner.
The conventional MYSQL database only supports a single version, only one server supports read-write operation of the MYSQL database, and if the read-write operation data volume is too large, or server failure and other conditions occur, the MYSQL cannot work normally, so that normal use of the whole system is influenced, and therefore high availability of the MYSQL component is required to be achieved. The defects of the single-version MYSQL database are mainly reflected in the following aspects:
(1) the MYSQL database deployment is in a single-machine version state, the deployment mode does not provide any safety guarantee and high availability, once a single-point fault occurs, the MYSQL database component cannot be used, and the operation of the whole insurance master station is influenced.
(2) Due to the adoption of a single-machine version MYSQL database deployment mode, the pressure of reading and writing data is concentrated on the same server, once a large amount of data needs to be taken out of or stored in the MYSQL database within a very small period of time, great pressure is generated on the server, and the server is crashed. After a server deployed by the MYSQL database is down, the MYSQL database component is paralyzed to influence the use of the whole system.
Disclosure of Invention
Based on the above situation in the prior art, the invention aims to solve the problems of low availability and hot handover of the MYSQL database component in the new trust master station by adopting a database setting mode of a dual master mode to realize a backup mode.
In order to achieve the above object, according to an aspect of the present invention, there is provided a method for master-slave backup of a database of a trust master, including the steps of:
selecting two servers and configuring the database into a double-host backup mode;
respectively logging in databases on the two servers, and setting a database corresponding to the other server as a slave database;
providing external services by virtualizing an IP through keepalive, and determining a server as a current main database by using the position of a server mounted by the virtual IP;
and judging the state of the current master database by using scripts in the keepalived configuration file, and mounting the virtual IP to another master database when the current master database stops running so as to realize hot switching of the master database.
Further, the database includes MYSQL.
Further, the configuring the database into the dual-host backup mode includes adding an enabled backup mode configuration, adding a binary log location configuration, and adding a binary log update time configuration.
Further, the method for judging the state of the current master database by using scripts in the keepalived configuration file comprises the following steps:
judging whether the database is running;
if the database is running, judging whether the iptable has VRRP configuration, and if the iptable has VRRP configuration, deleting the relevant configuration;
if the database is not operated and the VRRP configuration is not available, the VRRP configuration is added, and the transmission of the VRRP message is forbidden.
According to another aspect of the invention, a database master-slave backup device of a credit protection master station is provided, which comprises a dual-host backup mode configuration module and a master database switching module; wherein the content of the first and second substances,
the dual-host backup mode configuration module is used for configuring the database into a dual-host backup mode; respectively logging in databases on the two selected servers, and setting a database corresponding to the other server as a slave database;
the main database switching module provides external services by virtualizing an IP (Internet protocol) through keepalive, and determines a server as a current main database according to the position of the server mounted by the virtual IP; and judging the state of the current master database by using scripts in the keepalived configuration file, and mounting the virtual IP to another master database when the current master database stops running so as to realize hot switching of the master database.
Further, the database includes MYSQL.
Further, in the dual-host backup mode configuration module, the database is configured to be in the dual-host backup mode, which includes adding a configuration of an enabled backup mode, adding a configuration of a location of a binary log, and adding a configuration of an update time of the binary log.
Further, in the master database switching module, determining a state of a current master database using scripts in a keepalive configuration file, including,
judging whether the database is running;
if the database is running, judging whether the iptable has VRRP configuration, and if the iptable has VRRP configuration, deleting the relevant configuration;
if the database is not operated and the VRRP configuration is not available, the VRRP configuration is added, and the transmission of the VRRP message is forbidden.
In summary, the invention provides a master-slave backup method and device for a database of a trust-preserving master station, wherein two server databases are arranged in the trust-preserving master station, and both databases are configured as master databases, i.e. a dual-master database backup mode is formed, and a keepalive virtual IP is adopted to provide external services, and a program is connected with the virtual IP, and the virtual IP can detect the state of a MYSQL database to perform drift between the master and slave servers, thereby solving the problem of hot switching of the servers and realizing high availability of MYSQL database components.
Drawings
FIG. 1 is a schematic diagram of a database master-slave backup method of a trust-preserving master station according to the present invention;
FIG. 2 is a flowchart of an embodiment of a database master-slave backup method of a trust-preserving master station according to the present invention;
fig. 3 is a schematic overall structure diagram of the database master-slave backup device of the information-protecting master station of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings in conjunction with the following detailed description. It should be understood that the description is intended to be exemplary only, and is not intended to limit the scope of the present invention. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present invention.
The technical solution of the present invention will be described in detail below with reference to the accompanying drawings. According to an embodiment of the invention, a master-slave backup method for a database of a trust-guaranteeing master station is provided, a MYSQL database synchronization permission library and configuration library data are deployed in a zone II and a zone III of the trust-guaranteeing master station, two servers are required to be deployed in the zone II and the zone III for backup respectively due to an isolation device between the zone II and the zone III, and a schematic diagram of the principle of the method is shown in FIG. 1. As shown in fig. 1, the method is implemented in a manner that two server databases are provided in the trust master, and both databases are configured as a master database, i.e., a dual master database backup mode is formed. And then, providing external services by virtualizing an IP through keepalived, and determining which server is the current main database of the MYSQL database component according to the position of the server mounted by the virtual IP. Therefore, the problem that the MYSQL database component is low in availability in a new information-guaranteeing main station is solved, and the problem of hot switching between two servers is solved in a mode of carrying out virtual IP drifting through keepalived. The flow chart of the implementation of the method is shown in fig. 2. The method comprises the following steps:
selecting two servers and configuring the database into a double-host backup mode; and respectively logging in databases on the two servers, and setting the database corresponding to the other server as a slave database. Specifically, the configuration of the dual host backup mode may be achieved by: add configuration description to my. cnf configuration file: adding server id configuration to set a backup mode needed to be started for the MYSQL database; adding a log _ bin parameter specifying the location of the binary log; the log _ slave _ updates parameter is added to account for the update time of the binary log, until the configuration of my.
In two selected servers, a MYSQL database is logged in one machine, and the following commands are input in a command line of the MYSQL database:
print reproduction slave on to ' IP address of shared account ' @ ' slave ' secret code '
The code is used for setting a MYSQL account on a certain IP as a local slave library and then inputting:
show master status;
at this point, the number and location of the mysql-bin file will be displayed.
And logging MYSQL on another server, and sequentially inputting:
stop slave;
change master to master host ═ IP address of master ═ test ═ master _ user ═ test ═ master _ password ═ your password ═ master _ log _ file ═ mysql-bin.000019 ═ master _ log _ pos ═ 338; (filled in according to status of the former master)
start slave;
If the information is filled correctly, the show SLAVE status \ G is input, yes is displayed in both the SLAVE _ IO _ RUNNING line and the SLAVE _ SQL _ RUNNING line, and when two yes are displayed, the MYSQL server is successfully set as the SLAVE library of the other MYSQL server.
And then repeating the above operations, reversing the position of the target server, and setting the current master library as the slave library of the current slave library, so that the MYSQL database forms a double-master database backup mode.
Next, providing external services by virtualizing an IP through keepalive, and determining a server as a current main database according to the position of the server mounted by the virtual IP; and judging the state of the current master database by using scripts in the keepalived configuration file, and mounting the virtual IP to another master database when the current master database stops running so as to realize hot switching of the master database. Judging the state of the current master database by using scripts in the keepalived configuration file, wherein the method comprises the following steps: and judging whether the database is running and whether the VRRP configuration exists, if the database stops running and no VRRP configuration exists, prohibiting the VRRP from sending, and if the database is running and the VRRP configuration exists, deleting the VRRP configuration.
According to another embodiment of the present invention, there is provided a database master-slave backup apparatus for a trust-preserving primary station, an overall structural diagram of the apparatus is shown in fig. 3, and the apparatus includes: the system comprises a dual-host backup mode configuration module and a main database switching module. And the double-host backup mode configuration module selects two servers and configures the database into a double-host backup mode. Specifically, configurations including adding an enable backup mode configuration, adding a binary log location configuration, and adding a binary log update time configuration are included. And aiming at the two selected servers, respectively logging in databases on the two servers, and setting a database corresponding to the other server as a slave database master database switching module. Providing external services by virtualizing an IP through keepalive, and determining a server as a current main database by using the position of a server mounted by the virtual IP; using scripts in a keepalived configuration file to judge the state of a current master database, the method comprises the following steps: and judging whether the database is running and whether the VRRP configuration exists, if the database stops running and no VRRP configuration exists, prohibiting the VRRP from sending, and if the database is running and the VRRP configuration exists, deleting the VRRP configuration. And when the current master database stops running, mounting the virtual IP to another master database so as to realize hot switching of the master database.
In summary, the invention relates to a master-slave backup method and device for a database of a trust-preserving master station, wherein two server databases are arranged in the trust-preserving master station, and both databases are arranged as master databases through configuration, i.e. a mode of backup of a double-master database is formed, and a keepalive virtual IP is adopted to provide external services, a program is connected with the virtual IP, and the virtual IP can detect the state of a MYSQL database to perform drift between the master and slave servers, thereby solving the problem of hot switching of the servers and realizing high availability of MYSQL database components.
It is to be understood that the above-described embodiments of the present invention are merely illustrative of or explaining the principles of the invention and are not to be construed as limiting the invention. Therefore, any modification, equivalent replacement, improvement and the like made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. Further, it is intended that the appended claims cover all such variations and modifications as fall within the scope and boundaries of the appended claims or the equivalents of such scope and boundaries.

Claims (7)

1. A master-slave backup method for a database of a trust-guaranteeing master station is characterized by comprising the following steps:
selecting two servers and configuring the database into a double-host backup mode;
respectively logging in databases on the two servers, and setting a database corresponding to the other server as a slave database;
providing external services by virtualizing an IP through keepalive, and determining a server as a current main database by using the position of a server mounted by the virtual IP;
and judging the state of the current master database by using scripts in the keepalived configuration file, and mounting the virtual IP to another master database when the current master database stops running so as to realize hot switching of the master database.
2. The method of claim 1, wherein the database comprises MYSQL.
3. The method of claim 2, wherein configuring the database in the dual-master backup mode comprises adding an enable backup mode configuration, adding a binary log location configuration, and adding a binary log update time configuration.
4. The method according to claim 3, wherein the script is used in the keepalive configuration file to judge the status of the current master database, comprising the steps of:
judging whether the database is running;
if the database is running, judging whether the iptable has VRRP configuration, and if the iptable has VRRP configuration, deleting the relevant configuration;
if the database is not operated and the VRRP configuration is not available, the VRRP configuration is added, and the transmission of the VRRP message is forbidden.
5. A master-slave backup device of a database of a communication protection master station is characterized by comprising a double-host backup mode configuration module and a master database switching module; wherein the content of the first and second substances,
the dual-host backup mode configuration module is used for configuring the database into a dual-host backup mode; respectively logging in databases on the two selected servers, and setting a database corresponding to the other server as a slave database;
the main database switching module provides external services by virtualizing an IP (Internet protocol) through keepalive, and determines a server as a current main database according to the position of the server mounted by the virtual IP; and judging the state of the current master database by using scripts in the keepalived configuration file, and mounting the virtual IP to another master database when the current master database stops running so as to realize hot switching of the master database.
6. The apparatus of claim 5, wherein the database comprises MYSQL.
7. The apparatus of claim 6, wherein the dual host backup mode configuration module configures the database into the dual host backup mode, including adding an enabled backup mode configuration, adding a binary log location configuration, and adding a binary log update time configuration.
The apparatus of claim 7, wherein in the master database switching module, determining a state of a current master database using scripts in a keepalived profile comprises,
judging whether the database is running;
if the database is running, judging whether the iptable has VRRP configuration, and if the iptable has VRRP configuration, deleting the relevant configuration;
if the database is not operated and the VRRP configuration is not available, the VRRP configuration is added, and the transmission of the VRRP message is forbidden.
CN202011243748.6A 2020-11-10 2020-11-10 Master-slave backup method and device for database of information-guaranteeing master station Withdrawn CN112380056A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011243748.6A CN112380056A (en) 2020-11-10 2020-11-10 Master-slave backup method and device for database of information-guaranteeing master station

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011243748.6A CN112380056A (en) 2020-11-10 2020-11-10 Master-slave backup method and device for database of information-guaranteeing master station

Publications (1)

Publication Number Publication Date
CN112380056A true CN112380056A (en) 2021-02-19

Family

ID=74578938

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011243748.6A Withdrawn CN112380056A (en) 2020-11-10 2020-11-10 Master-slave backup method and device for database of information-guaranteeing master station

Country Status (1)

Country Link
CN (1) CN112380056A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105227394A (en) * 2015-08-27 2016-01-06 浪潮电子信息产业股份有限公司 A kind of fault detect of the DB2 database based on x86 platform and changing method
CN108259239A (en) * 2018-01-11 2018-07-06 郑州云海信息技术有限公司 A kind of database high availability support method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105227394A (en) * 2015-08-27 2016-01-06 浪潮电子信息产业股份有限公司 A kind of fault detect of the DB2 database based on x86 platform and changing method
CN108259239A (en) * 2018-01-11 2018-07-06 郑州云海信息技术有限公司 A kind of database high availability support method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
汪海洋 等: ""基于keepalived的高可用性应用研究"", 《电子技术》 *

Similar Documents

Publication Publication Date Title
EP3493471B1 (en) Data disaster recovery method, apparatus and system
US11194679B2 (en) Method and apparatus for redundancy in active-active cluster system
CN105159795A (en) Data synchronization method, apparatus and system
CN105940397A (en) Application synchornization
CN105095245B (en) Archive log synchronous method and system based on association type database
KR20110044858A (en) Maintain data indetermination in data servers across data centers
CN112100005B (en) Redis copy set implementation method and device
CN109558273B (en) Disk array backup method, electronic equipment and disk array
US10503415B2 (en) Snapshot processing method and related device
US8255649B2 (en) Remote copy control method and system in storage cluster environment
CN113656147B (en) Cluster deployment method, device, equipment and storage medium
CN112380062A (en) Method and system for rapidly recovering system for multiple times based on system backup point
CN111147274B (en) System and method for creating a highly available arbitration set for a cluster solution
CN110908723A (en) Main/standby switching method and device of operating system and related equipment
US10855776B2 (en) Method and device for managing sessions
JP2015506112A (en) Redirecting requests to a second location during a temporary failure
US20150256446A1 (en) Method and apparatus for relaying commands
CN112380056A (en) Master-slave backup method and device for database of information-guaranteeing master station
CN105159794A (en) Mirror image implementing system and method
KR101618992B1 (en) System for providing virtual desktop service, control method thereof, recording medium for recording program for executing the control method, application saved in the recording medium for executing the control method being combined with hardware
CN111597192A (en) Database switching control method and device and electronic equipment
CN111835857B (en) Method and apparatus for accessing data
US11748314B2 (en) Method, device and computer program product for data replication
CN117785568A (en) Dual-master dual-machine hot standby method and device
CN117692500A (en) Operation method, device, equipment and storage medium

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
WW01 Invention patent application withdrawn after publication

Application publication date: 20210219

WW01 Invention patent application withdrawn after publication