Exception processing method, device, and electronic device based on multi-node database

By detecting exceptions in the database master node and automatically performing switching operations, the problem of the automatic switching policy cannot be executed when multiple nodes are abnormal in a distributed database cluster is solved, and the database is high reliability and stability is achieved.

CN119782053APending Publication Date: 2025-04-08JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411939703.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

In a distributed database cluster, when multiple nodes have abnormalities almost simultaneously, conventional automatic switching strategies cannot be effectively executed, and system administrators need to intervene manually, resulting in unstable business operations.

Method used

By detecting abnormal situations in the database master node, obtaining node switching policy and storage partition information, determining whether the node switching conditions are met, and automatically performing switching operations when the conditions are met, ensuring the reliability and stability of the database.

Benefits of technology

Automatic switching of database master nodes is realized, manual intervention is reduced, and business operation stability and reliability are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782053A_ABST
    Figure CN119782053A_ABST
Patent Text Reader

Abstract

The present application relates to an exception handling method, device, electronic device and storage medium based on a multi-node database, the method comprising: obtaining a node switching strategy of a master node and partition information of a storage partition corresponding to the master node; determining the strategy type of the node switching strategy; when the node switching strategy is a high-reliability strategy, determining whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition; when the storage partition meets the node switching condition, executing a switching operation of the corresponding node switching strategy on the master node, and automatically repairing the master node when there is no high-availability data node in the storage partition. The method determines whether the storage partition of the master node meets the node switching condition according to the partition information of the storage partition, and when the switching condition is met, executes the switching strategy to automatically switch the master node to the standby node, thereby ensuring the high availability of the database and the integrity of the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to an exception handling method, device, electronic device and storage medium based on a multi-node database. Background Art

[0002] Distributed databases often use a one-master-multiple-backup deployment method to ensure business reliability. When the database master node is affected by network, equipment, and other reasons that affect the normal operation of the business, you can usually switch the data node by configuring a switching strategy to ensure the normal operation of the business.

[0003] However, when multiple nodes in a distributed database cluster fail almost simultaneously, the conventional automatic switching strategy may not be able to be effectively executed due to the large number of faulty nodes. It does not have the ability to automatically switch data nodes for recovery, and requires manual intervention by the system administrator to manually diagnose the fault and switch data nodes. However, the speed and efficiency of manual processing often cannot meet the data switching requirements, affecting the normal operation of the business.

[0004] Therefore, there is an urgent need to develop an exception handling method, device, electronic device and storage medium based on a multi-node database to solve one or more of the above-mentioned problems. Summary of the invention

[0005] In view of this, in order to solve the above technical problems or part of the technical problems, an embodiment of the present invention provides an exception handling method, device, electronic device and storage medium based on a multi-node database.

[0006] In a first aspect, the present application provides an exception handling method based on a multi-node database, the method comprising:

[0007] When an abnormality is detected in a database master node, a node switching strategy of the master node and partition information of a storage partition corresponding to the master node are obtained;

[0008] Determining a strategy type of the node switching strategy;

[0009] In the case where the node switching strategy is a high reliability strategy, judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition;

[0010] When the storage partition meets the node switching condition, a switching operation corresponding to the node switching strategy is performed on the master node.

[0011] In a possible implementation, the method further includes:

[0012] When the node switching strategy is a high availability strategy, determining whether there is a high availability data node in the storage partition;

[0013] In the case where there is a highly available data node in the storage partition, switching the master node to the highly available data node;

[0014] In the case that there is no highly available data node in the storage partition, the master node is repaired.

[0015] In a possible implementation, before determining, according to the partition information of the storage partition, whether the storage partition corresponding to the master node meets the node switching condition, the method further includes:

[0016] Obtain the number of abnormal nodes in each storage partition included in the historical database;

[0017] According to the number of abnormal nodes in each storage partition, the storage partition is divided into abnormal partitions and valid partitions;

[0018] Determine the number of partitions in the history database that are valid partitions;

[0019] When the number of partitions of the valid partitions in the historical database meets the preset high reliability condition, a switching operation corresponding to the node switching strategy is performed on the master node.

[0020] In a possible implementation, judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition includes:

[0021] Obtain the number of abnormal nodes in each storage partition included in the current database, and divide the storage partition into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition;

[0022] Determine the number of abnormal partitions and the number of valid partitions in the current database;

[0023] When the number of abnormal partitions in the current database is less than the number of valid partitions, and the storage partition corresponding to the master node is an abnormal partition, the storage partition corresponding to the master node meets the node switching condition.

[0024] In a possible implementation, the method further includes:

[0025] Determine whether the switching of the master node is successful;

[0026] In case the switching fails, the master node is repaired.

[0027] In a possible implementation manner, repairing the master node includes:

[0028] When the automatic repair of abnormal nodes is turned on, check whether there is alarm information corresponding to the master node in the database;

[0029] When the alarm information corresponding to the master node exists in the database, the alarm information is sent to the repair node, and a repair result corresponding to the alarm information is generated.

[0030] In a possible implementation manner, after repairing the master node, the method further includes:

[0031] Detect whether there is master node update information of the storage area corresponding to the master node in the database;

[0032] In the case that the master node update information of the storage area corresponding to the master node does not exist in the database, the step of determining the policy type of the node switching policy is re-executed.

[0033] In a second aspect, the present application provides an exception handling device based on a multi-node database, the device comprising:

[0034] An acquisition module, used to acquire a node switching strategy of the master node and partition information of a storage partition corresponding to the master node when detecting an abnormality in the master node of the database;

[0035] A first determination module, used to determine the strategy type of the node switching strategy;

[0036] A second judgment module is used to judge whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition when the node switching strategy is a high reliability strategy;

[0037] The switching module is used to execute a switching operation corresponding to the node switching strategy on the master node when the storage partition meets the node switching condition.

[0038] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the processor implements the steps of the exception handling method based on a multi-node database as described in any one of the embodiments of the first aspect.

[0039] In a fourth aspect, the present application further provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the exception handling method based on a multi-node database as described in any embodiment of the first aspect are implemented.

[0040] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application, when there is an abnormality in the main node of the database, determines whether the storage partition corresponding to the main node meets the node switching conditions based on the partition information of the storage partition corresponding to the main node. If the switching conditions are met, the switching strategy is executed to automatically switch the main node to the backup node, thereby ensuring the reliability and stability of the database. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0042] In order to more clearly illustrate the embodiments of the present invention 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0043] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0044] Figure 1 A flowchart of an exception handling method based on a multi-node database provided in an embodiment of the present application;

[0045] Figure 2 A flowchart of another exception handling method based on a multi-node database provided in an embodiment of the present application;

[0046] Figure 3 A flowchart of another exception handling method based on a multi-node database provided in an embodiment of the present application;

[0047] Figure 4 A flowchart of an exception handling method based on a multi-node database provided in an embodiment of the present application;

[0048] Figure 5 A schematic diagram of the structure of an exception handling product provided in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of the structure of an exception handling device based on a multi-node database provided in an embodiment of the present application;

[0050] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are 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 making creative work are within the scope of protection of this application.

[0052] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0053] In order to solve the technical problem in the prior art that when multiple nodes in a cluster are abnormal at the same time, it is impossible to perform timely master node switching according to the switching strategy to select a new master node, and manual selection of the new master node is required, resulting in slow processing speed, thereby failing to ensure the normal operation of the business, the present application provides an exception handling method, device, electronic device and storage medium based on a multi-node database, which can switch according to the configured switching strategy in production mode when the database master node is abnormal. When the switching conditions are not met, the majority method is used to determine whether there is a consistent copy in the fault scenario. When it is determined that a consistent copy exists, the consistent copy is selected for switching, thereby ensuring the continuity and stability of the database service.

[0054] Figure 1 A flowchart of an exception handling method based on a multi-node database provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method specifically includes:

[0055] S101. When detecting that a database master node is abnormal, obtaining a node switching strategy of the master node and partition information of a storage partition corresponding to the master node;

[0056] In computer networks, a master node usually refers to a node that plays a key control and coordination role in a distributed system or network topology. Taking the blockchain network as an example, the master node is a special full node that not only stores a complete copy of the blockchain, but also undertakes more advanced functions such as verifying transactions and maintaining network order. Therefore, the master node needs to have high computing power, storage capacity and network bandwidth, and needs to process a large amount of transaction information and broadcast the verified information to other nodes.

[0057] In this embodiment, when an abnormal condition is detected in the master node of the database, in order to ensure the integrity of the data and the stability of the system, first, the node switching policy of the master node is obtained to understand the key information such as the current failover mechanism, switching conditions and switching process, and then the relevant information of the storage partition corresponding to the master node is obtained, including the size, location, data type and data distribution of the partition, etc. The possible impact of the switching operation on the storage system is evaluated through the partition information, and necessary data support is provided for subsequent data recovery and system optimization.

[0058] S102, determining the strategy type of the node switching strategy;

[0059] The node switching strategies include high reliability strategy, high availability strategy, low reliability strategy, and low availability strategy;

[0060] In this embodiment, when performing node switching, it is first necessary to determine the type of strategy to be adopted to ensure the feasibility of the switching strategy and further ensure the correctness of the switching process.

[0061] S103: When the node switching strategy is a high reliability strategy, judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition;

[0062] If the switching strategy is an implementable strategy, it is also necessary to analyze the node status of the storage partition corresponding to the failed master node to ensure that there are other data nodes in the storage partition that can replace the master node;

[0063] In this embodiment, when the node switching strategy of the current faulty master node is a high reliability strategy, which means that the strategy can be directly implemented, it is further determined whether the storage partition meets the relevant conditions for node switching. The relevant conditions may include whether the size of the partition is within a preset threshold range, whether the data type meets specific requirements, whether the data distribution is uniform, etc.

[0064] S104: When the storage partition meets the node switching condition, perform a switching operation corresponding to the node switching strategy on the master node.

[0065] In this embodiment, after confirming that the storage partition meets the conditions,

[0066] A node switching operation can be performed to transfer the responsibilities of the failed main node to the standby node, so that the standby node can continue to perform operations such as data transmission, task execution or resource utilization, realize fault recovery, and thus ensure the continuity and stability of the database system.

[0067] The exception handling method based on a multi-node database provided in the embodiment of the present application, when an exception or failure occurs in the master node in the database system, firstly analyzes the relevant information of the storage partitions corresponding to the master node, checks the storage contents of these storage partitions to determine whether the storage partitions meet the switching conditions for node switching, and executes a pre-set switching strategy when it is determined that the storage partitions meet the predetermined node switching conditions, and automatically transfers the role and function of the master node to the backup node, so as to ensure the continuous operation of the entire database system and the integrity of the data, and achieve the reliability and stability of the database when problems occur in the master node.

[0068] In an optional solution of the embodiment of the present invention, the method further includes:

[0069] When the node switching strategy is a high availability strategy, determining whether there is a high availability data node in the storage partition;

[0070] In this embodiment, in the specific situation where the node switching strategy currently described is set as a high availability strategy, it is necessary to further determine whether there are data nodes configured as high availability within the storage partition.

[0071] In the case where there is a highly available data node in the storage partition, switching the master node to the highly available data node;

[0072] In the case that there is no highly available data node in the storage partition, the master node is repaired.

[0073] In this embodiment, when there are high-availability data nodes in the storage partition, the responsibilities of the master node are transferred to the high-availability node, so that the high-availability node continues to perform operations such as data transmission, task execution or resource utilization, and realizes fault recovery, thereby ensuring the continuity and stability of the database.

[0074] For example, in production mode, when the database master node is abnormal, switching is performed according to the configured switching strategy. When the switching conditions are not met, the majority method is used to determine whether there is a consistent copy (highly available data node) in the fault scenario. When it is determined that there is a consistent copy, the consistent copy is selected for switching.

[0075] When there is no high-availability data node in the storage partition, it means that there is no available standby switch node in the storage node. At this time, the faulty primary node needs to be repaired to ensure that the database can resume normal operation as soon as possible, thereby ensuring the stability of the database.

[0076] The faulty master node switching method provided in the embodiment of the present application, in the process of judging whether to implement node switching, when the node switching strategy is a high availability strategy, determines whether there is a high-availability data node in the storage partition. If so, the switching operation from the master node to the high-availability data node is executed to ensure data continuity and uninterrupted service; if not, the repair process of the faulty master node is started, including but not limited to fault diagnosis, data recovery, and system restart steps, so as to restore the normal operating state of the database as soon as possible. In this way, the faulty master node switching method can effectively handle abnormal situations in multi-node databases and improve the availability and stability of the system.

[0077] Figure 2 A flowchart of another exception handling method based on a multi-node database provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, before judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition, the method specifically includes:

[0078] S201, obtaining the number of abnormal nodes in each storage partition included in the historical database;

[0079] Database storage partitioning is a technology that divides the database storage area into multiple independent parts; each storage partition is like an independent small database and can have its own storage characteristics, access rules, and management methods.

[0080] In this embodiment, in order to ensure the stability and reliability of the system, all storage partitions contained in the historical database are obtained, and the number of nodes with abnormalities therein is counted, and the nodes are further analyzed and processed.

[0081] It should be noted that the historical database is a pre-anomaly warning database, which records the storage partition status information before the anomaly occurs, including key indicators such as the number of nodes in each partition, node health status, data synchronization status, etc. By analyzing these historical data, an important reference basis can be provided for anomaly handling.

[0082] S202, dividing the storage partitions into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition;

[0083] In this embodiment, after obtaining the number of abnormal nodes in each storage partition, the storage partition is divided into abnormal partitions where the abnormal data nodes are greater than the specified response number and valid partitions where the abnormal data nodes are less than the specified response number according to the number of abnormal nodes.

[0084] It should be noted that the number of consistent replicas in the valid partition, that is, the number of switchable standby nodes, is greater than or equal to the specified number of responses.

[0085] S203, determining the number of partitions of the valid partitions in the historical database;

[0086] S204: When the number of partitions of the valid partitions in the historical database meets a preset high reliability condition, a switching operation corresponding to the node switching strategy is performed on the master node.

[0087] In this embodiment, after the storage partitions of the historical database are divided into valid partitions and abnormal partitions, the number of partitions of the valid partitions in the historical database is counted. When the number of valid partitions in the historical database has reached the preset high reliability condition, the abnormal node switching strategy is a high reliability strategy that satisfies the original historical database, and the node switching operation is executed to switch the main node to the backup node to ensure the continuity and stability of the database system.

[0088] The exception handling method for a multi-node database provided in an embodiment of the present application detects the storage partitions of the historical database and divides them into valid partitions and abnormal partitions; then the number of the valid partitions and the abnormal partitions is counted, and when the number of valid partitions meets the preset high reliability condition, no further judgment is required, and the node switching operation is directly executed to switch the main node to the backup node, which can effectively improve the reliability and stability of the database system, while simplifying the exception handling process and reducing the need for manual intervention.

[0089] In an optional solution of the embodiment of the present invention, judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition includes:

[0090] Obtain the number of abnormal nodes in each storage partition included in the current database, and divide the storage partition into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition;

[0091] Determine the number of abnormal partitions and the number of valid partitions in the current database;

[0092] When the number of abnormal partitions in the current database is less than the number of valid partitions, and the storage partition corresponding to the master node is an abnormal partition, the storage partition corresponding to the master node meets the node switching condition.

[0093] In this embodiment, in the process of determining whether the storage area corresponding to the master node meets the node switching conditions, it is necessary to determine whether the storage area where the abnormal node is located is an abnormal area; prior to this, the storage partitions are divided into abnormal partitions and valid partitions for the first time according to the number of nodes of the abnormal nodes in each storage partition of the current database. When the number of partitions of the abnormal partitions in the current database is less than the number of partitions of the valid partitions, and the storage partition corresponding to the master node is an abnormal partition, it means that the abnormal area where the abnormal node is located can perform node switching normally and meets the node switching conditions.

[0094] In an optional solution of the embodiment of the present invention, the method further includes:

[0095] Determine whether the switching of the master node is successful;

[0096] In case the switching fails, the master node is repaired.

[0097] In this embodiment, during the process of executing node switching, no matter which of the above node switching methods is adopted, the switching result will be obtained after the switching is completed to determine whether the switching is successful. If a failure occurs during the switching process, in order to ensure the stability of the database, necessary repair work is performed on the failed master node and a preset fault recovery program is started. The program includes but is not limited to restarting the master node service, checking and repairing data consistency issues, and resynchronizing the data between the master node and the slave node, ensuring that even in the event of a node switching failure, the database system can still maintain normal operation and reduce the impact on the business.

[0098] Figure 3 A flowchart of another exception handling method based on a multi-node database provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the method specifically includes:

[0099] S301. When the automatic repair of abnormal nodes is enabled, detecting whether there is alarm information corresponding to the master node in the database;

[0100] In this embodiment, during the process of repairing abnormal nodes, it is first necessary to determine whether the automatic repair corresponding to the database is turned on. When the automatic repair function of the abnormal node is activated and enabled, a series of node repair processes will be automatically started. This process scans the database in detail to ensure that the alarm information associated with the designated master node is identified without any omissions. The automated monitoring mechanism not only improves the efficiency of database management, but also greatly reduces the need for manual intervention, thereby ensuring the stability and reliability of the system.

[0101] S302: When there is alarm information corresponding to the master node in the database, the alarm information is sent to the repair node, and a repair result corresponding to the alarm information is generated.

[0102] In this embodiment, when alarm information associated with a faulty main node is detected in the database, the alarm information will be identified and collected, and then passed to the repair node responsible for handling such problems; once the system receives the alarm information and passes it to the repair node, it will immediately start the process of repairing the faulty node, and generate a repair result report after the repair, recording all repair measures taken and the repair results.

[0103] Specifically, the repair master control module extracts the alarm information and sends the corresponding alarm information to the repair module under the node to be repaired. After receiving the alarm information, the repair module will adopt corresponding strategies and methods according to the information to ensure that the problem can be repaired effectively.

[0104] Furthermore, if a failure is encountered during the repair attempt, a corresponding alarm message will be generated, which will clearly point out the problem so that the staff can conduct manual troubleshooting and processing in a timely manner.

[0105] The exception handling method based on a multi-node database provided in the embodiment of the present application is applied to automatic switching and repair after multi-node exceptions in the database. The majority protocol is used to determine whether there is a consistent copy under extreme conditions. If it exists, switching is performed; if not, switching is performed again after repair. Parameters are used to control whether automatic repair is performed after the component exception. If a new master node is not selected before repair, switching is performed again after repair, thereby ensuring high availability and high reliability of the database, thereby ensuring the stability and reliability of the business.

[0106] In an optional solution of the embodiment of the present invention, after repairing the master node, the method further includes:

[0107] Detect whether there is master node update information of the storage area corresponding to the master node in the database;

[0108] In the case that the master node update information of the storage area corresponding to the master node does not exist in the database, the step of determining the policy type of the node switching policy is re-executed.

[0109] In this embodiment, after the faulty master node is repaired, the database needs to be checked to determine whether there is master node update information for the storage area associated with the specific master node; if the master node update information for the storage area associated with the specific master node is not found in the database, then it is necessary to re-judge, that is, to execute the process of checking the policy type of the node switching policy again.

[0110] Figure 4 A flowchart of an exception handling device based on a multi-node database provided in an embodiment of the present application is shown in FIG. Figure 4 As shown in the figure, automatic switching and repair after multiple database nodes are abnormal mainly include the following steps:

[0111] Step 1: The monitoring module detects data node abnormalities, makes a switching strategy judgment, and generates alarm information and stores it in the alarm module;

[0112] Step 2: Determine the switching strategy. If it is a high-availability strategy and there are available nodes, go to step 4 after normal switching. If there are no available nodes, go to step 5. If it is a high-reliability strategy, obtain the number of valid teams before the exception and determine whether the switching conditions are met. If so, initiate switching and go to step 5. If not, go to step 4.

[0113] Step 3: Determine whether the team where the abnormal node is located is an abnormal team;

[0114] Step 4: Determine whether there is a consistent copy based on the valid team and the abnormal team. If yes, initiate a switch and go to step 5. If no, the switch fails and go to step 5.

[0115] Step 5: Determine whether the automatic repair switch is turned on. If the switch is not turned on, the automatic repair process will not be performed and the process ends. If the switch is turned on, go to step 6;

[0116] Step 6: If the automatic repair switch is turned on, obtain the alarm information in the abnormal node in the alarm module. If there is no alarm information, the automatic repair process will not be completed. If there is alarm information, go to step 7;

[0117] Step 7: If there is an alarm message, send the alarm message to the repair master control module;

[0118] Step 8: The repair master control module extracts the alarm information and sends the corresponding alarm information to the repair module under the node to be repaired. The repair module performs repair in a corresponding manner according to the specific alarm information;

[0119] Step 9: The repair module initiates the repair. If the repair fails, a new alarm message is generated to the alarm module, which reports it to the front-end page for manual intervention.

[0120] Step 10: If the repair is successful, determine whether to select a new primary. If so, the process ends. If not, continue with steps 2 to 9.

[0121] In this embodiment, a team is composed of one or more data nodes, where a valid team is one in which the number of consistent replicas is greater than or equal to a specified response number, and an abnormal team is one in which the number of abnormal data nodes is greater than a specified response number; the response number refers to the number of data nodes in a team that can respond normally; a consistent replica is a replica node that is consistent with the data of the primary node.

[0122] Figure 5 The structural diagram of the exception handling product provided in the embodiment of the present application is as follows: Figure 5 As shown, the exception handling product may include a front-end page, a monitoring module, an alarm module, a switching module, and a repair master control module; wherein the front-end page is a module for setting a switching strategy, setting an emergency repair strategy, and displaying alarm information; the monitoring module is a module for monitoring the status of data nodes and storing switching strategies; the switching module is a module that triggers data node switching based on the node status, switching strategy, and other information sent by the interface monitoring module; the alarm module is a module that receives alarm information sent by the monitoring module, stores the alarm information, and reports the alarm information to the front-end page; the repair master control module is a module that receives node information, switching progress, and switching strategy sent by the switching module, checks the alarm information in the alarm module, and sends the repair strategy to the data node; the repair module is a module that receives the repair strategy sent by the repair master control module and actually performs the repair.

[0123] Figure 6 A schematic diagram of the structure of an exception handling device based on a multi-node database provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the device specifically includes:

[0124] The acquisition module 601 is used to acquire the node switching strategy of the master node and the partition information of the storage partition corresponding to the master node when detecting that there is an abnormality in the master node of the database;

[0125] A first determination module 602 is used to determine the strategy type of the node switching strategy;

[0126] The second judgment module 603 is used to judge whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition when the node switching strategy is a high reliability strategy;

[0127] The switching module 604 is used to execute a switching operation corresponding to the node switching strategy on the master node when the storage partition meets the node switching condition.

[0128] In one possible embodiment, the device also includes a third judgment module 605, which is used to determine whether there is a high-availability data node in the storage partition when the node switching strategy is a high-availability strategy; if there is a high-availability data node in the storage partition, switch the master node to the high-availability data node; if there is no high-availability data node in the storage partition, repair the master node.

[0129] In one possible implementation, the second judgment module 603 is also used to obtain the number of abnormal nodes in each storage partition included in the historical database; divide the storage partitions into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition; determine the number of partitions of the valid partitions in the historical database; and perform a switching operation corresponding to the node switching strategy on the master node when the number of partitions of the valid partitions in the historical database meets a preset high reliability condition.

[0130] In one possible implementation, the second judgment module 603 is further used to obtain the number of abnormal nodes in each storage partition included in the current database, and divide the storage partitions into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition; determine the number of partitions of the abnormal partitions in the current database, and the number of partitions of the valid partitions; when the number of partitions of the abnormal partitions in the current database is less than the number of partitions of the valid partitions, and the storage partition corresponding to the master node is an abnormal partition, the storage partition corresponding to the master node meets the node switching condition.

[0131] In a possible implementation, the device further includes a repair module 606, which is used to determine whether the switching of the master node is successful; if the switching fails, repair the master node.

[0132] In one possible implementation, the repair module 606 is also used to detect whether there is alarm information corresponding to the master node in the database when automatic repair of abnormal nodes is turned on; if there is alarm information corresponding to the master node in the database, the alarm information is sent to the repair node to generate a repair result corresponding to the alarm information.

[0133] In one possible implementation, the repair module 606 is also used to detect whether there is master node update information of the storage area corresponding to the master node in the database; if there is no master node update information of the storage area corresponding to the master node in the database, the step of determining the policy type of the node switching strategy is re-executed.

[0134] The exception handling device based on the multi-node database provided in this embodiment can be as follows: Figure 6The exception handling device based on a multi-node database shown in can be executed as follows Figure 1-5 All steps of exception handling based on multi-node database in Figure 1-5 The technical effect of exception handling based on multi-node database is shown. For details, please refer to Figure 1-5 For the sake of brevity, the relevant description is not repeated here.

[0135] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0136] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, an embodiment of the present application provides an electronic device, including a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704; the memory 703 is used to store computer programs; the processor 701 is used to execute the program stored in the memory 703, and implement the steps of the exception handling method based on the multi-node database provided by any of the aforementioned method embodiments:

[0137] When an abnormality is detected in the database master node, the node switching strategy of the master node and the partition information of the storage partition corresponding to the master node are obtained; the policy type of the node switching strategy is determined; when the node switching strategy is a high-reliability strategy, whether the storage partition corresponding to the master node meets the node switching conditions is determined based on the partition information of the storage partition; when the storage partition meets the node switching conditions, a switching operation corresponding to the node switching strategy is performed on the master node.

[0138] In one possible implementation, when the node switching strategy is a high availability strategy, determine whether there is a high availability data node in the storage partition; when there is a high availability data node in the storage partition, switch the master node to the high availability data node; when there is no high availability data node in the storage partition, repair the master node.

[0139] In one possible implementation, the number of abnormal nodes in each storage partition included in the historical database is obtained; the storage partitions are divided into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition; the number of partitions of the valid partitions in the historical database is determined; and when the number of partitions of the valid partitions in the historical database meets a preset high reliability condition, a switching operation corresponding to the node switching strategy is performed on the master node.

[0140] In one possible implementation, the number of abnormal nodes in each storage partition included in the current database is obtained, and the storage partitions are divided into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition currently included; the number of partitions of the abnormal partitions in the current database and the number of partitions of the valid partitions are determined; when the number of partitions of the abnormal partitions in the current database is less than the number of partitions of the valid partitions, and the storage partition corresponding to the master node is an abnormal partition, the storage partition corresponding to the master node meets the node switching condition.

[0141] In a possible implementation, it is determined whether the switching of the master node is successful; if the switching fails, the master node is repaired.

[0142] In one possible implementation, when automatic repair of abnormal nodes is turned on, it is detected whether there is alarm information corresponding to the master node in the database; if there is alarm information corresponding to the master node in the database, the alarm information is sent to the repair node, and a repair result corresponding to the alarm information is generated.

[0143] In one possible implementation, it is detected whether there is master node update information of the storage area corresponding to the master node in the database; if there is no master node update information of the storage area corresponding to the master node in the database, the step of determining the policy type of the node switching policy is re-executed.

[0144] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0145] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0146] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. 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 invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. An exception handling method based on a multi-node database, characterized in that: include: When an abnormality is detected in a database master node, a node switching strategy of the master node and partition information of a storage partition corresponding to the master node are obtained; Determining a strategy type of the node switching strategy; In the case where the node switching strategy is a high reliability strategy, judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition; When the storage partition meets the node switching condition, a switching operation corresponding to the node switching strategy is performed on the master node.

2. The method according to claim 1, characterized in that The method further comprises: When the node switching strategy is a high availability strategy, determining whether there is a high availability data node in the storage partition; In the case where there is a highly available data node in the storage partition, switching the master node to the highly available data node; In the case that there is no highly available data node in the storage partition, the master node is repaired.

3. The method according to claim 1, characterized in that Before judging whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition, the method further includes: Obtain the number of abnormal nodes in each storage partition included in the historical database; According to the number of abnormal nodes in each storage partition, the storage partition is divided into abnormal partitions and valid partitions; Determine the number of partitions in the history database that are valid partitions; When the number of partitions of the valid partitions in the historical database meets the preset high reliability condition, a switching operation corresponding to the node switching strategy is performed on the master node.

4. The method according to claim 3, characterized in that The determining, according to the partition information of the storage partition, whether the storage partition corresponding to the master node meets the node switching condition includes: Obtain the number of abnormal nodes in each storage partition included in the current database, and divide the storage partition into abnormal partitions and valid partitions according to the number of abnormal nodes in each storage partition; Determine the number of abnormal partitions and the number of valid partitions in the current database; When the number of abnormal partitions in the current database is less than the number of valid partitions, and the storage partition corresponding to the master node is an abnormal partition, the storage partition corresponding to the master node meets the node switching condition.

5. The method according to claim 2 or 3, characterized in that: The method further comprises: Determine whether the switching of the master node is successful; In case the switching fails, the master node is repaired.

6. The method according to claim 5, characterized in that The repairing of the master node comprises: When the automatic repair of abnormal nodes is turned on, check whether there is alarm information corresponding to the master node in the database; When the alarm information corresponding to the master node exists in the database, the alarm information is sent to the repair node, and a repair result corresponding to the alarm information is generated.

7. The method according to claim 6, characterized in that After repairing the master node, the method further includes: Detect whether there is master node update information of the storage area corresponding to the master node in the database; In the case that the master node update information of the storage area corresponding to the master node does not exist in the database, the step of determining the policy type of the node switching policy is re-executed.

8. An exception handling device based on a multi-node database, characterized in that: include: An acquisition module, used to acquire a node switching strategy of the master node and partition information of a storage partition corresponding to the master node when detecting an abnormality in the master node of the database; A first determination module, used to determine the strategy type of the node switching strategy; A second judgment module is used to judge whether the storage partition corresponding to the master node meets the node switching condition according to the partition information of the storage partition when the node switching strategy is a high reliability strategy; The switching module is used to execute a switching operation corresponding to the node switching strategy on the master node when the storage partition meets the node switching condition.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the exception handling method based on a multi-node database according to any one of claims 1 to 7 are implemented.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the exception handling method based on a multi-node database according to any one of claims 1 to 7 are implemented.