Database fault processing method, system, device and readable storage medium
By configuring adapted fault determination and processing strategies for different types of databases, the problem of inflexible fault determination of relational databases in the prior art is solved, and flexible processing of multiple fault types of master and slave databases is realized, and the application scope is expanded.
Patent Information
- Application Number
- CN202111178101.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-09
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2041-10-09
AI Technical Summary
In the prior art, the fault determination strategy of relational databases is unified and not flexible enough to effectively solve various fault types of master-slave databases, and the application scope is narrow.
Configure the respective adapted fault determination policies for different types of databases, and determine the target fault type based on the fault information, select the corresponding fault handling strategy to achieve flexible fault determination and processing.
It realizes flexible determination and handling of different types of database failures, expands the scope of application, and ensures high database availability.
Smart Images

Figure CN113900858B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of databases, and in particular to a database fault handling method, system, device, and readable storage medium. Background Art
[0002] Relational databases (such as MySQL and Oracle) are widely used in the IT (Internet Technology) sector. They are primarily used to store core IT business data, and their high availability directly impacts the continuity of IT business.
[0003] Currently, a master-slave database system is often used to improve overall database high availability. This high availability is achieved by having the master and slave databases serve as backups of each other, storing the same data. When the master database is functioning properly, it provides access to the business. If the master database fails, access is switched to the slave database, allowing business to recover.
[0004] However, the existing solution can only solve the failure of the master database and the normal operation of the slave database, and has a narrow application scope. In addition, the fault judgment strategy for all databases is unified, resulting in insufficient flexibility in fault judgment.
[0005] Therefore, how to provide a solution to the above technical problems is a problem that technicians in this field currently need to solve. Summary of the Invention
[0006] The purpose of this application is to provide a database fault handling method, system, device and readable storage medium, which configures fault judgment strategies that are adapted to different databases, thereby making fault judgment more flexible; and this application configures fault handling strategies that are adapted to different fault types under the master-slave database architecture, thereby solving different types of faults and having a wide range of applications.
[0007] To solve the above technical problems, this application provides a database fault handling method, including:
[0008] According to the preset database and fault judgment strategy adaptation relationship, select the target fault judgment strategy that is adapted to the master and slave databases to be fault detected;
[0009] Determining whether the master-slave database is faulty according to the target fault determination strategy;
[0010] If so, the target fault type to which it belongs is determined based on the fault information of the master-slave database, and the target fault handling strategy adapted to the target fault type is determined based on the preset fault type and fault handling strategy adaptation relationship, so as to perform fault handling on the master-slave database according to the target fault handling strategy.
[0011] Optionally, the preset process of the adaptation relationship between the database and the fault determination strategy includes:
[0012] Configure fault determination strategies that are tailored to different types of databases; the fault determination strategies for databases of the same type are the same.
[0013] Optionally, the preset process of the adaptation relationship between the database and the fault determination strategy includes:
[0014] According to the customized fault judgment index of the database, an adaptive fault judgment strategy is customized for the database.
[0015] Optionally, according to the customized fault judgment index of the database, a fault judgment strategy adapted to the database is customized, including:
[0016] Determine a customized index based on the data combination in the database, and configure a determination condition for each customized data under the customized index;
[0017] The determination conditions of the customized data are combined to obtain a fault determination strategy for the database.
[0018] Optionally, according to a customized index determined by combining data in a database, configuring a determination condition for each customized data under the customized index determined by combining data; and combining the determination conditions of each customized data to obtain a fault determination strategy for the database, including:
[0019] Output display interface; wherein, the display interface displays a plurality of judgment parameters to be selected associated with the data combination judgment customized index of the database and parameter fault indicators corresponding to each of the plurality of judgment parameters;
[0020] receiving a selection instruction from a user, and selecting a target judgment parameter and its corresponding target parameter fault indicator from the plurality of judgment parameters according to the selection instruction;
[0021] A fault determination strategy for the database is generated according to the target determination parameter and the target parameter fault indicator.
[0022] Optionally, determining whether the master-slave database is faulty according to the target fault determination strategy includes:
[0023] Determining a target fault detection frequency that is compatible with the type of the master-slave database according to a preset database type-fault detection frequency adaptation relationship;
[0024] An operation of determining whether the master-slave database has a fault according to the target fault determination strategy is performed according to the target fault detection frequency.
[0025] Optionally, the preset process of the adaptation relationship between the fault type and the fault handling strategy includes:
[0026] When the fault type of the master-slave database is that the master database fails and the slave database is normal, the original slave database works as the new master database, and the original master-slave relationship between the original master database and the original slave database is terminated;
[0027] The failed original master database is restored, and the restored original master database is used as a new slave database to establish a new master-slave relationship between the new master database and the new slave database.
[0028] Optionally, the preset process of the adaptation relationship between the fault type and the fault handling strategy includes:
[0029] When the fault type of the master-slave database is that the master database is normal and the slave database is faulty, the master-slave relationship between the master database and the slave database is terminated;
[0030] Perform recovery processing on the failed slave database, and after the slave database is recovered, restore the master-slave relationship between the master database and the slave database.
[0031] Optionally, the preset process of the adaptation relationship between the fault type and the fault handling strategy includes:
[0032] When the failure type of the master-slave database is that both the master database and the slave database fail, the master-slave relationship between the master database and the slave database is terminated, and the failed master database is restored;
[0033] After the master database is restored, the failed slave database is restored;
[0034] After the slave database is restored, the master-slave relationship between the master database and the slave database is restored.
[0035] Optionally, recover the failed target database, including:
[0036] Determining a target recovery strategy that is compatible with the recovery environment of the target database based on a preset database recovery environment and recovery strategy adaptation relationship;
[0037] The target database is restored according to the target recovery strategy.
[0038] To solve the above technical problems, the present application also provides a database fault handling system, including:
[0039] A selection module is used to select a target fault determination strategy that is adapted to the master and slave databases to be detected for fault detection according to a preset adaptation relationship between the database and the fault determination strategy;
[0040] a determination module, configured to determine whether the master-slave database is faulty according to the target fault determination strategy; and if so, execute a processing module;
[0041] A processing module is used to determine the target fault type to which the fault information of the master-slave database belongs based on the fault information, and determine the target fault handling strategy adapted to the target fault type based on the preset adaptation relationship between the fault type and the fault handling strategy, so as to perform fault handling on the master-slave database according to the target fault handling strategy.
[0042] To solve the above technical problems, the present application also provides a database fault handling device, comprising:
[0043] Memory for storing computer programs;
[0044] A processor is configured to implement the steps of any of the above-mentioned database fault handling methods when executing the computer program.
[0045] To solve the above technical problems, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above database fault handling methods are implemented.
[0046] The present invention provides a database fault handling method, which selects a target fault judgment strategy that is adapted for the master and slave databases to be fault-detected based on a preset database and fault judgment strategy adaptation relationship; determines whether the master and slave databases are faulty based on the target fault judgment strategy; and if so, determines the target fault type to which it belongs based on the fault information of the master and slave databases, and determines a target fault handling strategy that is adapted to the target fault type based on a preset fault type and fault handling strategy adaptation relationship, so as to perform fault handling on the master and slave databases based on the target fault handling strategy. It can be seen that the present application configures fault judgment strategies that are adapted to different databases, thereby making fault judgment more flexible; and the present application configures fault handling strategies that are adapted to different fault types under the master-slave database architecture, thereby being able to solve different types of faults and having a wide range of applications.
[0047] The present invention also provides a database fault handling system, device and readable storage medium, which have the same beneficial effects as the above fault handling method. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the prior art and the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 A flowchart of a database fault handling method provided in an embodiment of the present application;
[0050] Figure 2 A schematic diagram of a database fault determination method provided in an embodiment of the present application;
[0051] Figure 3 A flowchart for recovering a master failure in a MySQL master-slave scenario provided in an embodiment of the present application;
[0052] Figure 4 A flowchart for recovering a MySQL master-slave scenario in which both the master and the slave fail, provided in an embodiment of the present application;
[0053] Figure 5 A schematic diagram of a fault database recovery method provided in an embodiment of the present application;
[0054] Figure 6 A schematic diagram of the structure of a database fault handling system provided in an embodiment of the present application;
[0055] Figure 7 A schematic diagram of the structure of a database fault handling device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The core of this application is to provide a database fault handling method, system, device and readable storage medium, which configures fault judgment strategies that are adapted to different databases, thereby making fault judgment more flexible; and this application configures fault handling strategies that are adapted to different fault types under the master-slave database architecture, thereby solving different types of faults and having a wide range of applications.
[0057] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0058] Please refer to Figure 1 , Figure 1 A flowchart of a database fault handling method provided in an embodiment of the present application.
[0059] The database fault handling method includes:
[0060] Step S1: According to the preset adaptation relationship between the database and the fault determination strategy, a target fault determination strategy that is adapted to the master and slave databases to be detected for fault detection is selected.
[0061] Specifically, this application pre-configures the adaptation relationship between databases and fault determination strategies. This means pre-configuring fault determination strategies that are tailored to different databases, providing a basis for subsequent database fault determination for master and slave databases. It should be noted that different databases refer to databases for different business purposes, such as account databases and backend service databases; fault determination strategies refer to scripts, executable files, and code blocks used to implement fault determination. These scripts, executable files, and code blocks used to implement fault determination include parameter names, parameter values, and execution functions.
[0062] Based on this, the present application selects a target fault determination strategy that matches the master and slave databases to be fault-detected, based on the preset database-fault determination strategy adaptation relationship. It will be understood that the master-slave database includes a master database and a slave database, and selecting a target fault determination strategy that matches the master and slave databases specifically involves selecting a fault determination strategy that matches both the master database and the slave database, so as to subsequently determine the fault status of the master and slave databases.
[0063] Step S2: Determine whether the master and slave databases are faulty based on the target fault determination strategy; if so, proceed to step S3. Step S3: Determine the target fault type based on the fault information of the master and slave databases, and determine the target fault handling strategy that matches the target fault type based on the preset fault type-fault handling strategy adaptation relationship, so as to perform fault handling on the master and slave databases according to the target fault handling strategy.
[0064] Specifically, this application pre-configures the adaptation relationship between the fault types and fault handling strategies of the master and slave databases. This means that each fault handling strategy is pre-configured for each fault type in the master and slave databases, providing a basis for subsequent handling of different types of faults in the master and slave databases. It should be noted that the fault handling strategy refers to the scripts, executable files, and code blocks used to implement fault handling. These scripts, executable files, and code blocks used to implement fault handling include parameter names, parameter values, and execution functions.
[0065] Based on this, after selecting a target fault judgment strategy that is compatible with the master-slave database, the present application determines whether the master-slave database is faulty according to the selected target fault judgment strategy; if the judgment result is a master-slave database fault (such as a master database fault and / or a slave database fault and / or a master-slave synchronization fault, etc.), the target fault type to which the master-slave database belongs is determined based on the fault information of the master-slave database, and the target fault handling strategy that is compatible with the target fault type is determined based on the preset adaptation relationship between the fault type and the fault handling strategy, so as to perform fault handling on the master-slave database according to the determined target fault handling strategy; if the judgment result is that there is no fault in the master-slave database, there is no need to perform fault handling on the master-slave database.
[0066] It can be seen that the present application configures fault judgment strategies that are adapted to different databases, thereby making fault judgment more flexible; and the present application configures fault handling strategies that are adapted to different fault types under the master-slave database architecture, thereby being able to solve different types of faults and having a wide range of applications.
[0067] Based on the above embodiment:
[0068] As an optional embodiment, the preset process of the adaptation relationship between the database and the fault determination strategy includes:
[0069] Configure fault determination strategies that are tailored to different types of databases; the fault determination strategies for databases of the same type are the same.
[0070] Specifically, the first preset process for adapting the database to the fault determination strategy in this application includes configuring a fault determination strategy adapted to the database type. This means that different types of databases are configured with their own adapted fault determination strategies, while databases of the same type have the same fault determination strategy. It should be noted that the database types mentioned in this application are categorized by their business purpose, such as account databases, backend service databases, and other types.
[0071] More specifically, the present application may utilize a DMP (Data Management Platform) to implement a fault determination strategy adapted to the database configuration according to the type of database.
[0072] As an optional embodiment, the preset process of the adaptation relationship between the database and the fault determination strategy includes:
[0073] According to the customized fault judgment indicators of the database, a fault judgment strategy suitable for the database is customized.
[0074] Specifically, the second preset process of the adaptation relationship between the database and the fault judgment strategy of the present application includes: customizing the fault judgment strategy for the database, specifically customizing the adapted fault judgment strategy for the database based on the fault judgment customization index of the database.
[0075] It should be noted that the database and fault determination strategy adaptation relationship of this application can set the above two adaptation relationships at the same time, and one of the adaptation relationships can be selected for application according to the fault determination strategy configuration requirements. Figure 2 As shown, according to the fault judgment strategy configuration requirements, an adaptation relationship is selected from the DMP platform adaptation relationship and the customized adaptation relationship to configure a fault judgment strategy adapted to the target DB (Data Base) to be detected for use.
[0076] As an optional embodiment, a fault determination strategy adapted to the database is customized based on the database's fault determination customization index, including:
[0077] Determine the customized index based on the data combination of the database, and configure the determination conditions for each customized data under the customized index;
[0078] The judgment conditions of each customized data are combined to obtain the fault judgment strategy of the database.
[0079] Specifically, the present application can customize a fault judgment strategy for the database based on multiple data related to the database. Specifically, it can determine the customized indicators based on the data combination of the database, configure judgment conditions for each customized data under the data combination determination customized indicators, and then combine the judgment conditions of each customized data to obtain the fault judgment strategy of the database.
[0080] As an optional embodiment, according to the database data combination determination customization index, a determination condition is configured for each customized data under the data combination determination customization index; the determination conditions of each customized data are combined to obtain a database fault determination strategy, including:
[0081] Output display interface; wherein the display interface displays a plurality of judgment parameters to be selected associated with the database data combination judgment customized index and parameter fault indicators corresponding to the plurality of judgment parameters;
[0082] receiving a selection instruction from a user, and selecting a target judgment parameter and its corresponding target parameter fault indicator from a plurality of judgment parameters according to the selection instruction;
[0083] A fault judgment strategy for the database is generated based on the target judgment parameters and the target parameter fault indicators.
[0084] Specifically, the present application may output a display interface that provides the user with multiple selectable judgment parameters and parameter fault indicators corresponding to each of the multiple judgment parameters. The user selects at least one judgment parameter and its corresponding parameter fault indicator, and then a fault judgment strategy for the database is generated based on the judgment parameter and its corresponding parameter fault indicator selected by the user.
[0085] For example, a user selects two judgment parameters, namely, the database's QPS (Queries Per Second) and the CPU (Central Processing Unit) usage rate on the host where the database is located, as a custom database fault judgment strategy. The parameter fault indicator corresponding to QPS is: QPS is greater than a query rate threshold (e.g., database specifications * 10000, a specific value can be selected on the display interface) and the phenomenon persists for a first time (e.g., 5 minutes, a specific value can be selected on the display interface); the parameter fault indicator corresponding to CPU is: CPU usage is greater than a usage threshold (e.g., 90%, a specific value can be selected on the display interface) and the phenomenon persists for a second time (e.g., 5 minutes, a specific value can be selected on the display interface). The database fault judgment strategy is: a database fault is determined when the database's QPS is greater than the selected query rate threshold and the phenomenon persists for the selected first time, and when the CPU usage rate on the host where the database is located is greater than the selected usage threshold and the phenomenon persists for the selected second time.
[0086] Of course, this application can also customize the fault judgment strategy for the database based on the custom scripts developed by the user himself (such as shell scripts or python scripts). For example, for the user center database, the database is considered to be faulty when the database request duration exceeds the preset duration threshold (such as 1s); for the report database, the database is considered to be faulty only when the database connection is unavailable. In other scenarios, the database is considered to be fault-free.
[0087] As an optional embodiment, determining whether the master and slave databases are faulty according to the target fault determination strategy includes:
[0088] According to the preset database type and fault detection frequency adaptation relationship, determine the target fault detection frequency adapted to the type of the master and slave databases;
[0089] An operation of determining whether the master and slave databases are faulty according to a target fault determination strategy is performed according to a target fault detection frequency.
[0090] Specifically, this application pre-configures the adaptation relationship between database type and fault detection frequency. This means that different types of databases are pre-configured with their own adaptive fault detection frequencies. Databases of the same type have the same fault detection frequency, providing a basis for subsequent cyclic detection of faults in the master and slave databases. For example, a fault detection frequency of 5 seconds is configured for account databases, meaning database faults are detected every 5 seconds; and a fault detection frequency of 1 minute is configured for backend service databases, meaning database faults are detected every 1 minute.
[0091] Based on this, the present application determines a target fault detection frequency that matches the type of the master-slave database (the type of the master-slave database is equivalent to the master database type and also to the slave database type, because the master and slave database types are the same) based on the preset database type and fault detection frequency adaptation relationship. Then, according to the determined target fault detection frequency, the operation of determining whether the master and slave databases are faulty according to the target fault determination strategy is executed. For example, if the target fault detection frequency is 5 seconds, the operation of determining whether the master and slave databases are faulty according to the target fault determination strategy is executed every 5 seconds.
[0092] More specifically, when this application selects a DMP platform adaptation relationship application, it can use the DMP platform to perform operations to determine whether the master and slave databases are faulty based on the target fault determination strategy. Based on this, this application has modified the DMP platform's open source orchestrator (database management tool) to support configuring different database types with different fault detection frequencies, and supports the default fault detection frequency of 5 seconds.
[0093] As an optional embodiment, the preset process of the adaptation relationship between the fault type and the fault handling strategy includes:
[0094] When the master-slave database fails and the slave database is normal, the original slave database will be used as the new master database, and the original master-slave relationship between the original master database and the original slave database will be terminated.
[0095] The failed original master database is restored, and the restored original master database is used as the new slave database to establish a new master-slave relationship between the new master database and the new slave database.
[0096] Specifically, when the failure type of the master-slave database is that the master database fails and the slave database is normal, the failure handling strategy adapted to this failure type is (taking the target master-slave database including the target master database and the target slave database as an example): the normal original target slave database is used as the new target master database, and the original master-slave relationship between the original target master database and the original target slave database is released to restore the business, and then the failed original target master database is restored, and the restored original target master database is used as the new target slave database to establish a new master-slave relationship between the new target master database and the new target slave database, that is, the master-slave relationship of the original target master-slave database is exchanged to ensure the high availability of the database.
[0097] For example, Figure 3 As shown in the figure (VIP: Virtual IP used by the database in the master-slave architecture, used to provide business access), taking the MySQL master-slave scenario as an example, where the master node fails and the slave node is normal, the entire recovery process is as follows: ① Master node fails, switch to the slave node to restore business; ② Self-heal the failed node (the original master node); ③ The self-healed failed node is used as a slave node and added to the new master node.
[0098] As an optional embodiment, the preset process of the adaptation relationship between the fault type and the fault handling strategy includes:
[0099] When the master-slave database failure type is that the master database is normal and the slave database is faulty, the master-slave relationship between the master database and the slave database is terminated;
[0100] Recover the failed slave database, and after the slave database recovers, restore the master-slave relationship between the master database and the slave database.
[0101] Specifically, when the failure type of the master-slave database is that the master database is normal and the slave database is faulty, the fault handling strategy adapted to this failure type is (taking the target master-slave database including the target master database and the target slave database as an example): cancel the master-slave relationship between the target master database and the target slave database to avoid the failure of the target slave database affecting the operation of some businesses, and then recover the faulty target slave database. After the target slave database is recovered, restore the master-slave relationship between the target master database and the target slave database to ensure the high availability of the database.
[0102] As an optional embodiment, the preset process of the adaptation relationship between the fault type and the fault handling strategy includes:
[0103] When the master-slave database failure type is that both the master database and the slave database fail, the master-slave relationship between the master database and the slave database is terminated, and the failed master database is restored;
[0104] After the master database is restored, the failed slave database is restored;
[0105] After the slave database is restored, restore the master-slave relationship between the master database and the slave database.
[0106] Specifically, when the failure type of the master-slave database is that both the master database and the slave database fail, the failure handling strategy adapted to this failure type is (taking the target master-slave database including the target master database and the target slave database as an example): cancel the master-slave relationship between the target master database and the target slave database, first restore the failed target master database to restore the business, and then restore the failed target slave database after the target master database is restored; after the target slave database is restored, restore the master-slave relationship between the target master database and the target slave database to ensure the high availability of the database.
[0107] In addition to the three failure types mentioned above, there are other types of master-slave database failures, such as master-slave database synchronization errors. The appropriate fault handling strategy for this type of failure is to repair the master-slave database synchronization issue to prevent core business functions from being affected. It should also be noted that when any database fails, it must be removed from the cluster topology of all databases in the system to break the master-slave relationship associated with it. Once the database recovers, it must be added back to the cluster topology to restore the original master-slave relationship or re-establish a new one.
[0108] In summary, the troubleshooting for different fault types of master and slave databases is shown in Table 1 below:
[0109] Table 1
[0110]
[0111] Here we take the MySQL master and slave failure as an example to explain the specific process of troubleshooting (refer to Figure 4 , with rollback operation): If the detected cluster (the topology structure composed of all databases in the system) is not in suspend (pause) or intermediate state (the state in which the cluster is being repaired), the cluster state is changed to no candidate (no election state); the status of the master node host is queried; if the host status is abnormal, the master node is restarted, the master node MySQL is started, the master node is set to writable, semi-synchronization is enabled, the slave node is added to the lost_instances_list (lost instance list), the cluster topology information is set, the load node pool is updated, the cluster state is updated, and the MySQL configuration file is set; if the host status is normal, further judgment is made on whether the MySQL service is normal and whether the parameters are correct; if the judgment result contains a negative result, the database fault self-healing process is entered.
[0112] As an optional embodiment, recovering the failed target database includes:
[0113] Determine the target recovery strategy that is compatible with the recovery environment of the target database based on the preset database recovery environment and recovery strategy adaptation relationship;
[0114] Recover the target database according to the target recovery strategy.
[0115] Specifically, this application pre-sets the adaptation relationship between the database recovery environment and the recovery strategy, that is, pre-configures the database recovery strategy adapted to the database in different recovery environments, making fault recovery more flexible. It should be noted that the database recovery environment refers to the application field to which the database belongs and the recovery purpose of the database in the application field to which it belongs (such as changing the configuration parameters of the account database). The recovery strategy refers to the scripts, executable files, and code blocks used to implement database recovery, among which the scripts, executable files, and code blocks used to implement database recovery include parameter names, parameter values, execution functions, etc.
[0116] Based on this, this application determines the target recovery strategy that is adapted to the recovery environment of the target database (the master database or slave database of the above-mentioned failure) according to the preset database recovery environment and recovery strategy adaptation relationship, so as to restore the target database according to the determined target recovery strategy.
[0117] For example, Figure 5 As shown, this application can set two types of recovery strategies: the DMP platform's default recovery strategy and a custom recovery strategy. Based on these two types of recovery strategies, the database recovery environment and recovery strategy adaptation relationship are set. Specifically, the DMP platform's default recovery strategy can achieve fixed database recovery objectives. If the user wants to achieve a database recovery objective other than the DMP platform's default recovery strategy, a custom recovery strategy must be defined. For example, the DMP platform's default recovery strategy cannot achieve the recovery objective of changing the configuration parameters of an account-related database, and can only be achieved using a custom recovery strategy.
[0118] In summary, this application provides the ability to customize fault types, process fault handling, and self-heal fault nodes, with high coverage scenario integrity.
[0119] Please refer to Figure 6 , Figure 6 A schematic diagram of the structure of a database fault handling system provided in an embodiment of the present application.
[0120] The database fault handling system includes:
[0121] Selection module 1, for selecting a target fault determination strategy that is adapted to the master and slave databases to be detected for fault detection according to a preset adaptation relationship between the database and the fault determination strategy;
[0122] Determination module 2 is used to determine whether the master and slave databases are faulty according to the target fault determination strategy; if so, processing module 3 is executed;
[0123] Processing module 3 is used to determine the target fault type according to the fault information of the master-slave database, and determine the target fault handling strategy adapted to the target fault type according to the preset adaptation relationship between the fault type and the fault handling strategy, so as to perform fault handling on the master-slave database according to the target fault handling strategy.
[0124] For an introduction to the fault handling system provided in this application, please refer to the embodiment of the above-mentioned fault handling method, and this application will not go into details here.
[0125] Please refer to Figure 7 , Figure 7 A schematic diagram of the structure of a database fault handling device provided in an embodiment of the present application.
[0126] The database fault processing device includes:
[0127] Memory 4, for storing computer programs;
[0128] The processor 5 is configured to implement the steps of any one of the above database fault handling methods when executing a computer program.
[0129] For an introduction to the fault handling device provided in this application, please refer to the embodiment of the above-mentioned fault handling method, and this application will not go into details here.
[0130] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned database fault handling methods are implemented.
[0131] For an introduction to the readable storage medium provided in this application, please refer to the embodiment of the above-mentioned fault handling method, and this application will not go into details here.
[0132] It should also be noted that, in this specification, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
[0133] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A database fault handling method, characterized in that: include: According to the preset database and fault judgment strategy adaptation relationship, select the target fault judgment strategy that is adapted to the master and slave databases to be fault detected; Determining whether the master-slave database is faulty according to the target fault determination strategy; If so, determining the target fault type according to the fault information of the master-slave database, and determining a target fault handling strategy adapted to the target fault type according to a preset adaptation relationship between the fault type and the fault handling strategy, so as to perform fault handling on the master-slave database according to the target fault handling strategy; The adaptation relationship between the fault type and the fault handling strategy includes a preset process or a combination of any multiple preset processes, and the preset process includes: When the failure type of the master-slave database is that the master database fails and the slave database is normal, the original slave database is used as the new master database, and the original master-slave relationship between the original master database and the original slave database is terminated; the failed original master database is restored, and the restored original master database is used as the new slave database to establish a new master-slave relationship between the new master database and the new slave database; When the fault type of the master-slave database is that the master database is normal and the slave database is faulty, the master-slave relationship between the master database and the slave database is terminated; the faulty slave database is restored, and after the slave database is restored, the master-slave relationship between the master database and the slave database is restored; When the fault type of the master-slave database is that both the master database and the slave database fail, the master-slave relationship between the master database and the slave database is terminated, and the failed master database is restored; after the master database is restored, the failed slave database is restored; after the slave database is restored, the master-slave relationship between the master database and the slave database is restored; When master-slave database synchronization errors occur, fix the synchronization issues between the master and slave databases.
2. The database fault handling method according to claim 1, wherein: The preset process of the adaptation relationship between the database and the fault determination strategy includes: Configure fault determination strategies that are tailored to different types of databases; the fault determination strategies for databases of the same type are the same.
3. The database fault handling method according to claim 1, wherein: The preset process of the adaptation relationship between the database and the fault determination strategy includes: According to the customized fault judgment index of the database, an adaptive fault judgment strategy is customized for the database.
4. The database fault handling method according to claim 3, wherein: According to the customized fault judgment indicators of the database, a fault judgment strategy adapted to the database is customized, including: Determine a customized index based on the data combination in the database, and configure a determination condition for each customized data under the customized index; The determination conditions of the customized data are combined to obtain a fault determination strategy for the database.
5. The database fault handling method according to claim 4, characterized in that: Determine a customized index based on the data combination in the database, and configure a determination condition for each customized data under the customized index; Combining the determination conditions of the customized data to obtain the fault determination strategy of the database includes: Output display interface; wherein, the display interface displays a plurality of judgment parameters to be selected associated with the data combination judgment customized index of the database and parameter fault indicators corresponding to each of the plurality of judgment parameters; receiving a selection instruction from a user, and selecting a target judgment parameter and its corresponding target parameter fault indicator from the plurality of judgment parameters according to the selection instruction; A fault determination strategy for the database is generated according to the target determination parameter and the target parameter fault indicator.
6. The database fault handling method according to claim 1, wherein: Determining whether the master-slave database is faulty according to the target fault determination strategy includes: Determining a target fault detection frequency that is compatible with the type of the master-slave database according to a preset database type-fault detection frequency adaptation relationship; An operation of determining whether the master-slave database has a fault according to the target fault determination strategy is performed according to the target fault detection frequency.
7. The database fault handling method according to claim 1, wherein: Recover the failed target database, including: Determining a target recovery strategy that is compatible with the recovery environment of the target database based on a preset database recovery environment and recovery strategy adaptation relationship; The target database is restored according to the target recovery strategy.
8. A database fault handling system, characterized in that: include: A selection module is used to select a target fault determination strategy that is adapted to the master and slave databases to be detected for fault detection according to a preset adaptation relationship between the database and the fault determination strategy; a determination module, configured to determine whether the master-slave database is faulty according to the target fault determination strategy; and if so, execute a processing module; a processing module, configured to determine a target fault type according to the fault information of the master-slave database, and determine a target fault handling strategy adapted to the target fault type according to a preset adaptation relationship between the fault type and the fault handling strategy, so as to perform fault handling on the master-slave database according to the target fault handling strategy; The adaptation relationship between the fault type and the fault handling strategy includes a preset process or a combination of any multiple preset processes, and the preset process includes: When the failure type of the master-slave database is that the master database fails and the slave database is normal, the original slave database is used as the new master database, and the original master-slave relationship between the original master database and the original slave database is terminated; the failed original master database is restored, and the restored original master database is used as the new slave database to establish a new master-slave relationship between the new master database and the new slave database; When the fault type of the master-slave database is that the master database is normal and the slave database is faulty, the master-slave relationship between the master database and the slave database is terminated; the faulty slave database is restored, and after the slave database is restored, the master-slave relationship between the master database and the slave database is restored; When the fault type of the master-slave database is that both the master database and the slave database fail, the master-slave relationship between the master database and the slave database is terminated, and the failed master database is restored; after the master database is restored, the failed slave database is restored; after the slave database is restored, the master-slave relationship between the master database and the slave database is restored; When master-slave database synchronization errors occur, fix the synchronization issues between the master and slave databases.
9. A database fault processing device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the database fault handling method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the database fault handling method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for switching between master node and standby node
CN104679604A
Database read-write method and related device
CN111078802A