CN113190374A - Application fault transfer system and method based on mysql MGR - Google Patents

Application fault transfer system and method based on mysql MGR Download PDF

Info

Publication number
CN113190374A
CN113190374A CN202110732953.7A CN202110732953A CN113190374A CN 113190374 A CN113190374 A CN 113190374A CN 202110732953 A CN202110732953 A CN 202110732953A CN 113190374 A CN113190374 A CN 113190374A
Authority
CN
China
Prior art keywords
mysql
database
node
mgr
domain name
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.)
Pending
Application number
CN202110732953.7A
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.)
Sichuan XW Bank Co Ltd
Original Assignee
Sichuan XW Bank 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 Sichuan XW Bank Co Ltd filed Critical Sichuan XW Bank Co Ltd
Priority to CN202110732953.7A priority Critical patent/CN113190374A/en
Publication of CN113190374A publication Critical patent/CN113190374A/en
Pending 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/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0793Remedial or corrective actions
    • 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/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/0709Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in a distributed system consisting of a plurality of standalone computer nodes, e.g. clusters, client-server systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses

Abstract

The invention belongs to the technical field of data transfer, and particularly relates to an application fault transfer system and method based on mysql MGR, which comprises a configuration module and a detection module; the configuration module is used for configuring mysql MGR clusters of a plurality of nodes, setting the MGR clusters as a single main mode, and defining any node as a main node; distributing a domain name to the mysql MGR cluster, wherein an effective node of the domain name is a main node; modifying the connection address of the application program into a domain name; the detection module determines that the main database is switched based on the fact that the MEMBER _ ROLE field is changed into the PRIMARY field; judging that the new main database plays back all data based on the closing of the read _ only parameter; by the connection mode of the domain name and the judgment of whether the read _ only parameter is closed, the split brain phenomenon can not occur under the condition that the data 0 is lost.

Description

Application fault transfer system and method based on mysql MGR
Technical Field
The invention belongs to the technical field of computer databases, and particularly relates to an application fault transfer system and method based on mysql MGR.
Background
The mysql MGR realizes the final consistency of data under the distributed mode and ensures that the data 0 is lost in the switching process. And MGR provides automatic failover of the database itself, but no automatic switching scheme at the drive level is provided by the authorities. Thus, even if the MGR does a problem with the master database, data 0 is lost, but manual intervention is still required to allow the program to reconnect to the new master database.
To ensure 0's of data are lost, VIP addresses are also a common way, common tools such as: keepalived; however, when the communication between the master database and the slave database is interrupted in the network, split brains may occur by using the VIP address.
Disclosure of Invention
The invention provides an application fault transfer system and method based on mysql MGR, which aim to solve the problem that split brains may occur in a mode of adopting VIP addresses when a master database and a slave database are referred to in the prior art and network communication is interrupted.
In order to achieve the purpose, the invention provides the following technical scheme:
an application failover system based on mysql MGR comprises a configuration module and a detection module;
the configuration module is used for configuring mysql MGR clusters of a plurality of nodes, setting the MGR clusters as a single main mode, and defining any node as a main node;
the configuration module allocates a domain name to the mysql MGR cluster, and an effective node of the domain name is the main node;
the configuration module is used for modifying the connection address of the application program into a domain name;
the detection module is used for detecting whether a MEMBER _ ROLE field in a replay _ group _ MEMBERs table in a mysql database in each node is changed into a PRIMARY field;
the detection module is used for detecting whether a read _ only parameter in a mysql database in each node is closed or not;
the detection module judges whether the main database is switched or not based on whether the MEMBER _ ROLE field is changed into the PRIMARY field or not; judging whether the new main database plays back all data or not based on whether the read _ only parameter is closed or not;
if the MEMBER _ ROLE field is changed into a PRIMARY word, the main database is indicated to be switched; if the read _ only parameter has been closed, it indicates that the new master database has played back all data.
According to the method, the split phenomenon of the brain can be avoided under the condition that the data 0 is lost through the connection mode of the domain name and the judgment on whether the read _ only parameter is closed.
When the master database is switched, the original master database becomes the slave database, and any slave database in the plurality of slave databases is switched to be the new master database. At this time, the domain name cannot necessarily correspond to a new main database; therefore, the current IP address is modified through the configuration module, and the current IP address corresponds to the domain name.
And when the modified IP address corresponds to the domain name, the application program locates a new IP address through the domain name to complete reconnection with the new main database.
An application failover method based on mysql MGR comprises the following steps:
step 1: the configuration module builds a mysql MGR cluster of a plurality of nodes, the single master mode is set, and any one node is defined as a master node;
step 2: the configuration module allocates a domain name to the mysql MGR cluster, and an effective node of the domain name is the main node;
and step 3: the configuration module modifies the connection address of the application program into a domain name;
and 4, step 4: the detection module detects whether a MEMBER _ ROLE field in a replay _ group _ MEMBERs table in a mysql database in each node is changed into a PRIMARY field; if the change indicates that the main database is switched, executing step 5; if not, it indicates that the main database is not switched, and does not execute step 5;
and 5: the detection module detects whether a read _ only parameter in a mysql database in each node is closed; if the data is closed, the new master database can be opened, which indicates that the new master database plays back all the data; if not, opening a new main database after the read _ only parameter is closed;
since the master database and the slave database may have a phenomenon that network communication is interrupted at any time, after the configuration of steps 1 to 3 is completed, step 4 needs to be periodically performed; for example: setting a timing module, and executing the step 4 once every ten seconds or four seconds; of course, the time interval for periodically performing step 4 may be performed according to specific situations, and the above example is not a limitation to the present invention; when it is found that the master database is switched by periodically performing step 4, step 5 is performed as described in step 4.
When the master database is switched, the original master database becomes the slave database, and any slave database in the plurality of slave databases is switched to be the new master database. At this time, the domain name cannot necessarily correspond to a new main database; therefore, the method also comprises the step 6: the configuration module modifies the current IP address to enable the current IP address to correspond to the domain name.
And 7: and automatically reconnecting the application program, and relocating to a new IP address through the domain name to complete the reconnection of the database.
Compared with the prior art, the invention has the beneficial effects that: according to the method, the split phenomenon of the brain can be avoided under the condition that the data 0 is lost through the connection mode of the domain name and the judgment on whether the read _ only parameter is closed.
Drawings
FIG. 1 is a schematic diagram of an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, a preferred embodiment of the present invention will be described in detail.
An application failover system based on mysql MGR comprises a configuration module and a detection module;
the configuration module is used for configuring A, B, C mysql MGR clusters of three nodes, is set to be in a single master mode, and defines a node A as a master node;
the configuration module allocates a domain name to the mysql MGR cluster, and an effective node of the domain name is the main node, namely the node A;
the configuration module is used for modifying the connection address of the application program into a domain name;
the detection module is used for detecting whether a MEMBER _ ROLE field in a replay _ group _ MEMBERs table in a mysql database in each node is changed into a PRIMARY field;
the detection module is used for detecting whether a read _ only parameter in a mysql database in each node is closed or not;
the detection module judges whether the main database is switched or not based on whether the MEMBER _ ROLE field is changed into the PRIMARY field or not; judging whether the new main database plays back all data or not based on whether the read _ only parameter is closed or not;
if the MEMBER _ ROLE field is changed into a PRIMARY word, the main database is indicated to be switched; if the read _ only parameter has been closed, it indicates that the new master database has played back all data.
According to the method, the split phenomenon of the brain can be avoided under the condition that the data 0 is lost through the connection mode of the domain name and the judgment on whether the read _ only parameter is closed.
When the master node is switched, namely the master node A is switched to the slave node A, and the slave node B is switched to the master node B, the domain name cannot necessarily correspond to a new master database; therefore, the IP address of the main node B is modified through the configuration module, so that the IP address of the main node B corresponds to the domain name.
And when the modified IP address of the main node B corresponds to the domain name, the application program locates the IP address of the main node B through the domain name to complete reconnection with a main database in which the main node B is located. Here, since the master node is switched, the corresponding master database is also switched.
An application failover method based on mysql MGR comprises the following steps:
step 1: the configuration module builds a mysql MGR cluster of A, B, C three nodes, the MGR cluster is set to be in a single-master mode, and a node A is defined as a master node;
step 2: the configuration module allocates a domain name to the mysql MGR cluster, and an effective node of the domain name is the main node, namely the node A;
and step 3: the configuration module modifies the connection address of the application program into a domain name;
and 4, step 4: the detection module detects whether a MEMBER _ ROLE field in a replay _ group _ MEMBERs table in a mysql database in each node is changed into a PRIMARY field; if the change indicates that the main database is switched, executing step 5; if not, it indicates that the main database is not switched, and does not execute step 5;
and 5: the detection module detects whether a read _ only parameter in a mysql database in each node is closed; if the data is closed, the new master database can be opened, which indicates that the new master database plays back all the data; if not, opening a new main database after the read _ only parameter is closed;
since the master database and the slave database may have a phenomenon that network communication is interrupted at any time, after the configuration of steps 1 to 3 is completed, step 4 needs to be periodically performed; for example: setting a timing module, and executing the step 4 once every ten seconds or four seconds; of course, the time interval for periodically performing step 4 may be performed according to specific situations, and the above example is not a limitation to the present invention; when it is found that the master database is switched by periodically performing step 4, step 5 is performed as described in step 4.
When the master database is switched, the original master database becomes the slave database, and any slave database in the plurality of slave databases is switched to be the new master database. At this time, the domain name cannot necessarily correspond to a new main database; therefore, the method also comprises the step 6: the configuration module modifies the current IP address to enable the current IP address to correspond to the domain name.
And 7: and automatically reconnecting the application program, and relocating to a new IP address through the domain name to complete the reconnection of the database.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.
Furthermore, it should be understood that although the present description refers to embodiments, not every embodiment may contain only a single embodiment, and such description is for clarity only, and those skilled in the art should integrate the description, and the embodiments may be combined as appropriate to form other embodiments understood by those skilled in the art.

Claims (7)

1. The application failover system based on the mysql MGR is characterized by comprising a configuration module and a detection module;
the configuration module is used for configuring mysql MGR clusters of a plurality of nodes, setting the MGR clusters as a single main mode, and defining any node as a main node;
the configuration module allocates a domain name to the mysql MGR cluster, and an effective node of the domain name is the main node;
the configuration module is used for modifying the connection address of the application program into a domain name;
the detection module is used for detecting whether a MEMBER _ ROLE field in a replay _ group _ MEMBERs table in a mysql database in each node is changed into a PRIMARY field;
the detection module is used for detecting whether a read _ only parameter in a mysql database in each node is closed or not;
the detection module judges whether the main database is switched or not based on whether the MEMBER _ ROLE field is changed into the PRIMARY field or not; judging whether the new main database plays back all data or not based on whether the read _ only parameter is closed or not;
if the MEMBER _ ROLE field is changed into a PRIMARY word, the main database is indicated to be switched; if the read _ only parameter has been closed, it indicates that the new master database has played back all data.
2. The system of claim 1, wherein the configuration module is configured to modify the current IP address such that the current IP address corresponds to the domain name.
3. The mysql MGR-based application failover system of claim 2, wherein the application automatically reconnects to the new primary database by domain name relocation to a new IP address.
4. An application failover method based on mysql MGR is characterized by comprising the following steps:
step 1: the configuration module builds a mysql MGR cluster of a plurality of nodes, the single master mode is set, and any one node is defined as a master node;
step 2: the configuration module allocates a domain name to the mysql MGR cluster, and an effective node of the domain name is the main node;
and step 3: the configuration module modifies the connection address of the application program into a domain name;
and 4, step 4: the detection module detects whether a MEMBER _ ROLE field in a replay _ group _ MEMBERs table in a mysql database in each node is changed into a PRIMARY field; if the change indicates that the main database is switched, executing step 5; if not, it indicates that the main database is not switched, and does not execute step 5;
and 5: the detection module detects whether a read _ only parameter in a mysql database in each node is closed; if the data is closed, the new master database can be opened, which indicates that the new master database plays back all the data; if not, the new main database is opened after the read _ only parameter is closed.
5. The mysql MGR-based application failover method of claim 4, wherein step 4 is performed periodically.
6. The application failover method of claim 5 further comprising step 6, the configuration module modifying the current IP address to make the current IP address and the domain name correspond to each other.
7. The mysql MGR-based application failover method of claim 6, further comprising step 7 of automatically reconnecting the application program, and completing the reconnected database by relocating the domain name to a new IP address.
CN202110732953.7A 2021-06-30 2021-06-30 Application fault transfer system and method based on mysql MGR Pending CN113190374A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110732953.7A CN113190374A (en) 2021-06-30 2021-06-30 Application fault transfer system and method based on mysql MGR

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110732953.7A CN113190374A (en) 2021-06-30 2021-06-30 Application fault transfer system and method based on mysql MGR

Publications (1)

Publication Number Publication Date
CN113190374A true CN113190374A (en) 2021-07-30

Family

ID=76976758

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110732953.7A Pending CN113190374A (en) 2021-06-30 2021-06-30 Application fault transfer system and method based on mysql MGR

Country Status (1)

Country Link
CN (1) CN113190374A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1533115A (en) * 2003-02-14 2004-09-29 ���ǵ�����ʽ���� Method and device for supporting error reason of simple network management protocol
US20070168692A1 (en) * 2005-11-30 2007-07-19 Microsoft Corporation Remote location failover server application
CN101482847A (en) * 2009-01-19 2009-07-15 北京邮电大学 Detection method based on safety bug defect mode
US20180300205A1 (en) * 2017-04-18 2018-10-18 Netapp, Inc. Systems and methods for backup and restore of master-less distributed database clusters
CN108959604A (en) * 2018-07-13 2018-12-07 浙江彩虹鱼科技有限公司 Safeguard the method, apparatus and computer readable storage medium of data-base cluster
CN112437166A (en) * 2020-10-30 2021-03-02 四川新网银行股份有限公司 Automatic switching method for MySQL database domain names

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1533115A (en) * 2003-02-14 2004-09-29 ���ǵ�����ʽ���� Method and device for supporting error reason of simple network management protocol
US20070168692A1 (en) * 2005-11-30 2007-07-19 Microsoft Corporation Remote location failover server application
CN101482847A (en) * 2009-01-19 2009-07-15 北京邮电大学 Detection method based on safety bug defect mode
US20180300205A1 (en) * 2017-04-18 2018-10-18 Netapp, Inc. Systems and methods for backup and restore of master-less distributed database clusters
CN108959604A (en) * 2018-07-13 2018-12-07 浙江彩虹鱼科技有限公司 Safeguard the method, apparatus and computer readable storage medium of data-base cluster
CN112437166A (en) * 2020-10-30 2021-03-02 四川新网银行股份有限公司 Automatic switching method for MySQL database domain names

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
1024程序员天空: "mysql8 参考手册--多主模式和单主模式", 《HTTPS://WWW.1024SKY.CN/BLOG/ARTICLE/1451》 *
MYSQL: "MySQL高可用之MGR(单主模式&多主模式)--MySQL 8.0.16+ MGR 基于同一个主机搭建", 《HTTP://BLOG.ITPUB.NET/26736162/VIEWSPACE-2675139/》 *

Similar Documents

Publication Publication Date Title
US11010358B2 (en) Data migration method and system
CN110798499B (en) Distributed service coordination system and method
US20120257603A1 (en) Network Access Point Management
CN104503965A (en) High-elasticity high availability and load balancing realization method of PostgreSQL (Structured Query Language)
CN112003961A (en) Resource exposure method, system, equipment and medium in kubernets
CN102843264A (en) Control method of double hosts in high-speed serial bus network
CN103810174B (en) Database switching method and database switching system
CN104090992A (en) Method for high-availability configuration between conversion nodes in cluster storage system
CN105450717A (en) Method and device for processing brain split in cluster
CN110196859A (en) Data base read-write based on JDBC distributor separates cluster real-time consistency method
CN113220235B (en) Read-write request processing method, device, equipment and storage medium
CN113190374A (en) Application fault transfer system and method based on mysql MGR
CN108228812A (en) Adaptive host node switching method and device
CN105323271B (en) Cloud computing system and processing method and device thereof
CN102291313B (en) Method, device and equipment for finding virtual router redundancy protocol (VRRP) network topology
CN108595485A (en) A kind of data-updating method and system at Double Data center
CN111338767B (en) PostgreSQL master-slave database automatic switching system and method
CN107566475B (en) Session failover method and device
CN111176904B (en) Method, system, equipment and medium for data backup under private cloud architecture
WO2021093079A1 (en) Service data processing method and system
WO2016154860A1 (en) Method, apparatus and system for establishing interface between vnfms
CN109088937B (en) Cluster authorization method and device based on unified management
CN104052799B (en) A kind of method that High Availabitity storage is realized using resource ring
CN105511808A (en) Data operation method, system and related device
CN109218386A (en) A kind of high availability method managing Hadoop NameSpace

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210730

RJ01 Rejection of invention patent application after publication