Database high availability method and device

By automatically monitoring and switching the main database node, the problem of low efficiency of manual restart management process in the existing technology is solved, efficient failover and monitoring of the database is realized, and the high availability of the database is improved.

CN112000745BActive Publication Date: 2024-10-25CHINA CONSTRUCTION BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010916216.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-03
Publication Date
2024-10-25
Estimated Expiration
2040-09-03

AI Technical Summary

Technical Problem

In the existing database high-availability technology, after the master database node fails over, the management process of the slave database node needs to be manually restarted, which is inefficient and cannot efficiently perform failover.

Method used

By monitoring the working status of the main database node, the switch operation is automatically performed to the standby main database node, and after the switch is successful, the management process of the slave database node is restarted, and the status of the standby main database node is monitored to achieve automated failover.

Benefits of technology

The failover of the main database node can be automatically completed without manual intervention, which improves the efficiency of failover and ensures high availability of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112000745B_ABST
    Figure CN112000745B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for high availability of a database, wherein the method comprises: in the case of identifying that the current node is a first slave library node with a management software package installed, monitoring whether the working state of the original master library node is normal; if the working state of the original master library node is abnormal, executing a switching operation from the original master library node to a standby master library node; monitoring whether the standby master library node is successfully switched; if the standby master library node is successfully switched, restarting the management process in the first slave library node so that the management process monitors whether the working state of the standby master library node is normal. In the present application, the first slave library node can automatically restart the management process in the first slave library node after the standby master library node is successfully switched, without the need for maintenance personnel to manually restart the management process, so that the fault switching of the master library node can be efficiently performed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a method and device for high availability of a database. Background Art

[0002] A database (for example, MySQL) can deploy high availability technology based on MHA (Master High Availability) on a master-multiple-slave cluster. A master-multiple-slave cluster can include a master-two-slave cluster (one master node and two slave nodes), a master-three-slave cluster (one master node and three slave nodes), etc.

[0003] The MHA software consists of a management software package (also known as the MHA Manager software package) and a node software package (MHA Node software package). The method of deploying the management software package separately on a slave node in each master-slave cluster is called MHA independent management.

[0004] In the MHA independent management mode, a management process will run after the management software package is started. The management process will periodically detect whether the master database node in the one-master-multiple-slave cluster has a fault, and switch the master database node after a fault occurs to ensure high availability of the database.

[0005] In the related art, when the original master node in a one-master-multiple-slave cluster fails and the master node is switched, the management process in the slave node will automatically terminate. At this time, maintenance personnel need to manually intervene to restart the management process in the slave node so that the management process can continue to monitor the switched master node to ensure the high availability of the database.

[0006] However, in the related art, the management process in the slave library node needs to be manually restarted to restore the management process. Since the manual operation efficiency is low, the related art cannot efficiently perform the fault switching of the master library node. Summary of the invention

[0007] In view of this, the present application provides a database high availability method and device, which can automatically perform failover of master database nodes to improve failover efficiency.

[0008] In order to achieve the above object, the present invention provides the following technical features:

[0009] A database high availability method, comprising:

[0010] In the case of identifying that the current node is the first slave library node with the management software package installed, monitoring whether the working status of the original master library node is normal;

[0011] If the working state of the original master database node is abnormal, a switching operation is performed from the original master database node to the standby master database node;

[0012] Monitor whether the standby master library node is switched successfully;

[0013] If the standby master library node is switched successfully, the management process in the first slave library node is restarted so that the management process can monitor whether the working status of the standby master library node is normal.

[0014] Optionally, monitoring whether the standby master library node is successfully switched includes:

[0015] Monitoring whether the management process in the first slave library node is in a running state;

[0016] If it is in the running state, continue to monitor whether the management process in the first slave library node is in the running state until the management process in the first slave library node is in the stopped state;

[0017] Monitor whether the replication relationship between the standby master database node and other slave database nodes has been established;

[0018] If it is not completed, continue to monitor whether the replication relationship between the standby master library node and other slave library nodes is completed until the replication relationship between the standby master library node and other slave library nodes is completed.

[0019] Optionally, also include:

[0020] After the standby master database node is successfully switched, monitor whether the database instance of the original master database node is normal;

[0021] If the database instance of the original master database node is abnormal, continue to monitor whether the database instance of the original master database node is normal until the database instance of the original master database node returns to normal;

[0022] Execute a switching operation from the standby master database node to the original master database node;

[0023] Monitor whether the original master database node is switched successfully;

[0024] If the original master library node is switched successfully, the management process in the first slave library node is restarted so that the management process can monitor whether the working status of the original master library node is normal.

[0025] Optionally, monitoring whether the working status of the original master library node is abnormal includes:

[0026] Remotely log in to the original master database node;

[0027] Monitor whether the database process in the original master database node exists;

[0028] If it exists, it means that the working status of the original master database node is normal;

[0029] If it does not exist, it means that the working status of the original master library node is abnormal.

[0030] Optionally, also include:

[0031] In the case of identifying that the current node is a second slave library node on which the management software package is not installed, monitoring whether the first slave library node fails;

[0032] If the first slave library node fails, the management process of the second slave library node is started.

[0033] Optionally, monitoring whether the first slave library node fails includes:

[0034] Monitor whether the status of the server where the first slave library node is located is normal;

[0035] If the status of the server where the first slave library node is located is abnormal, it is determined that the first slave library node is faulty;

[0036] If the status of the server where the first slave library node is located is normal, monitor whether the database instance of the first slave library node is normal;

[0037] If the database instance of the first slave library node is abnormal, it is determined that the first slave library node fails;

[0038] If the database instance of the first slave node is normal, monitor whether the management process in the first slave node exists;

[0039] If the management process in the first slave library node does not exist, it is determined that the first slave library node has a fault.

[0040] Optionally, also include:

[0041] After starting the management process of the second slave library node, monitoring whether the first slave library node returns to normal;

[0042] Stop the management process of the second warehouse node, and start the management process of the first slave library node.

[0043] Optionally, monitoring whether the first slave node recovers to normal includes:

[0044] Monitor whether the database instance of the first slave node has returned to normal;

[0045] If the database instance of the first slave library node recovers to normal, monitor whether the first slave library node joins the cluster where the second slave library node is located;

[0046] If the first slave library node joins the cluster where the second slave library node is located, it is determined that the first slave library node has recovered to normal.

[0047] A database high availability device, comprising:

[0048] A first monitoring unit is used to monitor whether the working state of the original master library node is normal when the current node is identified as the first slave library node with the management software package installed;

[0049] A switching unit, configured to execute a switching operation from the original main library node to a backup main library node if the working state of the original main library node is abnormal;

[0050] A second monitoring unit is used to monitor whether the standby master library node is switched successfully;

[0051] The first restart unit is used to restart the management process in the first slave library node if the standby master library node is switched successfully, so that the management process can monitor whether the working status of the standby master library node is normal.

[0052] Optionally, also include:

[0053] A third monitoring unit is used to monitor whether the first slave library node fails when the current node is identified as a second slave library node on which the management software package is not installed;

[0054] The second restart unit is used to start the management process of the second slave library node if the first slave library node fails.

[0055] Through the above technical means, the following beneficial effects can be achieved:

[0056] In the present application, the first slave library node can execute a switching operation from the original master library node to the backup master library node when the working status of the original master library node is abnormal, and restart the management process in the first slave library node after the backup master library node is successfully switched, so that the management process can monitor whether the working status of the backup master library node is normal.

[0057] In the present application, the first slave library node can automatically restart the management process in the first slave library node after the standby master library node is successfully switched, without the need for maintenance personnel to manually restart the management process, so the master library node fault switching can be performed efficiently. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0059] Figure 1 A flowchart of a first embodiment of a method for high availability of a database provided by the present invention according to an embodiment of the present application;

[0060] Figure 2 A flowchart of a second embodiment of a method for high availability of a database provided by the present invention is disclosed in an embodiment of the present application;

[0061] Figure 3 A flowchart of a method for providing high availability of a database according to an embodiment of the present application;

[0062] Figure 4 The present invention is a schematic diagram of the structure of a database high-availability device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0064] The present invention provides a first embodiment of a database high availability method, which is applied to a slave database node in a one-master-multiple-slave cluster. This embodiment can efficiently implement fault switching when the master database node fails.

[0065] See also Figure 1 , the database high availability method includes the following steps:

[0066] Step S101: when the current node is identified as the first slave library node with the management software package installed, monitor whether the working status of the original master library node is normal.

[0067] There are two types of slave nodes: a first slave node with a management software package installed and a second slave node without a management software package installed. By identifying the configuration file of the current node, it can be known whether the current node is the first slave node or the second slave node.

[0068] When the current node is identified as the first slave node with the management software package installed, the first slave node runs the management software package, that is, starts the management process, which monitors whether the working status of the original master node in the one-master-multiple-slave cluster is normal.

[0069] In this embodiment, the management process can remotely log in to the original main library node to monitor whether the database process in the original main library node exists; if it exists, it means that the working status of the original main library node is normal; if it does not exist, it means that the working status of the original main library node is abnormal.

[0070] Step S102: If the working status of the original master library node is abnormal, a switching operation is performed from the original master library node to the backup master library node.

[0071] If the original master node is not working properly, a switch operation is required to ensure high availability of the database. Select a second slave node with the latest data from multiple second slave nodes in the master-slave cluster as the backup master node. Then, perform a switch operation from the original master node to the backup master node.

[0072] Optionally, the data of each slave node can be supplemented according to the log to ensure the data consistency of each slave node as much as possible.

[0073] The switching operation from the original master node to the standby master node may include: establishing a replication relationship between the standby master node and other slave nodes, that is, directing the replication sources of all other slave nodes to the standby master node. In addition, the management process in the first slave node needs to be stopped.

[0074] Step S103: monitor whether the standby master library node is switched successfully.

[0075] This step may include two parallel aspects until both aspects are completed.

[0076] The first aspect: monitor whether the management process in the first slave library node is in a running state; if it is in a running state, continue to monitor whether the management process in the first slave library node is in a running state until the management process in the first slave library node is in a stopped state.

[0077] The second aspect: monitor whether the replication relationship between the standby master library node and other slave library nodes has been established; if not, continue to monitor whether the replication relationship between the standby master library node and other slave library nodes has been established until the replication relationship between the standby master library node and other slave library nodes has been established.

[0078] Step S104: If the standby master library node is switched successfully, restart the management process in the first slave library node so that the management process can monitor whether the working status of the standby master library node is normal.

[0079] Since it has been switched to the standby master node, in order to make the standby master node effective, it is necessary to restart the management process in the first slave node so that the management process can point to the standby master node and monitor whether the working status of the standby master node is normal.

[0080] Through the above technical means, the following beneficial effects can be achieved:

[0081] In the present application, the first slave library node can execute a switching operation from the original master library node to the backup master library node when the working status of the original master library node is abnormal, and restart the management process in the first slave library node after the backup master library node is successfully switched, so that the management process can monitor whether the working status of the backup master library node is normal.

[0082] In the present application, the first slave library node can automatically restart the management process in the first slave library node after the standby master library node is successfully switched, without the need for maintenance personnel to manually restart the management process, so the master library node fault switching can be performed efficiently.

[0083] See also Figure 2 The present invention provides a second embodiment of a database high availability method, which is applied to a slave node in a one-master-multiple-slave cluster. This embodiment can switch to the original master node after the original master node recovers.

[0084] Embodiment 2 performs amplification based on Embodiment 1, and further includes the following steps after step S104:

[0085] Step S201: After the standby master database node is successfully switched, monitor whether the database instance of the original master database node is normal.

[0086] After the original master database node fails, maintenance personnel will repair it. Therefore, after the standby node is successfully switched, the management process can monitor whether the database instance of the original master database node is normal.

[0087] The management process can remotely log in to the original main library node to monitor whether the database instance in the original main library node is normal; if normal, it means that the database instance of the original main library node is normal; if abnormal, it means that the database instance of the original main library node is abnormal.

[0088] Step S202: If the database instance of the original master database node is abnormal, continue to monitor whether the database instance of the original master database node is normal until the database instance of the original master database node returns to normal.

[0089] After the database instance in the original master database node returns to normal, the original master database node is marked as restored to normal. Since the performance of the original master database node is better than that of the standby master database node (slave database node), the original master database node can continue to be used as the master database node after it returns to normal.

[0090] Step S203: Identify the standby master library node and join the one-master-multiple-slave cluster.

[0091] After the failure of the original master library node is repaired, since the original master library node has been separated from the one-master-multiple-slave cluster, this embodiment identifies the slave library node used as the master library in the one-master-multiple-slave cluster, that is, the backup master library node, and then automatically establishes a replication relationship from the original master library node to the backup master library node, so that the original master library node joins the one-master-multiple-slave cluster.

[0092] Step S204: executing a switching operation from the backup master library node to the original master library node.

[0093] Executing the switching operation from the standby master node to the original master node may include: establishing a replication relationship between the original master node and other slave nodes, that is, pointing the replication sources of all other slave nodes to the original master node. In addition, the management process in the first slave node needs to be stopped.

[0094] Step S205: monitor whether the original master library node is switched successfully.

[0095] This step may include two parallel aspects until both aspects are completed.

[0096] The first aspect: monitor whether the management process in the first slave library node is in a running state; if it is in a running state, continue to monitor whether the management process in the first slave library node is in a running state until the management process in the first slave library node is in a stopped state.

[0097] The second aspect: monitor whether the replication relationship between the original master library node and other slave library nodes has been established; if not, continue to monitor whether the replication relationship between the original master library node and other slave library nodes has been established until the replication relationship between the original master library node and other slave library nodes has been established.

[0098] Step S206: If the original master library node is switched successfully, restart the management process in the first slave library node so that the management process can monitor whether the working status of the original master library node is normal.

[0099] Since the node has been switched to the original master library node, in order to make the original master library node effective, it is necessary to restart the management process in the first slave library node so that the management process can point to the original master library node and monitor whether the working status of the original master library node is normal.

[0100] Through the above technical means, the following beneficial effects can be achieved:

[0101] After the failure of the original master library node is repaired, since the original master library node has been separated from the one-master-multiple-slave cluster, this embodiment identifies the slave library node used as the master library in the one-master-multiple-slave cluster, that is, the backup master library node, and then automatically establishes a replication relationship from the original master library node to the backup master library node, so that the original master library node joins the one-master-multiple-slave cluster.

[0102] Furthermore, since the original master library node has better performance, this embodiment switches the standby master library node to the original master library node after the original master library node is restored, so as to continue to use the original master library node as the master library node.

[0103] The present invention provides a third embodiment of a database high availability method, which is applied to a slave node in a one-master-multiple-slave cluster. This embodiment can efficiently implement fault switching when a slave node with a management software package installed fails.

[0104] See also Figure 3 , the database high availability method includes the following steps:

[0105] Step S301: when the current node is identified as a second slave library node without the management software package installed, monitoring whether the first slave library node fails.

[0106] There are two types of slave nodes: a first slave node with a management software package installed and a second slave node without a management software package installed. By identifying the configuration file of the current node, it can be known whether the current node is the first slave node or the second slave node.

[0107] When the current node is identified as a second slave node without the management software package installed, the second slave node monitors whether the first slave node in the one-master-multiple-slave cluster is faulty. Because the master node cannot be monitored after the first slave node fails, the second slave node is used to monitor the first slave node to ensure high availability of the database.

[0108] S1: Monitor whether the status of the server where the first slave node is located is normal;

[0109] S2: If the status of the server where the first slave library node is located is abnormal, it is determined that the first slave library node is faulty.

[0110] S3: If the status of the server where the first slave library node is located is normal, monitor whether the database instance of the first slave library node is normal.

[0111] S4: If the database instance of the first slave library node is abnormal, it is determined that the first slave library node fails.

[0112] S5: If the database instance of the first slave node is normal, monitor whether the management process in the first slave node exists.

[0113] S6: If the management process in the first slave library node does not exist, it is determined that the first slave library node fails.

[0114] S7: If the management process in the first slave library node exists, it is determined that the first slave library node has not failed.

[0115] Step S302: If the first slave library node fails, start the management process of the second slave library node.

[0116] In this embodiment, a management software package is also installed in the second slave library node. After the first slave library node fails, the management process in the second slave library node can be started to continue monitoring the master library node, thereby ensuring high availability of the database.

[0117] Step S303: After starting the management process of the second slave library node, monitor whether the first slave library node returns to normal.

[0118] The management process can monitor whether the database instance of the first slave library node has returned to normal; if the database instance of the first slave library node has returned to normal, it can monitor whether the first slave library node has joined the cluster where the second slave library node is located; if the first slave library node has joined the cluster where the second slave library node is located, it can be determined that the first slave library node has returned to normal.

[0119] Step S304: stop the management process of the second warehouse node, and start the management process of the first slave warehouse node.

[0120] If the management process in the second slave library node returns to normal, the management process in the second slave library node can be stopped, and the management process in the first slave library node can be started, thereby returning to the original state.

[0121] The technical means provided in the above-mentioned embodiment 3 can achieve the following beneficial effects:

[0122] In this embodiment, after a failure occurs in the first slave library node, the node can be automatically switched to the second slave library node, and a management process is started in the second slave library node to monitor the master library node and ensure high availability of the database.

[0123] See also Figure 4 , the present application provides a database high availability device, comprising:

[0124] The identification unit 40 is used to identify whether the current node is a first slave library node with the management software package installed, or a second slave library node with the management software package not installed.

[0125] The first monitoring unit 41 is used to monitor whether the working state of the original master library node is normal when the current node is identified as the first slave library node with the management software package installed;

[0126] The switching unit 42 is used to execute a switching operation from the original main library node to the backup main library node if the working state of the original main library node is abnormal;

[0127] The second monitoring unit 43 is used to monitor whether the standby master library node is switched successfully;

[0128] The first restart unit 44 is used to restart the management process in the first slave library node if the standby master library node is switched successfully, so that the management process can monitor whether the working status of the standby master library node is normal.

[0129] Wherein, monitoring whether the standby master library node is switched successfully includes:

[0130] Monitoring whether the management process in the first slave library node is in a running state;

[0131] If it is in the running state, continue to monitor whether the management process in the first slave library node is in the running state until the management process in the first slave library node is in the stopped state;

[0132] Monitor whether the replication relationship between the standby master database node and other slave database nodes has been established;

[0133] If it is not completed, continue to monitor whether the replication relationship between the standby master library node and other slave library nodes is completed until the replication relationship between the standby master library node and other slave library nodes is completed.

[0134] The first monitoring unit 41 is further used to monitor whether the database instance of the original main library node is normal after the standby main library node is successfully switched; if the database instance of the original main library node is abnormal, continue to monitor whether the database instance of the original main library node is normal until the database instance of the original main library node returns to normal;

[0135] The switching unit 42 is further used to perform a switching operation from the backup master library node to the original master library node;

[0136] The second monitoring unit 43 is also used to monitor whether the original master library node is successfully switched;

[0137] The first restart unit 44 is further configured to restart the management process in the first slave library node if the original master library node is switched successfully, so that the management process can monitor whether the working status of the original master library node is normal.

[0138] The monitoring of whether the working status of the original master database node is abnormal includes:

[0139] Remotely log in to the original master database node;

[0140] Monitor whether the database process in the original master database node exists;

[0141] If it exists, it means that the working status of the original master database node is normal;

[0142] If it does not exist, it means that the working status of the original master library node is abnormal.

[0143] The database high availability device also includes:

[0144] The third monitoring unit 45 is used to monitor whether the first slave library node fails when the current node is identified as a second slave library node without the management software package installed;

[0145] The second restart unit 46 is used to start the management process of the second slave library node if the first slave library node fails.

[0146] The monitoring of whether the first slave node fails includes:

[0147] Monitor whether the status of the server where the first slave library node is located is normal;

[0148] If the status of the server where the first slave library node is located is abnormal, it is determined that the first slave library node is faulty;

[0149] If the status of the server where the first slave library node is located is normal, monitor whether the database instance of the first slave library node is normal;

[0150] If the database instance of the first slave library node is abnormal, it is determined that the first slave library node fails;

[0151] If the database instance of the first slave node is normal, monitor whether the management process in the first slave node exists;

[0152] If the management process in the first slave library node does not exist, it is determined that the first slave library node has a fault.

[0153] Among them, the third monitoring unit 45 is also used to monitor whether the first slave library node returns to normal after starting the management process of the second slave library node; stop the management process of the second slave library node, and start the management process of the first slave library node.

[0154] The monitoring of whether the first slave node has recovered to normal includes:

[0155] Monitor whether the database instance of the first slave node has returned to normal;

[0156] If the database instance of the first slave library node recovers to normal, monitor whether the first slave library node joins the cluster where the second slave library node is located;

[0157] If the first slave library node joins the cluster where the second slave library node is located, it is determined that the first slave library node has recovered to normal.

[0158] Through the above technical means, the following beneficial effects can be achieved:

[0159] After the failure of the original master library node is repaired, since the original master library node has been separated from the one-master-multiple-slave cluster, this embodiment identifies the slave library node used as the master library in the one-master-multiple-slave cluster, that is, the backup master library node, and then automatically establishes a replication relationship from the original master library node to the backup master library node, so that the original master library node joins the one-master-multiple-slave cluster.

[0160] Furthermore, since the original master library node has better performance, this embodiment switches the standby master library node to the original master library node after the original master library node is restored, so as to continue to use the original master library node as the master library node.

[0161] In this embodiment, after a failure occurs in the first slave library node, the node can be automatically switched to the second slave library node, and a management process is started in the second slave library node to monitor the master library node and ensure high availability of the database.

[0162] If the functions described in the method of this embodiment are implemented in the form of software functional units and sold or used as independent products, they can be stored in a storage medium readable by a computing device. Based on this understanding, the part of the embodiment of the present application that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computing device (which can be a personal computer, server, mobile computing device or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0163] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0164] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A database high availability method, characterized in that: include: In the case of identifying that the current node is the first slave library node with the management software package installed, monitoring whether the working status of the original master library node is normal; If the working state of the original master database node is abnormal, a switching operation is performed from the original master database node to the standby master database node; Monitor whether the standby master library node is switched successfully; If the standby master library node is switched successfully, restarting the management process in the first slave library node so that the management process can monitor whether the working status of the standby master library node is normal; Also includes: In the case of identifying that the current node is a second slave library node on which the management software package is installed, the second slave library node monitors whether the first slave library node fails; If the first slave library node fails, the management process of the second slave library node is started to monitor the master library node; After starting the management process of the second slave library node, monitoring whether the database instance of the first slave library node returns to normal; If the database instance of the first slave library node recovers to normal, monitor whether the first slave library node joins the cluster where the second slave library node is located; If the first slave node joins the cluster where the second slave node is located, it is determined that the first slave node has recovered to normal; Stop the management process of the second slave library node and start the management process of the first slave library node; The monitoring of whether the first slave node fails comprises: Monitor whether the status of the server where the first slave library node is located is normal; If the status of the server where the first slave library node is located is abnormal, it is determined that the first slave library node is faulty; If the status of the server where the first slave library node is located is normal, monitor whether the database instance of the first slave library node is normal; If the database instance of the first slave library node is abnormal, it is determined that the first slave library node fails; If the database instance of the first slave node is normal, monitor whether the management process in the first slave node exists; If the management process in the first slave library node does not exist, it is determined that the first slave library node has a fault.

2. The method according to claim 1, characterized in that Monitoring whether the standby master library node is switched successfully includes: Monitoring whether the management process in the first slave library node is in a running state; If it is in the running state, continue to monitor whether the management process in the first slave library node is in the running state until the management process in the first slave library node is in the stopped state; Monitor whether the replication relationship between the standby master database node and other slave database nodes has been established; If it is not completed, continue to monitor whether the replication relationship between the standby master library node and other slave library nodes is completed until the replication relationship between the standby master library node and other slave library nodes is completed.

3. The method according to claim 1, characterized in that Also includes: After the standby master database node is successfully switched, monitor whether the database instance of the original master database node is normal; If the database instance of the original master database node is abnormal, continue to monitor whether the database instance of the original master database node is normal until the database instance of the original master database node returns to normal; Execute a switching operation from the standby master database node to the original master database node; Monitor whether the original master database node is successfully switched; If the original master library node is switched successfully, the management process in the first slave library node is restarted so that the management process can monitor whether the working status of the original master library node is normal.

4. The method according to claim 1 or 3, characterized in that The monitoring of whether the working status of the original master database node is abnormal includes: Remotely log in to the original master database node; Monitor whether the database process in the original master database node exists; If it exists, it means that the working status of the original master database node is normal; If it does not exist, it means that the working status of the original master library node is abnormal.

5. A database high availability device, characterized in that: include: A first monitoring unit is used to monitor whether the working state of the original master library node is normal when the current node is identified as the first slave library node with the management software package installed; A switching unit, configured to execute a switching operation from the original main library node to a backup main library node if the working state of the original main library node is abnormal; A second monitoring unit is used to monitor whether the standby master library node is switched successfully; A first restart unit, configured to restart the management process in the first slave library node if the standby master library node is switched successfully, so that the management process can monitor whether the working state of the standby master library node is normal; The device is also used for: In the case of identifying that the current node is a second slave library node on which the management software package is installed, the second slave library node monitors whether the first slave library node fails; If the first slave library node fails, the management process of the second slave library node is started to monitor the master library node; After starting the management process of the second slave library node, monitoring whether the database instance of the first slave library node returns to normal; If the database instance of the first slave library node recovers to normal, monitor whether the first slave library node joins the cluster where the second slave library node is located; If the first slave node joins the cluster where the second slave node is located, it is determined that the first slave node has recovered to normal; Stop the management process of the second slave library node and start the management process of the first slave library node; The monitoring of whether the first slave node fails comprises: Monitor whether the status of the server where the first slave library node is located is normal; If the status of the server where the first slave library node is located is abnormal, it is determined that the first slave library node is faulty; If the status of the server where the first slave library node is located is normal, monitor whether the database instance of the first slave library node is normal; If the database instance of the first slave library node is abnormal, it is determined that the first slave library node fails; If the database instance of the first slave node is normal, monitor whether the management process in the first slave node exists; If the management process in the first slave library node does not exist, it is determined that the first slave library node has a fault.