Database cluster management method, device and system
Through multi-path detection and the collaborative work of the leader management service instance and the candidate management service instance, the problem of a single fault detection path for the database cluster management service is solved, the reliability and security of the database cluster are improved, and high availability is ensured.
Patent Information
- Application Number
- CN202211163357.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-09-23
AI Technical Summary
The existing database cluster management service has a single fault detection path for database instances, which is prone to false alarms, resulting in the failure to effectively guarantee the reliability and security of the database cluster.
Use multi-path detection method to detect the upstream database, downstream database, network and switch in the database cluster, and combine the collaborative work of the leadership management service instance and the candidate management service instance to ensure the accuracy of fault detection and respond when a fault occurs. bug fixes.
Through multi-path detection and the collaborative work of leadership management service instances and candidate management service instances, the reliability and security of database cluster monitoring and management are significantly improved, preventing misjudgment problems caused by a single detection path, and ensuring the high performance of the database cluster. Availability.
Smart Images

Figure CN115514625B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of database management, and in particular to a database cluster management method, device and system. Background Art
[0002] In the era of big data, database clusters have become a necessary infrastructure for data storage. Internet companies use database clusters to store massive amounts of corporate data. A database cluster consists of a master database that provides external read and write services and several slave databases that only provide external read services. Each slave database continuously reads and updates data from the master database to ensure data consistency between the slave database and the master database.
[0003] In order to make the database cluster operate better, the relevant technology will be equipped with a database cluster management service to monitor and manage the database cluster. The database cluster management service ensures the normal operation of the database cluster by detecting faults in the database instance. However, since the database cluster management service has a single fault detection path for the database instance, it is easy to generate false alarms, resulting in the reliability and security of the database cluster cannot be effectively guaranteed. Summary of the invention
[0004] In order to solve or partially solve the problems existing in the related art, the present application provides a database cluster management method, device and system, which can ensure the reliability and security of the database cluster.
[0005] A first aspect of the present application provides a database cluster management method, comprising:
[0006] Using the leadership management service instance to detect the upstream database and the downstream database corresponding to the database instance in the database cluster;
[0007] When the detection result meets the first preset condition, determining that the upstream database corresponding to the database instance in the database cluster fails; or,
[0008] When the detection result meets the second preset condition, determining that a network corresponding to the database instance in the database cluster fails or a switch port fails; or,
[0009] When the detection result meets the third preset condition, it is determined that a switch corresponding to the database instance in the database cluster fails.
[0010] Preferably, before using the leadership management service instance to detect the upstream database and the downstream database corresponding to the database instance in the database cluster, the method further includes:
[0011] Detecting the management service instance of the configured database cluster, wherein the management service instance includes a leading management service instance and a candidate management service instance, wherein the leading management service instance is used to monitor and manage the database cluster;
[0012] When it is detected that the leading management service instance fails, the candidate management service instance is selected to replace the leading management service instance.
[0013] Preferably, the detecting of the upstream database and the downstream database corresponding to the database instance in the database cluster by using the leadership management service instance includes:
[0014] The leadership management service instance is used to detect the upstream database corresponding to the database instance in the database cluster, and after detecting the abnormality, the downstream database corresponding to the database instance is detected.
[0015] Preferably, the first preset condition includes: when the connection between the upstream database corresponding to the leadership management service instance and the database instance is abnormal, the connection between the downstream database corresponding to the leadership management service instance and the database instance is normal, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance is abnormal.
[0016] Preferably, the second preset condition includes: when the connection between the upstream database corresponding to the leadership management service instance and the database instance is abnormal, the connection between the downstream database corresponding to the leadership management service instance and the database instance is normal, and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal.
[0017] Preferably, the third preset condition includes: when the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leadership management service instance and each downstream database corresponding to the database instance is abnormal.
[0018] Preferably, the method further includes: performing corresponding fault repair on the database instance in the database cluster according to the fault type;
[0019] When it is determined that the upstream database corresponding to the database instance in the database cluster fails, the method further includes: selecting the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance and updating the replication topology relationship of the database cluster to perform fault repair;
[0020] When it is determined that the network corresponding to the database instance in the database cluster fails or the switch port fails, the method further includes: repairing the network or the switch port corresponding to the database instance;
[0021] When it is determined that the switch corresponding to the database instance in the database cluster fails, the method further includes: repairing the switch corresponding to the database instance.
[0022] A second aspect of the present application provides a database cluster management device, including:
[0023] A detection module detects upstream databases and downstream databases corresponding to database instances in a database cluster using the leadership management service instance;
[0024] When the detection result meets the first preset condition, determining that the upstream database corresponding to the database instance in the database cluster fails; or,
[0025] When the detection result meets the second preset condition, determining that a network corresponding to the database instance in the database cluster fails or a switch port fails; or,
[0026] When the detection result meets the third preset condition, it is determined that a switch corresponding to the database instance in the database cluster fails.
[0027] Preferably, it also includes:
[0028] A detection module, used to detect the management service instance of the configured database cluster, wherein the management service instance includes a leading management service instance and a candidate management service instance, wherein the leading management service instance is used to monitor and manage the database cluster;
[0029] The election module is used to select the candidate management service instance to replace the leading management service instance when it is detected that the leading management service instance fails.
[0030] A third aspect of the present application provides a database cluster management system, including: a database cluster management server, a database cluster;
[0031] The database cluster management service end is used to use the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster; when the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster has a fault; or, when the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault; or, when the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster has a fault.
[0032] A third aspect of the present application provides an electronic device, including:
[0033] Processor; and
[0034] A memory stores executable codes thereon, and when the executable codes are executed by the processor, the processor is enabled to execute the database cluster management method as described above.
[0035] A fourth aspect of the present application provides a computer-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor is caused to execute the database cluster management method as described above.
[0036] The technical solution provided by this application may have the following beneficial effects:
[0037] The technical solution of the present application includes: using the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster; when the detection result meets the first preset condition, determining that the upstream database corresponding to the database instance in the database cluster has a fault; or, when the detection result meets the second preset condition, determining that the network corresponding to the database instance in the database cluster has a fault or a switch port fault; or, when the detection result meets the third preset condition, determining that the switch corresponding to the database instance in the database cluster has a fault. The use of a multi-path detection method can well prevent the problem of misjudgment due to a single detection path, and greatly improve the reliability and security of database cluster monitoring and management.
[0038] Furthermore, the technical solution of the present application detects the management service instance of the configured database cluster, wherein the management service instance includes a leading management service instance and a candidate management service instance, wherein the leading management service instance is used to monitor and manage the database cluster; when a failure of the leading management service instance is detected, a candidate management service instance is selected to replace the leading management service instance. When a failure of the leading management service instance occurs in the present application, one of the candidate management service instances is selected as a new leading management service instance to monitor and manage the database cluster, thereby ensuring the high availability of the database cluster.
[0039] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The above and other objects, features and advantages of the present application will become more apparent through a more detailed description of exemplary embodiments of the present application in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the present application.
[0041] Figure 1 It is a flowchart of a database cluster management method shown in an embodiment of the present application;
[0042] Figure 2 is a flowchart of a database cluster management method shown in another embodiment of the present application;
[0043] Figure 3 is a flowchart of a database cluster management method shown in another embodiment of the present application;
[0044] Figure 4 is a flowchart of multipath detection shown in an embodiment of the present application;
[0045] Figure 5 It is a schematic diagram of the overall architecture structure of the database shown in the embodiment of the present application;
[0046] Figure 6 A schematic diagram of the structure of a database cluster management device shown in an embodiment of the present application;
[0047] Figure 7 A schematic diagram of the structure of a database cluster management device shown in another embodiment of the present application;
[0048] Figure 8 A schematic diagram of the structure of a database cluster management device shown in another embodiment of the present application;
[0049] Fig. 9 A schematic diagram of the structure of a database cluster management system shown in an embodiment of the present application;
[0050] Fig.10 A schematic diagram of the structure of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The preferred embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0052] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0053] It should be understood that although the terms "first", "second", "third", etc. may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0054] In the description of the present application, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0055] Unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0056] In the related art, since the database cluster management service has a single fault detection path for the database instance, it is easy to generate false alarms, resulting in the inability to effectively guarantee the reliability and security of the database cluster.
[0057] Therefore, in response to the above technical problems, the present application provides a database cluster management method, apparatus, device and storage medium, which can ensure the reliability and security of the database cluster.
[0058] The technical solution of the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0059] Figure 1 A schematic diagram of a process flow of a database cluster management method in an embodiment of the present application is shown.
[0060] See also Figure 1 , a database cluster management method, comprising the following steps:
[0061] Step S11: Use the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster.
[0062] The main functions of the leadership management service instance include: 1) Continuously explore the database cluster and obtain the basic information of all database instances in the database cluster, including but not limited to: database instance ID, IP / host name, port, log replication data, role, status (operating status, replication status, etc.), upstream database and downstream database corresponding to the current database instance, etc.; 2) Continuously detect faults in the database cluster.
[0063] Preferably, when using the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster, the method adopted is: using the leadership management service instance to detect the upstream database corresponding to the database instance in the database cluster, and then detecting the downstream database corresponding to the database instance after detecting the anomaly.
[0064] Upstream database (UpstreamDB): The source database of data replication, providing data to its downstream database instance. Downstream database (Downstream DB): The target database of data replication, obtaining data from its upstream database instance.
[0065] When the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster has a fault, wherein the first preset condition includes: when the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance is abnormal.
[0066] When the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault, wherein the second preset condition includes: when the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal.
[0067] When the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster has a fault, wherein the third preset condition includes: when the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and each downstream database corresponding to the database instance is abnormal.
[0068] In this way, the cause of the database cluster failure is determined based on the connection between the leadership management service instance and the upstream database corresponding to the database instance, the connection between the leadership management service instance and the downstream database corresponding to the database instance, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance. The use of a multi-path detection method can effectively prevent the problem of misjudgment due to a single detection path, and greatly improve the reliability and security of database cluster monitoring and management.
[0069] Figure 2 A schematic flow chart of a database cluster management method in another embodiment of the present application is shown.
[0070] See also Figure 2 , a database cluster management method, comprising the following steps:
[0071] Step S21 : detecting the management service instances of the configured database cluster, wherein the management service instances include leading management service instances and candidate management service instances, wherein the leading management service instance is used to monitor and manage the database cluster.
[0072] It should be noted that the database cluster high availability management service (DB HAM Service) is configured with at least two management service instances, one of which is configured as the leading management service instance, and the remaining management service instances are configured as candidate management service instances. A consistency protocol is used between the management service instances. The leading management service instance is responsible for monitoring and managing the database cluster, such as fault detection and fault repair of the database cluster. The remaining management service instances are "candidates" to replace the leading management service instance when the leading management service instance fails.
[0073] It should also be noted that in order to make monitoring and management more in line with the business perspective and data security, the network where the database cluster high availability management service is located will be separated from the network where the database cluster is located. For example, the database cluster high availability management service is deployed in the management extranet, and the database cluster is deployed in the data intranet. Of course, the database cluster high availability management service and the database cluster can also be deployed in the same network (i.e. management, business, and data are three-in-one).
[0074] It should also be noted that the consistency protocol ensures that at the same time, there is only one management service instance that can monitor and manage the database cluster. Commonly used consistency protocols include the Paxos protocol, the Raft protocol, etc. In this implementation, for the consistency protocol, only the leadership election part is required, and there is no mandatory requirement for data replication or data consistency of the management service instance. That is, for the leading management service instance and the candidate management service instance, if you want to maintain data consistency between the two, you can use the following two methods to achieve it:
[0075] 1) Data consistency is achieved by replicating data from the leading management service instance to the candidate management service instance, while the candidate management service instance does not automatically obtain instance data of the database cluster;
[0076] 2) The leadership management service instance and the candidate management service instance are independent of each other and automatically obtain instance data of the database cluster. The data of the leadership management service instance and the candidate management service instance may be inconsistent at the same time, but when the database cluster is stable, the final data of the leadership management service instance and the candidate management service instance are consistent.
[0077] Step S22: When a failure of the leading management service instance is detected, a candidate management service instance is selected to replace the leading management service instance.
[0078] It should be noted that real-time fault detection is performed on the leadership management service instance. If a failure occurs in the leadership management service instance (for example, a downtime problem occurs), one of the remaining candidate management service instances will be selected as a new leadership management service instance to monitor and manage the database cluster, so that the database cluster can provide services to the outside world and ensure the high availability of the database cluster.
[0079] Step S23: Use the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster.
[0080] The main functions of the leadership management service instance include: 1) Continuously explore the database cluster and obtain the basic information of all database instances in the database cluster, including but not limited to: database instance ID, IP / host name, port, log replication data, role, status (operating status, replication status, etc.), upstream database and downstream database corresponding to the current database instance, etc.; 2) Continuously detect faults in the database cluster.
[0081] Preferably, when using the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster, the method adopted is: using the leadership management service instance to detect the upstream database corresponding to the database instance in the database cluster, and then detecting the downstream database corresponding to the database instance after detecting the anomaly.
[0082] When the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster has a fault, wherein the first preset condition includes: the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance is abnormal.
[0083] When the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault, wherein the second preset condition includes: the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal.
[0084] When the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster has a fault, wherein the third preset condition includes: the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leading management service instance and each downstream database corresponding to the database instance is abnormal.
[0085] In this way, the cause of the database cluster failure is determined based on the connection between the leadership management service instance and the upstream database corresponding to the database instance, the connection between the leadership management service instance and the downstream database corresponding to the database instance, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance. The use of a multi-path detection method can effectively prevent the problem of misjudgment due to a single detection path, and greatly improve the reliability and security of database cluster monitoring and management.
[0086] Figure 3 A schematic flow chart of a database cluster management method in another embodiment of the present application is shown.
[0087] See also Figure 3 , a database cluster management method, comprising the following steps:
[0088] Step S31 : detecting the management service instances of the configured database cluster, wherein the management service instances include leading management service instances and candidate management service instances, wherein the leading management service instance is used to monitor and manage the database cluster.
[0089] For step S31, please refer to the relevant description in step S21, which will not be repeated here.
[0090] Step S32: When a failure of the leading management service instance is detected, a candidate management service instance is selected to replace the leading management service instance.
[0091] For step S32, please refer to the relevant description in step S22, which will not be repeated here.
[0092] Step S33: Use the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster.
[0093] For step S33, please refer to the relevant description in step S23, which will not be repeated here.
[0094] Step S34: Perform corresponding fault repair on the database instance in the database cluster according to the fault type.
[0095] When it is determined that an upstream database corresponding to a database instance in a database cluster fails (i.e., the detection result meets the first preset condition), the fault repair method is: select the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance, and update the replication topology relationship of the database cluster pair.
[0096] When it is determined that a network corresponding to a database instance in the database cluster fails or a switch port fails (ie, when the detection result meets the second preset condition), the fault repair method is: repair the network or switch port corresponding to the database instance.
[0097] When it is determined that a switch corresponding to a database instance in the database cluster fails (ie, the detection result meets the third preset condition), the fault repair method is: repairing the switch corresponding to the database instance.
[0098] In this way, corresponding fault repairs are performed on the database instances in the database cluster according to different fault types to ensure that the database instances in the database cluster can operate normally.
[0099] Step S35: If the fault repair fails, an alarm message carrying information related to the fault repair is generated and sent to the terminal.
[0100] It should be noted that if the fault repair fails, an alarm message carrying relevant information of the fault repair will be generated. When the terminal receives the alarm message, the administrator can use the alarm message to determine whether the database cluster has a fault and whether the fault repair is successful. If the fault repair fails, the administrator needs to decide whether to manually intervene in the fault repair based on the actual situation.
[0101] To better understand the principles of database cluster fault detection, Figure 5 The overall architecture of the database is shown in Figure 1. The database is divided into two major sections. One is the database cluster high-availability management service deployed on the management extranet, which is configured with at least two management service instances, one of which is set as the leading management service instance (i.e. Figure 5 The remaining management service instances are set as candidate management service instances (i.e. Figure 5 The other is a database cluster deployed in the data intranet. The database cluster includes multiple database instances, each of which corresponds to an upstream database (i.e. Figure 5 Upstream DB) and downstream database (i.e. Figure 5 Downstream DB (1), (2) shown).
[0102] Figure 5 The paths shown include the following:
[0103] 1) Detection path A is between the leader management service instance and the downstream database (i.e. Figure 5 Between the DB HAMService and the Downstream DB (1) shown);
[0104] 2) Detection path B is between the leader management service instance and the upstream database (i.e. Figure 5 between the DB HAMService and the Upstream DB shown);
[0105] 3) The detection path C is between the leader management service instance and the downstream database (2) (i.e. Figure 5 Between the DB HAMService and the Downstream DB (2) shown);
[0106] 4) The detection path D is located between the upstream database and the downstream database (1) (i.e. Figure 5 Between the Upstream DB and the Downstream DB (1) shown);
[0107] 5) Detection path E is located between the upstream database and the downstream database (2) (i.e. Figure 5 Between the Upstream DB and Downstream DB (2) shown);
[0108] 6) Detection path -1 is equivalent to path B. Failure of detection path -1 means: path B fails;
[0109] 7) Detection path -2 is equal to path A + path D. Failure of detection path -2 means: path A succeeds and path D fails.
[0110] 8) Detection path -3 is equivalent to path C + path E. Failure of detection path -3 means: path C succeeds and path E fails.
[0111] The detection anomaly usually refers to the failure of the leadership management service instance (DB HAM Service) to establish a connection with the database instance or to obtain the basic data of the database instance.
[0112] When the leader management service instance initiates a probe on the database cluster, see Figure 4 , Figure 4 What is shown is a flowchart of multipath detection in an embodiment of the present application, and this part of the content corresponds to steps S33 to S35.
[0113] Step S411, detect the upstream database corresponding to the database instance, and proceed to step S412.
[0114] It should be noted that the leadership management service instance obtains the basic data of the upstream database corresponding to the database instance. The basic information of the upstream database includes which downstream databases it corresponds to and the data replication status of the downstream database (the data replication status includes replication progress, whether it is normal, etc.). Initiate a probe on the upstream database corresponding to the database instance, which corresponds to the detection path -1.
[0115] Step S412: Determine whether the leadership management service instance is connected to the upstream database normally (i.e., the corresponding Figure 5 The detection path shown is -1).
[0116] If the leadership management service instance is connected to the upstream database normally (i.e., detection path-1 is normal), the acquired basic data will be persisted and the entire detection process will be ended; if the leadership management service instance is connected to the upstream database abnormally (i.e., detection path-1 is abnormal), step S413 will be entered.
[0117] Step S413: Detect all downstream databases corresponding to the upstream database in parallel, and proceed to step S414.
[0118] It should be noted that by obtaining the basic data of the upstream database, all downstream database instance information of the upstream database is obtained, and parallel detection is initiated for these instance information (such as Figure 5 Downstream DB(1) and Downstream DB(2) shown in the figure).
[0119] If the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal (i.e., detection path A and detection path B are both normal) and the connection between the upstream database corresponding to the database instance and the downstream databases corresponding to the database instance are abnormal (i.e., detection path D and detection path E are abnormal), it is determined that the upstream database corresponding to the database instance in the database cluster has a fault.
[0120] If the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal (i.e., both detection path A and detection path B are normal) and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal (i.e., detection path D or detection path E is normal), it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault.
[0121] If the connections between the leading management service instance and the downstream databases corresponding to the database instance are abnormal (ie, both the detection path A and the detection path B are abnormal), it is determined that the switch corresponding to the database instance in the database cluster fails.
[0122] Step S414: perform corresponding fault repair according to the fault type, and proceed to step S415.
[0123] When it is determined that the upstream database corresponding to the database instance in the database cluster has a fault (the corresponding detection path-1, detection path-2 and detection path-3 are all abnormal), the fault repair method is: select the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance, and update the replication topology relationship of the database cluster pair.
[0124] When it is determined that a network corresponding to a database instance in a database cluster fails or a switch port fails (corresponding to detection path-1 being abnormal, detection path-2 or detection path-3 being normal), the fault repair method adopted is: repairing the network or switch port corresponding to the database instance.
[0125] When it is determined that a switch corresponding to a database instance in a database cluster fails (corresponding detection path A, detection path B, and detection path C are all abnormal), the fault repair method is: repair the switch corresponding to the database instance.
[0126] Step S415: If the fault repair fails, an alarm message carrying information related to the fault repair is generated and sent to the terminal.
[0127] It should be noted that if the fault repair fails, an alarm message carrying relevant information of the fault repair will be generated. When the terminal receives the alarm message, the administrator can use the alarm message to determine whether the database cluster has a fault and whether the fault repair is successful. If the fault repair fails, the administrator needs to decide whether to manually intervene in the fault repair based on the actual situation.
[0128] Through the above steps, the problem of misjudgment due to a single detection path can be effectively prevented, greatly improving the reliability and security of database cluster monitoring and management.
[0129] Corresponding to the aforementioned functional method embodiments, the present application provides a database cluster management device, system and corresponding embodiments.
[0130] Figure 6 A schematic diagram of the structure of a database cluster high availability device in an embodiment of the present application is shown.
[0131] See also Figure 6 , A database cluster high availability device 60 includes: a detection module 610. .
[0132] The detection module 610 is used to detect the upstream database and the downstream database corresponding to the database instance in the database cluster using the leadership management service instance;
[0133] When the detection result meets the first preset condition, determining that the upstream database corresponding to the database instance in the database cluster fails; or,
[0134] When the detection result meets the second preset condition, determining that a network corresponding to the database instance in the database cluster fails or a switch port fails; or,
[0135] When the detection result meets the third preset condition, it is determined that a switch corresponding to the database instance in the database cluster fails.
[0136] In this way, the cause of the database cluster failure is determined based on the connection between the leadership management service instance and the upstream database corresponding to the database instance, the connection between the leadership management service instance and the downstream database corresponding to the database instance, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance. The use of a multi-path detection method can effectively prevent the problem of misjudgment due to a single detection path, and greatly improve the reliability and security of database cluster monitoring and management.
[0137] Figure 7 A schematic diagram of the structure of a database cluster high availability device in another embodiment of the present application is shown.
[0138] See also Figure 7 , a database cluster high availability device 60 includes: a detection module 620, an election module 630 and a detection module 610.
[0139] The detection module 620 is used to detect the management service instances of the configured database cluster, wherein the management service instances include a leading management service instance and a candidate management service instance, wherein the leading management service instance is used to monitor and manage the database cluster.
[0140] It should be noted that the database cluster high availability management service (DB HAM Service) is configured with at least two management service instances, one of which is configured as the leading management service instance, and the remaining management service instances are configured as candidate management service instances. The management service instances use a consistency protocol. The leading management service instance is responsible for monitoring and managing the database cluster, such as fault detection and fault repair of the database cluster. The remaining management service instances are "candidates" to replace the leading management service instance when the leading management service instance fails.
[0141] The election module 630 is used to select the candidate management service instance to replace the leading management service instance when it is detected that the leading management service instance fails.
[0142] It should be noted that real-time fault detection is performed on the leadership management service instance. If a failure occurs in the leadership management service instance (for example, a downtime problem occurs), one of the remaining candidate management service instances will be selected as a new leadership management service instance to monitor and manage the database cluster, so that the database cluster can provide services to the outside world and ensure the high availability of the database cluster.
[0143] The detection module 610 is used to detect the upstream database and the downstream database corresponding to the database instance in the database cluster by using the leadership management service instance.
[0144] Preferably, when using the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster, the method adopted is: using the leadership management service instance to detect the upstream database corresponding to the database instance in the database cluster, and then detecting the downstream database corresponding to the database instance after detecting the anomaly.
[0145] When the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster has a fault, wherein the first preset condition includes: the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance is abnormal.
[0146] When the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault, wherein the second preset condition includes: the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, the connection between the leading management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal.
[0147] When the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster has a fault, wherein the third preset condition includes: the connection between the leading management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leading management service instance and each downstream database corresponding to the database instance is abnormal.
[0148] In this way, the cause of the database cluster failure is determined based on the connection between the leadership management service instance and the upstream database corresponding to the database instance, the connection between the leadership management service instance and the downstream database corresponding to the database instance, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance. The use of a multi-path detection method can effectively prevent the problem of misjudgment due to a single detection path, and greatly improve the reliability and security of database cluster monitoring and management.
[0149] Figure 8 A schematic diagram of the structure of a database cluster high availability device in another embodiment of the present application is shown.
[0150] See also Figure 8 A database cluster high availability device 60 includes: a detection module 620, an election module 630, a detection module 610, a fault repair module 640 and an alarm module 650.
[0151] The functional description of the detection module 620, the election module 630, and the detection module 610 can be found in Figure 7 The relevant description in will not be repeated here.
[0152] The fault repair module 640 is used to perform corresponding fault repair on the database instance in the database cluster according to the fault type.
[0153] When it is determined that an upstream database corresponding to a database instance in a database cluster fails (i.e., the detection result meets the first preset condition), the fault repair method is: select the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance, and update the replication topology relationship of the database cluster pair.
[0154] When it is determined that a network corresponding to a database instance in the database cluster fails or a switch port fails (ie, when the detection result meets the second preset condition), the fault repair method is: repair the network or switch port corresponding to the database instance.
[0155] When it is determined that a switch corresponding to a database instance in the database cluster fails (ie, the detection result meets the third preset condition), the fault repair method is: repairing the switch corresponding to the database instance.
[0156] The alarm module 650 is used to generate an alarm message carrying information related to the fault repair if the fault repair fails, and send the alarm message to the terminal.
[0157] It should be noted that if the fault repair fails, an alarm message carrying relevant information of the fault repair will be generated. When the terminal receives the alarm message, the administrator can use the alarm message to determine whether the database cluster has a fault and whether the fault repair is successful. If the fault repair fails, the administrator needs to decide whether to manually intervene in the fault repair based on the actual situation.
[0158] Fig. 9 A schematic diagram of the structure of a database cluster high-availability system in an embodiment of the present application is shown.
[0159] See also Fig. 9 , a database cluster management system 90, comprising: a database cluster management server 910, a database cluster 920;
[0160] The database cluster management service end 910 is used to use the leadership management service instance to detect the upstream database and downstream database corresponding to the database instance in the database cluster; when the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster has a fault; or, when the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault; or, when the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster has a fault
[0161] Regarding the devices and systems in the above embodiments, the specific manners in which the various modules and units perform operations have been described in detail in the method embodiments corresponding to the devices and systems, and will not be elaborated on again here.
[0162] See also Fig.10 , the electronic device 1000 includes a processor 1100 and a memory 1200 .
[0163] The processor 1100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0164] The memory 1200 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 1100 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at run time. In addition, the memory 1200 may include any combination of computer-readable storage media, including various types of semiconductor storage chips (such as DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. The memory 1200 stores executable codes, and when the executable codes are processed by the processor 1100 , the processor 1100 can execute part or all of the methods described above.
[0165] The scheme of the present application has been described in detail above with reference to the accompanying drawings. In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, refer to the relevant description of other embodiments. Those skilled in the art should also know that the actions and modules involved in the description are not necessarily required for the present application. In addition, it can be understood that the steps in the method of the embodiment of the present application can be adjusted in order, merged and deleted according to actual needs, and the modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0166] The embodiments of the present application have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A database cluster management method, It is characterized in that include: Use the leadership management service instance to detect the upstream database corresponding to the database instance in the database cluster, and then detect the downstream database corresponding to the database instance after detecting the anomaly; When the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster fails; the first preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal, and the upstream database corresponding to the database instance and each downstream database corresponding to the database instance are abnormally connected; or, When the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster fails or the switch port fails; the second preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal; or, When the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster fails; the third preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and each of the downstream databases corresponding to the database instance is abnormal; Perform corresponding fault repair on the database instances in the database cluster according to the fault type; When it is determined that the upstream database corresponding to the database instance in the database cluster fails, the method further includes: selecting the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance and updating the replication topology relationship of the database cluster to perform fault repair; When it is determined that the network corresponding to the database instance in the database cluster fails or the switch port fails, the method further includes: repairing the network or the switch port corresponding to the database instance; When it is determined that the switch corresponding to the database instance in the database cluster fails, the method further includes: repairing the switch corresponding to the database instance.
2. The database cluster management method according to claim 1, It is characterized in that Before using the leadership management service instance to detect the upstream database and the downstream database corresponding to the database instance in the database cluster, the method further includes: Detecting the management service instance of the configured database cluster, wherein the management service instance includes a leading management service instance and a candidate management service instance, wherein the leading management service instance is used to monitor and manage the database cluster; When it is detected that the leading management service instance fails, the candidate management service instance is selected to replace the leading management service instance.
3. A database cluster management device, It is characterized in that include: The detection module uses the leadership management service instance to detect the upstream database corresponding to the database instance in the database cluster, and then detects the downstream database corresponding to the database instance after detecting the anomaly; When the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster fails; the first preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal, and the upstream database corresponding to the database instance and each downstream database corresponding to the database instance are abnormally connected; or, When the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster fails or the switch port fails; the second preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and the downstream database corresponding to at least one database instance is normal; or, When the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster fails; the third preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and each of the downstream databases corresponding to the database instance is abnormal; A fault repair module is used to perform corresponding fault repairs on database instances in the database cluster according to the fault type; When it is determined that the upstream database corresponding to the database instance in the database cluster fails, the fault repair module is further used to: select the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance and update the replication topology relationship of the database cluster to perform fault repair; When it is determined that the network corresponding to the database instance in the database cluster fails or the switch port fails, the fault repair module is further used to: repair the network or the switch port corresponding to the database instance; When it is determined that the switch corresponding to the database instance in the database cluster fails, the fault repair module is further used to: perform fault repair on the switch corresponding to the database instance.
4. The database cluster management device according to claim 3, It is characterized in that Also includes: A detection module, used to detect the management service instance of the configured database cluster, wherein the management service instance includes a leading management service instance and a candidate management service instance, wherein the leading management service instance is used to monitor and manage the database cluster; The election module is used to select the candidate management service instance to replace the leading management service instance when it is detected that the leading management service instance fails.
5. A database cluster management system, It is characterized in that include: Database cluster management server, database cluster; The database cluster management service end is used to detect the upstream database corresponding to the database instance in the database cluster using the leadership management service instance, and then detect the downstream database corresponding to the database instance after detecting the abnormality; When the detection result meets the first preset condition, it is determined that the upstream database corresponding to the database instance in the database cluster has a fault; the first preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and each downstream database corresponding to the database instance is abnormal; or, when the detection result meets the second preset condition, it is determined that the network corresponding to the database instance in the database cluster has a fault or a switch port fault; the second preset condition includes: the connection between the leadership management service instance and the upstream database corresponding to the database instance is abnormal, and the connection between the leadership management service instance and the downstream database corresponding to the database instance is normal, and the connection between the upstream database corresponding to the database instance and at least one downstream database corresponding to the database instance is normal; or, when the detection result meets the third preset condition, it is determined that the switch corresponding to the database instance in the database cluster has a fault; the second preset condition includes: the leadership management service instance and the database instance have a fault. The upstream database corresponding to the database instance is abnormally connected, and the leadership management service instance is normally connected to the downstream database corresponding to the database instance, and the upstream database corresponding to the database instance is normally connected to the downstream database corresponding to at least one database instance; the database instances in the database cluster are repaired accordingly according to the fault type; the system also includes: repairing the database instances in the database cluster accordingly according to the fault type; when it is determined that the upstream database corresponding to the database instance in the database cluster fails, the system also includes: selecting the downstream database corresponding to one of the database instances to replace the upstream database corresponding to the database instance and updating the replication topology relationship of the database cluster to repair the fault; when it is determined that the network corresponding to the database instance in the database cluster fails or the switch port fails, the system also includes: repairing the network or the switch port corresponding to the database instance; when it is determined that the switch corresponding to the database instance in the database cluster fails, the system also includes: repairing the switch corresponding to the database instance.
6. An electronic device, It is characterized in that include: processor; as well as A memory having executable codes stored thereon, which, when executed by the processor, causes the processor to execute the database cluster management method according to any one of claims 1 to 2.
7. A computer-readable storage medium having executable codes stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the database cluster management method according to any one of claims 1 to 2.
