Redis Cluster cluster data center fault switching isolation method and system

By setting primary priority and secondary priority data centers in multiple data centers of the Redis Cluster cluster, and automatically switching the primary node according to the fault type, the split-brain problem during cross-data center failover is solved and the stability of the cluster is improved. and availability.

CN118503022BActive Publication Date: 2024-10-18E SURFING VISION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410953470.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-10-18
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

When the existing Redis Cluster cluster is deployed across multiple data centers, if the master nodes of the same Redis Cluster set are distributed in different data centers, network failure may cause brain splitting, and when the master nodes are distributed in different data centers, the data center Network abnormalities or host failures prevent the cluster from being able to switch quickly.

Method used

By deploying primary priority and secondary priority data centers in multiple data centers, the number of master nodes in the primary priority data center is greater than or equal to the set threshold, and the number of primary nodes in the secondary priority data center is less than the set threshold, and the cluster node information is obtained , determine the fault type, and when the main priority data center fails, automatically switch the main node to the fault-free sub-priority data center to complete failover and isolation.

Benefits of technology

This avoids split-brain when the Redis Cluster cluster fails to switch across data centers, improves the cluster's fast switching capability when a data center-level failure occurs, and improves the overall availability and stability of the Redis Cluster cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503022B_ABST
    Figure CN118503022B_ABST
Patent Text Reader

Abstract

The present application relates to a Redis Cluster cluster data center fault switching isolation method and system. The method includes: arranging the master node in the same data center, based on which the cluster node information of the Redis Cluster cluster is obtained and classified according to different data centers, determining the node fault status and the number of node faults of each data center; judging the fault type of each data center according to the node fault status and the number of node faults; when the primary priority data center is the first fault type, sending a first switching instruction to all slave nodes of the non-faulty secondary priority data center, switching all master nodes of the primary priority data center to the non-faulty secondary priority data center. This method avoids brain splits when the cluster fails over across data centers, improves the cluster's ability to quickly switch when a data center-level fault occurs, and improves the overall availability and stability of the cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a Redis Cluster cluster data center fault switching isolation method and system. Background Art

[0002] The Redis system is widely used as a database cache in the Internet and cloud computing. However, with the development of business scale, the amount of data is getting larger and larger. The single write of the Redis master-slave architecture has a bottleneck, the hardware is difficult to expand, and saving a large amount of data will lead to slow response and delay. Therefore, the Redis Cluster cluster solution was launched to mainly solve the problem of slow response caused by massive data storage.

[0003] However, when the existing Redis Cluster is deployed across multiple data centers, if the master nodes of the same RedisCluster are distributed in different data centers, when the network link between the data centers fails, network partition may occur, resulting in split-brain. And because the master nodes are distributed in different data centers, when the network of the data center where all the master nodes are distributed is abnormal or the host fails, the cluster cannot be switched quickly. Summary of the invention

[0004] Based on this, it is necessary to provide a Redis Cluster cluster data center fault switching isolation method and system to address the above technical problems, which can avoid brain splits during Redis Cluster cross-data center fault switching and improve the rapid switching capability of computer room-level fault clusters.

[0005] In a first aspect, the present application provides a Redis Cluster cluster data center failover isolation method, wherein the nodes of the Redis Cluster cluster are deployed in multiple data centers, and the multiple data centers include a primary priority data center and a secondary priority data center, wherein the number of master nodes in the primary priority data center is greater than or equal to a set threshold, and the number of master nodes in the secondary priority data center is less than the set threshold, and the method includes:

[0006] Obtain cluster node information of the Redis Cluster cluster, and classify the cluster node information according to different data centers, and determine the node failure status and the number of node failures of each data center;

[0007] Determining the fault type of each of the data centers according to the node fault state and the number of node faults;

[0008] In the case where the main priority data center is of the first fault type, a first switching instruction is sent to all slave nodes of the fault-free secondary priority data center, and all master nodes of the main priority data center are automatically switched to the fault-free secondary priority data center to complete the fault switching.

[0009] In one embodiment, judging the failure type of each data center according to the node failure state and the number of node failures includes:

[0010] If the number of failed master nodes of the primary priority data center accounts for more than half of the number of all master nodes, and the number of failed master and slave nodes of the primary priority data center is less than the total number of all master and slave nodes, then the primary priority data center is determined to be of the first failure type; or

[0011] If the number of failed master and slave nodes of the main priority data center is the same as the number of all master and slave nodes, and the nodes in the secondary priority data center associated with the master and slave nodes of the main priority data center are failed nodes, then the main priority data center is determined to be of the first failure type.

[0012] In one of the embodiments, when the primary priority data center is of the second fault type, a second switching instruction is sent to the fault-free secondary priority data center to switch all the master nodes of the primary priority data center to the fault-free secondary priority data center to complete the fault switching; and / or a disconnection instruction is sent to all the master nodes of the primary priority data center at the same time to control all the master nodes of the primary priority data center to shut down node instances to complete fault isolation.

[0013] In one embodiment, judging the failure type of the primary priority data center according to the node failure state and the number of node failures includes:

[0014] If the exchange between the main priority data center and the external application network is abnormal, the overall cluster status displayed by the main priority data center is normal, and the node failure status of all nodes in the cluster is normal, then the main priority data center is determined to be the second failure type; or if the exchange between the main priority data center and the external application network is abnormal, the overall cluster status displayed by the main priority data center is normal, and the overall cluster status displayed by the secondary priority data center is abnormal, then the main priority data center is determined to be the second failure type.

[0015] In one of the embodiments, if the primary priority data center has a first fault type and a second fault type, a third switching instruction is sent to all slave nodes of the non-faulty secondary priority data center to switch the master node of the primary priority data center to the non-faulty secondary priority data center.

[0016] In one of the embodiments, after the primary priority data center has the first fault type and the second fault type and the master node of the primary priority data center is switched to the fault-free secondary priority data center, the method further includes: obtaining a first fault recovery time and a second fault recovery time corresponding to the first fault type and the second fault type, respectively; if the first fault recovery time is greater than the second fault recovery time, not controlling all master nodes of the primary priority data center to shut down node instances; if the first fault recovery time is less than the second fault recovery time, controlling all master nodes of the primary priority data center to perform isolation operations.

[0017] In one of the embodiments, if there is at least one faulty master node randomly in the primary priority data center, the Redis Cluster cluster performs automatic fault-tolerant switching, and after switching the first fault-free slave node of other secondary priority data centers to the corresponding update master node, the method further includes: judging whether there is a switchable second fault-free slave node in the current primary priority data center according to the current priority relationship of multiple data centers, and if so, automatically switching the second fault-free slave node to the update master node, and controlling the number of master nodes of the current primary priority data center to be greater than or equal to a set threshold; otherwise, obtaining the data center with the most master nodes, judging whether the data center with the most master nodes is a different data center from the current primary priority data center, and if so, updating the current priority relationship, and the data center with the most master nodes is the update primary priority data center; if the update primary priority data center is the secondary priority data center that originally contained the first fault-free slave node, stopping the automatic switching of the update master node; otherwise, obtaining the cluster node information of the update primary priority data center, judging whether there is a switchable third fault-free slave node in the update primary priority data center, and if so, automatically switching the third fault-free slave node to the update master node, and controlling the number of master nodes of the update primary priority data center to be greater than or equal to the set threshold.

[0018] In one of the embodiments, if multiple slave nodes across data centers simultaneously initiate synchronous replication requests, the method further includes: obtaining the dedicated line bandwidth utilization rate between each data center, and determining whether to perform flow control on each data center based on the growth rate or average utilization rate of the dedicated line bandwidth utilization rate within a first set time.

[0019] In one of the embodiments, the flow control of each data center includes: sending a flow limiting dynamic script file to the master node that executes flow limiting in the corresponding data center, and the master node that executes flow limiting uses the flow limiting dynamic script to limit the flow of the target IP and output port of the slave node that initiates the synchronous replication request, and generates log information after completion; obtaining the update dedicated line bandwidth utilization rate between each data center, and sending the clear flow limiting script file to the master node that executes flow limiting based on the decrease rate of the update dedicated line bandwidth utilization rate within the second set time and the log information, thereby ending the flow limiting.

[0020] In the second aspect, the present application also provides a Redis Cluster cluster data center fault switching isolation system, the system includes a Redis Cluster cluster, a cluster status monitoring module, and a cluster management control module; the nodes of the RedisCluster cluster are deployed in multiple data centers, and the multiple data centers include a primary priority data center and a secondary priority data center, wherein the number of master nodes in the primary priority data center is greater than or equal to a set threshold, and the number of master nodes in the secondary priority data center is much less than the set threshold;

[0021] The cluster status monitoring module is used to obtain the cluster node information of the Redis Cluster cluster, and classify the cluster node information according to different data centers, determine the node failure status and the number of node failures of each data center; according to the node failure status and the number of node failures, determine the failure type of each data center;

[0022] The cluster management control module is used to send a first switching instruction to all slave nodes of the non-faulty secondary priority data center when the primary priority data center is of the first fault type, and automatically switch all master nodes of the primary priority data center to the non-faulty secondary priority data center to complete the fault switching.

[0023] The above-mentioned Redis Cluster cluster data center fault switching isolation method and system, by arranging the master nodes in the same data center as much as possible, on this basis, obtains the cluster node information of the Redis Cluster cluster, and classifies the cluster node information according to different data centers, determines the node failure status and the number of node failures of each data center; according to the node failure status and the number of node failures, judges the failure type of each data center; when the primary priority data center is the first failure type, sends a first switching instruction to all slave nodes of the non-faulty secondary priority data center, automatically switches all master nodes of the primary priority data center to the non-faulty secondary priority data center, and completes the fault switching. It avoids brain split when the Redis Cluster cluster fails over across data centers, improves the cluster's rapid switching capability when a data center-level failure occurs, and improves the overall availability and stability of the Redis Cluster cluster. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0025] Figure 1 This is an application environment diagram of a Redis Cluster cluster data center fault switching isolation method in one embodiment;

[0026] Figure 2 A schematic diagram of a process of a Redis Cluster cluster data center failure switching isolation method in one embodiment;

[0027] Figure 3 A flowchart of steps for restoring an update master node that has been switched to another secondary priority data center to the same data center in one embodiment;

[0028] Figure 4 is a schematic diagram of a flow chart of performing flow control on each data center in one embodiment;

[0029] Figure 5 This is the structural diagram of the Redis Cluster cluster in implementation case 1;

[0030] Figure 6 The structure diagram of the Redis Cluster cluster data center fault switching isolation system in one embodiment. DETAILED DESCRIPTION

[0031] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0032] The Redis Cluster cluster data center fault switching isolation method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the node terminal 102 communicates with the server 104 through the network. The data storage system 106 can store data that the server 104 needs to process. The data storage system 106 can be integrated on the server 104, or placed on the cloud or other network servers.

[0033] The Redis Cluster cluster includes multiple node terminals 102, and the node terminals 102 include master nodes and slave nodes. During initial deployment, all master nodes are distributed in the same data center by default, and the remaining slave nodes are randomly distributed in multiple other data centers. The data center with the number of master nodes greater than or equal to the set threshold is set as the primary priority data center, and the data center with the number of master nodes less than the set threshold or much less than the set threshold is set as the secondary priority data center.

[0034] On server 104, the cluster node information of the Redis Cluster cluster is obtained, and the cluster node information is classified according to different data centers to determine the node fault status and the number of node faults of the nodes in each of the data centers; according to the node fault status and the number of node faults, the fault type of the main priority data center is judged; when the main priority data center is of the first fault type, a first switching instruction is sent to all slave nodes of the non-faulty secondary priority data center, and all master nodes of the main priority data center are automatically switched to the non-faulty secondary priority data center to complete the fault switching.

[0035] The node terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.

[0036] In an exemplary embodiment, Figure 2 As shown, a Redis Cluster cluster data center failover isolation method is provided, and the method is applied to Figure 1 The server side in the example is used for explanation, assuming that the nodes of the Redis Cluster cluster are deployed in two data centers, including the following steps 201 to 203.

[0037] Step 201, obtaining cluster node information of the Redis Cluster cluster, and classifying the cluster node information according to different data centers, and determining the node failure status and the number of node failures of the nodes in each of the data centers.

[0038] The server side stores the original node information of the Redis Cluster cluster in the initial stage. The original node information mainly includes the name of the data center where the node is located, the priority of the data center where the node is located, the node ID, the master node to which it belongs, the node status, the node link status, the node epoch, and the slot allocation information.

[0039] There is only one primary priority data center in a Redis Cluster cluster, and all nodes of the cluster can be read using the primary priority data center. Therefore, the cluster node information of all nodes of the Redis Cluster cluster is read from the primary priority data center once every 15 seconds. If a data center of the Redis Cluster cluster encounters problems such as power, switch network, host machine failure, or dedicated line failure, it is easy to cause data center-level failures that cannot be quickly switched to other data centers and achieve fault isolation. Therefore, based on the cluster node information detected at regular intervals, the read cluster node information is classified according to different data centers, so as to determine the node failure status and number of node failures of each of the data centers.

[0040] Step 202: determine the fault type of each of the data centers according to the node fault status and the number of node faults.

[0041] Specifically, the fault type at the data center level is divided into a first fault type and a second fault type. The first fault type is a node fault at the data center level, and the second fault type is a network fault at the data center level. Therefore, the fault type of each data center can be determined by the node fault state and the number of node faults of each data center.

[0042] Step 203, when the main priority data center is of the first fault type, sends a first switching instruction to all slave nodes of the non-faulty secondary priority data center, automatically switches all master nodes of the main priority data center to the non-faulty secondary priority data center, and completes the fault switching.

[0043] Specifically, since the Redis Cluster cluster divides the data center into primary priority data centers and secondary priority data centers according to the number of master nodes, and defines the failure type at the macro data center level, only when a failure occurs in the primary priority data center, a failover is required to switch all master nodes in the primary priority data center to a fault-free secondary priority data center.

[0044] It should be noted that in any embodiment of the present application, if the number of master nodes in the secondary priority data center changes after the failover is completed, the primary priority data center needs to be reselected based on the number of master nodes in each data center after the failover.

[0045] In the above-mentioned Redis Cluster cluster data center fault switching isolation method, the master nodes are arranged in the same data center as much as possible, and on this basis, the cluster node information of the Redis Cluster cluster is obtained, and the cluster node information is classified according to different data centers to determine the node failure status and the number of node failures of each data center; according to the node failure status and the number of node failures, the failure type of each data center is judged; when the primary priority data center is the first failure type, the first switching instruction is sent to all slave nodes of the non-faulty secondary priority data center, and all master nodes of the primary priority data center are automatically switched to the non-faulty secondary priority data center to complete the fault switching. It avoids the occurrence of brain split when the Redis Cluster cluster fails over across data centers, improves the cluster's rapid switching capability when a data center-level failure occurs, and improves the overall availability and stability of the Redis Cluster cluster.

[0046] In an exemplary embodiment, step 202 of determining the fault type of the primary priority data center according to the node fault state and the number of faults specifically includes the following:

[0047] If the number of failed master nodes of the primary priority data center accounts for more than half of the number of all master nodes, and the number of failed master and slave nodes of the primary priority data center is less than the total number of all master and slave nodes, then the primary priority data center is determined to be of the first failure type. Alternatively, if the number of failed master and slave nodes of the primary priority data center is the number of all master and slave nodes, and the nodes in the secondary priority data center that are associated with the master and slave nodes of the primary priority data center are failed nodes, then the primary priority data center is determined to be of the first failure type.

[0048] For example, if the master nodes in the primary priority data center are down at the same time or continuously down, the number of failures N of the master nodes in the primary priority data center is obtained. Master_Fair and the number of failures N of the master and slave nodes in the primary priority data center All_Fair。

[0049] like <N Master_Fair <N Master_ALL And N All_Fair <N All_a ,

[0050] Among them, N Master_ALL Indicates the number of all master nodes in the Redis Cluster cluster, N All_a Indicates the number of all master and slave nodes in the primary priority data center. It can be determined that the failure type of the primary priority data center is the first failure type, that is, a node failure at the data center level.

[0051] Or, if N All_Fair =N All_a At this time, all the master and slave nodes of the main priority data center fail, and the main priority data center cannot be connected. It is necessary to obtain the cluster node information of the secondary priority data center. If the nodes in the secondary priority data center that are associated with the master and slave nodes of the main priority data center are all in a faulty state, it can be determined that the fault type of the main priority data center is the first fault type.

[0052] In this embodiment, the failure type of the primary priority data center is determined timely and accurately by the number of node failures and the types of failed nodes in the primary priority data center, thereby improving the efficiency of cluster failure switching.

[0053] In another exemplary embodiment, in addition to the judgment condition of the first fault type as described in the previous embodiment, the present application also includes a judgment condition of the second fault type. Step 202 judges the fault type of the primary priority data center according to the node fault state and the number of node faults and also includes the following:

[0054] If the exchange between the primary priority data center and the external application network is abnormal, and the overall cluster status displayed by the primary priority data center is normal, and the node failure status of all nodes in the cluster is normal, then the primary priority data center is determined to be the second failure type. Alternatively, if the exchange between the primary priority data center and the external application network is abnormal, the overall cluster status displayed by the primary priority data center is normal, and the overall cluster status displayed by the secondary priority data center is abnormal, then the primary priority data center is determined to be the second failure type.

[0055] For example, when the external switch of the main priority data center fails, the exchange between the main priority data center and the external application network is abnormal. If at this time the cluster node information from the main priority data center shows that the overall cluster status of the Redis Cluster cluster is normal and all nodes of the Redis Cluster cluster are not faulty, but actually cannot provide services, then it can be determined that the failure type of the main priority data center is the second failure type, that is, a data center-level network failure. Alternatively, if at this time the cluster node information of the main priority data center shows that the overall cluster status of the Redis Cluster cluster is normal, but the secondary priority data center associated with the main priority data center shows that the overall cluster status of the Redis Cluster cluster is abnormal, and at this time the slave nodes of the secondary priority data center can no longer communicate with the main priority data center, then it can also be determined that the failure type of the main priority data center is the second failure type.

[0056] More specifically, regardless of the result of determining the second fault type in any of the above situations, when the primary priority data center is of the second fault type, a second switching instruction is sent to the fault-free secondary priority data center to switch all master nodes of the primary priority data center to the fault-free secondary priority data center to complete the fault switching.

[0057] However, when the overall cluster status of the Redis Cluster cluster is abnormal in the secondary priority data center, it is also necessary to send a disconnection command to all the master nodes of the primary priority data center to control all the master nodes of the primary priority data center to shut down the node instances and complete fault isolation to avoid inconsistent data writing by partitioned applications in different data centers.

[0058] It should be noted that if the external network and dedicated line of the original primary priority data center are restored to normal later, the shut down node of the original primary priority data center can be manually started. After the startup, the instance of the node will be compared with the latest epoch of the current Redis Cluster cluster, currentEpoch. According to the comparison result, the node will automatically connect to the master node of the latest primary priority data center as a slave node.

[0059] In this embodiment, the overall state of the data center cluster and the state of network exchange with the outside are used to timely and accurately determine the type of failure in the data center, thereby improving the efficiency of cluster failure switching.

[0060] In another exemplary embodiment, the first fault type and the second fault type may occur separately or simultaneously, so step 202 determines the fault type of the primary priority data center according to the node fault state and the number of node faults and further includes the following:

[0061] If the first fault type and the second fault type exist in the main priority data center, a third switching instruction is sent to all slave nodes of the fault-free secondary priority data center to switch the master node of the main priority data center to the fault-free secondary priority data center.

[0062] Specifically, if all the master nodes of the primary priority data center fail, before the master nodes are switched to the non-faulty secondary priority data center, the network communication dedicated line between the primary priority data center and the secondary priority data center also fails, and the failure type of the primary priority data center includes the first failure type and the second failure type, namely, node failure and network failure. Send a third switching instruction to all slave nodes of the non-faulty secondary priority data center to switch the master node of the primary priority data center to the non-faulty secondary priority data center.

[0063] Preferably, after the primary priority data center is of the first fault type and the second fault type and the master node of the primary priority data center is switched to the non-faulty secondary priority data center, if the node failure is recovered before the network failure, a network partition of the Redis Cluster cluster may occur. Therefore, in order to avoid network partition, the method further includes the following contents:

[0064] The first fault recovery time and the second fault recovery time corresponding to the first fault type and the second fault type are obtained respectively. If the first fault recovery time is greater than the second fault recovery time, all master nodes of the primary priority data center are not controlled to shut down the node instance; if the first fault recovery time is less than the second fault recovery time, all master nodes of the primary priority data center are controlled to shut down the node instance for isolation.

[0065] Specifically, if the first fault recovery time is greater than the second fault recovery time, that is, the network fault of the primary priority data center is restored first, then the Redis Cluster cluster will not experience network partition and split-brain, so there is no need to isolate the master node of the primary priority data center. If the first fault recovery time is less than the second fault recovery time, that is, the node fault of the primary priority data center is restored first, then the Redis Cluster cluster may experience network partition, so it is necessary to control all the master nodes of the primary priority data center for isolation.

[0066] In detail, the isolation operation includes two types. First: setting the node instances of all the master nodes of the primary priority data center to prohibit self-startup. Second: obtaining cluster node information from the primary priority data center and the secondary priority data center respectively. If the cluster node information of the two data centers both show that the overall cluster status of the Redis Cluster cluster is normal, but the cluster node information of the two data centers shows that the node IDs of the master nodes are inconsistent, and the master nodes of each other are displayed as faulty locally, it means that a network partition has occurred. Since the third switching instruction sent previously has switched the master node of the primary priority data center to the fault-free secondary priority data center, it is necessary to compare the latest epoch of the master node of the secondary priority data center after switching with the latest epoch of the master node of the original primary priority data center. When the latest epoch of the master node of the secondary priority data center after switching is greater than the latest epoch of the master node of the original primary priority data center, control the faulty master node of the original primary priority data center to shut down the node instance, and then manually open it after the network dedicated line is restored.

[0067] In addition to the fault switching isolation at the data center level, if the master node of the Redis Cluster cluster fails randomly, the Redis Cluster cluster has a failover automatic fault-tolerant switching mechanism. However, the failover automatic fault-tolerant switching mechanism will randomly switch the failed master node to other data centers, which destroys the prior condition of placing all master nodes in the same data center during the initial deployment of this application. In order to avoid the brain split problem caused by the random distribution of master nodes in multiple data centers, this application uses the following embodiments to automatically switch the failover to the update master node of other secondary priority data centers and restore it to the same data center. The premise for executing this embodiment is that the overall cluster status of the Redis Cluster cluster is normal, and the update master node and other master nodes are distributed in different data centers.

[0068] In an exemplary embodiment, if there is at least one faulty master node randomly in the primary priority data center, the Redis Cluster cluster performs failover automatic fault-tolerant switching, and switches the first non-faulty slave node of other secondary priority data centers to the corresponding updated master node, such as Figure 3 As shown, the method further includes the following steps 301 to 303:

[0069] Step 301, based on the current priority relationship of multiple data centers, determine whether there is a switchable second fault-free slave node in the current main priority data center. If so, automatically switch the second fault-free slave node to the updated master node, and control the number of master nodes in the current main priority data center to be greater than or equal to the set threshold.

[0070] Step 302, otherwise, obtain the data center with the most master nodes, and determine whether the data center with the most master nodes is a different data center from the current main priority data center. If so, update the current priority relationship, and the data center with the most master nodes is the updated main priority data center.

[0071] Step 303: if the updated main priority data center is a secondary priority data center that originally contains the first fault-free slave node, then stop the automatic switching of the updated main node; otherwise, obtain the cluster node information of the updated main priority data center, and determine whether there is a switchable third fault-free slave node in the updated main priority data center. If so, then automatically switch the third fault-free slave node to the updated main node, and control the number of master nodes of the updated main priority data center to be greater than or equal to the set threshold.

[0072] In this embodiment, by automatically switching the failover to the updated master node of other secondary priority data centers and restoring it to the same data center, when network instability or network failures of multiple data centers occur subsequently, the brain split problem caused by the random distribution of the master node in multiple data centers is avoided.

[0073] It should be noted that when updating the master node and other master nodes are distributed in different data centers, the following rules still need to be checked:

[0074] S1, determine whether the change of updating the master node is a manual operation, if so, do not execute the above steps 301 to 303. Otherwise, continue to S2.

[0075] S2, determine whether the update time of the updated master node is within the set time, if so, execute the above step 301 to determine whether there is a switchable second non-faulty slave node in the current primary priority data center, if there is no second faulty slave node, do not change the updated master node. Otherwise, continue to S3.

[0076] S3, automatically creates a scheduled task. The scheduled task will switch the updated master node within the specified time to ensure that all restored master nodes are distributed in the same data center. The scheduled task will be cleared if the following situations occur:

[0077] 1) The task is manually executed in advance.

[0078] 2) The task is manually terminated early.

[0079] 3) The task is executed when it expires.

[0080] 4) The slave node that needs to execute fails.

[0081] 5) Data center priorities change.

[0082] Because each slave node under the Redis Cluster architecture can only copy data from its master node, cascading replication is not supported. If the same Redis Cluster master node is distributed in the same data center, and the slave nodes are distributed in multiple other data centers, if multiple slave nodes (different groups) initiate full replication at the same time, the network traffic between data centers will surge, affecting the stability of the network link and thus affecting the service. Therefore, in addition to the methods described in the above embodiments, in order to avoid the problem of high traffic caused by multiple slave nodes across data centers initiating synchronous replication requests at the same time, this application proposes a dynamic current limiting strategy for cross-data center replication of Redis Cluster through the following embodiments. The underlying layer of this dynamic current limiting strategy relies on Linux TC (Traffic Control).

[0083] In an exemplary embodiment, if multiple slave nodes across data centers simultaneously initiate synchronous replication requests, the method further includes:

[0084] Obtain the dedicated line bandwidth usage rate between each data center, and determine whether to perform flow control on each data center according to the growth rate or average usage rate of the dedicated line bandwidth usage rate within a first set time.

[0085] Among them, Figure 4 As shown, the flow control for each data center specifically includes the following steps 401 to 402:

[0086] Step 401, send the flow limiting dynamic script file to the master node that executes flow limiting in the corresponding data center. The master node that executes flow limiting uses the flow limiting dynamic script to limit the flow of the target IP and output port of the slave node that initiates the synchronous replication request, and generates log information after completion.

[0087] Among them, the flow-limiting dynamic script file needs to be generated based on the node relationship, IP, port, flow-limiting bandwidth, and network card interface name of the master and slave nodes. When the server monitors that the master-slave replication triggers flow control, the flow-limiting dynamic script is generated based on the above required parameters.

[0088] Step 402, obtain the update dedicated line bandwidth usage rate between each data center, and send the clearing flow limit script file to the main node that executes the flow limit according to the decrease rate of the update dedicated line bandwidth usage rate within the second set time and the log information, so as to end the flow limit.

[0089] Specifically, obtain the dedicated line bandwidth usage U1 between each data center. Assume that in the past 5 minutes. The average usage rate of the dedicated line bandwidth usage is greater than or equal to 85%, or the growth rate is greater than 10% and lasts for 1 minute, then the current limiting strategy is triggered, and the current limiting dynamic script file is sent to the master node that executes the current limiting in the corresponding data center. The current limiting dynamic script file is executed on the master node, and after the traffic is limited on the target IP and output port of the slave node that initiates the synchronous replication request, log information is generated. According to the decrease rate and log information of the dedicated line bandwidth usage updated within the second set time, the current limiting script file is cleared and sent to the master node that executes the current limiting, and the current limiting is ended.

[0090] In this embodiment, the dynamic current limiting strategy enables the Redis Cluster cluster to have the current limiting capability of master-slave full replication, avoiding the problem that multiple groups of slave nodes may simultaneously perform a large number of full replications to impact the dedicated line bandwidth and affect network stability due to the inability to cascade replication.

[0091] The method proposed in this application is verified through two implementation cases below.

[0092] Implementation Case 1: A RedisCluster cluster with multiple Redis nodes deployed in multiple data centers. Figure 5 As shown, taking 12 Redis nodes and 2 data centers as an example, the data center is referred to as the computer room below. The computer room is divided into A computer room and B computer room. A computer room has a higher priority. The cluster includes 3 master nodes, and each master node has 3 slave nodes to form a group. The described Redis node is a carrier server, a computer, or a Linux system and hardware that can deploy the Redis execution program. The Redis instance is the deployed Redis service process. The Redis node is operated through the client.

[0093] The first step is to deploy Redis instances on the six nodes in computer room A. The Redis instances of three of the nodes are added to the other three nodes to form a master-slave relationship. Redis instances are also deployed on the six nodes in computer room B, and are added to the corresponding Master nodes of computer room A in groups of two. At this point, the overall large cluster has three Master nodes, each Master node has three Slave nodes, one Slave node in the same group is distributed in computer room A, and another Slave node in the same group is distributed in computer room B. The benefit of this initial architecture is that it avoids multiple Master nodes being distributed in different data centers, reducing the problem of inconsistent data writing when the network is unstable. At the same time, multiple Slave nodes provide synchronous replication, and can fail over to other computer rooms when a failure occurs, and can carry the same traffic.

[0094] The second step is to simulate the failure and recovery of the A-m1 Redis instance and the A-s1 Redis instance, as well as the network failure and recovery between computer rooms A and B. The specific operations are as follows:

[0095] a1. Log in to the A-m1 node, shut down the Redis instance, and observe the Master node's failover and log printing information.

[0096] a2. Get the node information of the A-m1 Redis instance. Normally, the Master node has switched to the A-s1 node.

[0097] a3. To further verify the accuracy, steps a1 and a2 can be repeated three times. The method is to reset the A-m1 Redis instance and the A-s1 Redis instance first, resume the A-m1 Redis instance process, and manually switch the Redis instance on the A-m1 Redis instance. Then repeat steps a1 and a2.

[0098] a4. Confirm that the A-m1 Redis instance is in a faulty state (Fail), log in to the A-s1 node and shut down the Redis instance. At this time, two nodes in the same group in the A computer room have failed (Fail). Observe that the Master node has been switched to the B computer room. The result is that when there is no available slave node in the data center with a high priority (A), it will not be switched to the A computer room.

[0099] a5. Restore the A-m1 Redis instance process in Data Center A. Within 5 minutes, the Master node has been transferred to the A-m1 node in Data Center A. The result of this step is consistent with the expectation that the Master node tends to have a high priority and is distributed in the data center containing most master nodes.

[0100] a6. All Master nodes are distributed in Computer Room A. On the A-m1 node, iptables is used to block the network connection between Computer Room A and Computer Room B. Iptables is a tool for setting firewall policies on Linux systems. It is observed that all Slave nodes in Computer Room B are Fail (subjectively offline), while the nodes in Computer Room A are in a healthy state, and the cluster can still operate normally and can read and write.

[0101] Implementation Case 2: Apply the Redis Cluster cluster data center failure switching isolation method described in the above embodiments to Figure 5 The Redis Cluster cluster shown has the following verification results:

[0102] Before using this method, log in to the A-m1 node and A-m2 node in the A computer room and terminate the corresponding Redis instance processes respectively. The execution interval should not exceed 10 seconds. Then check the cluster node information of the cluster on other nodes in the cluster, wait for 30 seconds, and check again. It is found that the master node has not failed and the overall cluster status cluster_state is still Fail.

[0103] After using this method, log in to the A-m1 node and A-m2 node in the A computer room, and terminate the corresponding Redis instance process respectively. The execution interval should not exceed 10 seconds. After 1 minute (up to 5 minutes), check the cluster node information of the cluster on other nodes in the cluster, and find that all the master nodes in the A computer room have failed over to the original slave nodes in the B computer room. At this time, the overall cluster status cluster_state is ok, and the result meets the expectations of automatic failover at the computer room level.

[0104] Restore the A-m1 Redis instance and the A-m2 Redis instance, switch all the master nodes back to the A computer room, and set the node to failover automatic fault-tolerant switching (mark it with "auto" automatically) with one click. Log in to the A-m1 node, A-m2 node, and A-m3 node in the A computer room, and end the corresponding instance process (simulate failure) respectively. The execution interval should not exceed 10 seconds. Immediately isolate the network between the A computer room and the B computer room through iptables (mutual restriction). After 1 minute (up to 5 minutes), check the cluster node information of the cluster on other nodes in the cluster and find that all the master nodes in the A computer room have failed over to the original slave nodes in the B computer room. At this time, the overall cluster status cluster_state is ok.

[0105] Log in to the A-m1 node, A-m2 node, and A-m3 node again, start and restore the instance process (simulate recovery), connect to the A-m1 Redis instance and the B-m1 Redis instance, check the cluster node information respectively, and find that the two sides output different cluster states, and network partition has occurred. After 1 minute, check the cluster information and Redis instances again and find that the three Redis instance processes in computer room A have been closed. This is after the system performs computer room-level fault switching and finds that multiple network partitions have occurred. Isolate the unhealthy computer room nodes, which is in line with operational expectations.

[0106] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0107] Based on the same inventive concept, the embodiment of the present application also provides a Redis Cluster cluster data center fault switching isolation system for implementing the RedisCluster cluster data center fault switching isolation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more Redis Cluster cluster data center fault switching isolation system embodiments provided below can refer to the limitations of the Redis Cluster cluster data center fault switching isolation method above, and will not be repeated here.

[0108] In an exemplary embodiment, Figure 6 As shown, a Redis Cluster cluster data center fault switching isolation system is provided, wherein the cluster status monitoring module 601, cluster management control module 602 and replication current limiting module 603 of the system are deployed in Figure 1 The nodes of the Redis Cluster cluster of the system are deployed in multiple data centers, and the multiple data centers include a primary priority data center and a secondary priority data center, wherein the number of master nodes in the primary priority data center is greater than or equal to a set threshold, and the number of master nodes in the secondary priority data center is much less than the set threshold.

[0109] The cluster status monitoring module 601 is used to obtain the cluster node information of the Redis Cluster cluster, and classify the cluster node information according to different data centers, determine the node failure status and the number of node failures in each data center; based on the node failure status and the number of node failures, determine the failure type of the main priority data center.

[0110] The cluster management control module 602 is used to send a first switching instruction to all slave nodes of the non-faulty secondary priority data center when the primary priority data center is of the first fault type, and automatically switch all master nodes of the primary priority data center to the non-faulty secondary priority data center to complete the fault switching.

[0111] In one of the embodiments, the cluster status monitoring module 601 is also used for: if the number of failures of the master nodes of the main priority data center accounts for more than half of the number of all master nodes, and the number of failures of the master and slave nodes of the main priority data center is less than the total number of all master and slave nodes, then determining that the main priority data center is of the first failure type; or if the number of failures of the master and slave nodes of the main priority data center is the number of all master and slave nodes, and the nodes in the secondary priority data center associated with the master and slave nodes of the main priority data center are failed nodes, then determining that the main priority data center is of the first failure type.

[0112] In one of the embodiments, the cluster management control module 602 is also used to: when the primary priority data center is of the second fault type, send a second switching instruction to the fault-free secondary priority data center to switch all the master nodes of the primary priority data center to the fault-free secondary priority data center to complete the fault switching; and / or simultaneously send a disconnection instruction to all the master nodes of the primary priority data center to control all the master nodes of the primary priority data center to shut down node instances to complete fault isolation.

[0113] In one of the embodiments, the cluster status monitoring module 601 is also used for: if the exchange between the main priority data center and the external application network is abnormal, and the overall cluster status displayed by the main priority data center is normal, and the node failure status of all nodes in the cluster is normal, then the main priority data center is determined to be the second fault type; or if the exchange between the main priority data center and the external application network is abnormal, the overall cluster status displayed by the main priority data center is normal, and the overall cluster status displayed by the secondary priority data center is abnormal, then the main priority data center is determined to be the second fault type.

[0114] In one embodiment, the cluster management control module 602 is also used to: if the first fault type and the second fault type exist in the main priority data center, send a third switching instruction to all slave nodes of the fault-free secondary priority data center to switch the master node of the main priority data center to the fault-free secondary priority data center.

[0115] In one of the embodiments, the cluster status monitoring module 601 is also used to: obtain a first fault recovery time and a second fault recovery time corresponding to a first fault type and a second fault type, respectively; if the first fault recovery time is greater than the second fault recovery time, all master nodes of the main priority data center are not controlled to shut down node instances; if the first fault recovery time is less than the second fault recovery time, all master nodes of the main priority data center are controlled to perform isolation operations.

[0116] In one of the embodiments, the cluster status monitoring module 601 is also used to: determine whether there is a switchable second fault-free slave node in the current main priority data center based on the current priority relationship of multiple data centers, and if so, automatically switch the second fault-free slave node to the updated master node, and control the number of master nodes of the current main priority data center to be greater than or equal to a set threshold; otherwise, obtain the data center with the most master nodes, and determine whether the data center with the most master nodes is a different data center from the current main priority data center, and if so, update the current priority relationship, and the data center with the most master nodes is the updated main priority data center; if the updated main priority data center is a secondary priority data center that originally contained the first fault-free slave node, stop the automatic switching of the updated master node; otherwise, obtain the cluster node information of the updated main priority data center, and determine whether there is a switchable third fault-free slave node in the updated main priority data center, and if so, automatically switch the third fault-free slave node to the updated master node, and control the number of master nodes of the updated main priority data center to be greater than or equal to the set threshold.

[0117] In one embodiment, the replication flow limiting module 603 is used to obtain the dedicated line bandwidth usage between each data center, and determine whether to perform flow control on each data center based on the growth rate or average usage of the dedicated line bandwidth usage within a first set time.

[0118] In one of the embodiments, the replication current limiting module 603 is used to: send the current limiting dynamic script file to the master node that executes the current limiting in the corresponding data center, and the master node that executes the current limiting uses the current limiting dynamic script to limit the traffic of the target IP and output port of the slave node that initiates the synchronous replication request, and generates log information after completion; obtain the update dedicated line bandwidth utilization rate between each data center, and according to the decrease rate of the update dedicated line bandwidth utilization rate within the second set time and the log information, send the clear current limiting script file to the master node that executes the current limiting to end the current limiting.

[0119] Each module in the above-mentioned Redis Cluster cluster data center failover isolation system can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0120] In an exemplary embodiment, a computer device is provided, which may be a server. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store cluster node information. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a Redis Cluster cluster data center fault switching isolation method is implemented.

[0121] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, steps corresponding to the methods described in the above embodiments are implemented.

[0122] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps corresponding to the methods described in the above embodiments are implemented.

[0123] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0124] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0125] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A Redis Cluster cluster data center fault switching isolation method, characterized in that: The nodes of the RedisCluster cluster are deployed in multiple data centers, the multiple data centers include a primary priority data center and a secondary priority data center, wherein the number of master nodes in the primary priority data center is greater than or equal to a set threshold, and the number of master nodes in the secondary priority data center is less than the set threshold, and the method includes: Obtain cluster node information of the Redis Cluster cluster, and classify the cluster node information according to different data centers, and determine the node failure status and the number of node failures of each data center; Determining the fault type of each of the data centers according to the node fault state and the number of node faults; If the number of failed master nodes of the primary priority data center accounts for more than half of the number of all master nodes, and the number of failed master and slave nodes of the primary priority data center is less than the total number of all master and slave nodes, then the primary priority data center is determined to be of the first fault type; or if the number of failed master and slave nodes of the primary priority data center is the number of all master and slave nodes, and the nodes in the secondary priority data center that are associated with the master and slave nodes of the primary priority data center are failed nodes, then the primary priority data center is determined to be of the first fault type; wherein the first fault type is a node fault at the data center level; In the case where the primary priority data center is of the first fault type, a first switching instruction is sent to all slave nodes of the non-faulty secondary priority data center, and all master nodes of the primary priority data center are automatically switched to the non-faulty secondary priority data center to complete the fault switching; In the case where there is at least one faulty master node in the primary priority data center, the Redis Cluster cluster performs automatic fault-tolerant switching, switches the first fault-free slave node of other secondary priority data centers to the corresponding update master node, and then determines whether there is a switchable second fault-free slave node in the current primary priority data center according to the current priority relationship of multiple data centers. If so, the second fault-free slave node is automatically switched to the update master node, and the number of master nodes in the current primary priority data center is controlled to be greater than or equal to the set threshold; Otherwise, obtain the data center with the most master nodes, and determine whether the data center with the most master nodes is a different data center from the current primary priority data center. If so, update the current priority relationship, and the data center with the most master nodes is the updated primary priority data center. If the update main priority data center is a secondary priority data center that originally included the first fault-free slave node, stop the automatic switching of the update main node; otherwise, obtain the cluster node information of the update main priority data center, and determine whether there is a switchable third fault-free slave node in the update main priority data center. If so, automatically switch the third fault-free slave node to the update master node, and control the number of master nodes in the update main priority data center to be greater than or equal to the set threshold.

2. The Redis Cluster cluster data center fault switching isolation method according to claim 1, characterized in that: Judging the failure type of the primary priority data center according to the node failure state and the number of node failures includes: If the exchange between the primary priority data center and the external application network is abnormal and the overall status of the cluster displayed by the primary priority data center is normal and the node failure status of all nodes in the cluster is normal, then the primary priority data center is determined to be the second failure type; or If the exchange between the main priority data center and the external application network is abnormal, the overall cluster status displayed by the main priority data center is normal, and the overall cluster status displayed by the secondary priority data center is abnormal, then the main priority data center is determined to be the second fault type; wherein the second fault type is a network failure at the data center level.

3. The Redis Cluster cluster data center fault switching isolation method according to claim 2 is characterized in that: In the case where the primary priority data center is of the second fault type, a second switching instruction is sent to the non-faulty secondary priority data center to switch all master nodes of the primary priority data center to the non-faulty secondary priority data center to complete the fault switching; And / or simultaneously send a cut-off instruction to all master nodes of the primary priority data center to control all master nodes of the primary priority data center to shut down node instances and complete fault isolation.

4. The Redis Cluster cluster data center fault switching isolation method according to claim 3 is characterized in that: If the first fault type and the second fault type exist in the main priority data center, a third switching instruction is sent to all slave nodes of the fault-free secondary priority data center to switch the master node of the main priority data center to the fault-free secondary priority data center.

5. The Redis Cluster cluster data center fault switching isolation method according to claim 4 is characterized in that: After the primary priority data center is of the first fault type and the second fault type and the master node of the primary priority data center is switched to the non-faulty secondary priority data center, the method further includes: Respectively obtain a first fault recovery time and a second fault recovery time corresponding to the first fault type and the second fault type; If the first fault recovery time is greater than the second fault recovery time, all master nodes of the primary priority data center are not controlled to shut down the node instances; If the first fault recovery time is less than the second fault recovery time, all master nodes of the primary priority data center are controlled to perform isolation operations.

6. The Redis Cluster cluster data center fault switching isolation method according to claim 1, characterized in that: If multiple slave nodes across data centers initiate synchronous replication requests simultaneously, the method further includes: Obtain the dedicated line bandwidth usage rate between each data center, and determine whether to perform flow control on each data center according to the growth rate or average usage rate of the dedicated line bandwidth usage rate within a first set time.

7. The Redis Cluster cluster data center fault switching isolation method according to claim 6, characterized in that: The flow control of each data center includes: The flow limiting dynamic script file is sent to the master node that executes flow limiting in the corresponding data center. The master node that executes flow limiting uses the flow limiting dynamic script to limit the flow of the target IP and output port of the slave node that initiates the synchronous replication request, and generates log information after completion; The update dedicated line bandwidth usage rate between each data center is obtained, and according to the decrease rate of the update dedicated line bandwidth usage rate within the second set time and the log information, the current limiting clearing script file is sent to the main node that executes the current limiting to end the current limiting.

8. A Redis Cluster cluster data center fault switching isolation system, characterized in that: The system includes a Redis Cluster cluster, a cluster status monitoring module, and a cluster management control module; the nodes of the Redis Cluster cluster are deployed in multiple data centers, and the multiple data centers include a primary priority data center and a secondary priority data center, wherein the number of master nodes in the primary priority data center is greater than or equal to a set threshold, and the number of master nodes in the secondary priority data center is much less than the set threshold; The cluster status monitoring module is used to obtain the cluster node information of the Redis Cluster cluster, and classify the cluster node information according to different data centers, determine the node failure status and the number of node failures of each data center; according to the node failure status and the number of node failures, determine the failure type of each data center; The cluster management control module is used to determine that the main priority data center is of the first fault type if the number of faults of the master nodes of the main priority data center accounts for more than half of the number of all master nodes, and the number of faults of the master and slave nodes of the main priority data center is less than the total number of all master and slave nodes; or if the number of faults of the master and slave nodes of the main priority data center is the number of all master and slave nodes, and the nodes associated with the master and slave nodes of the main priority data center in the secondary priority data center are faulty nodes, then determine that the main priority data center is of the first fault type; in the case where the main priority data center is of the first fault type, send a first switching instruction to all slave nodes of the non-faulty secondary priority data center, automatically switch all master nodes of the main priority data center to the non-faulty secondary priority data center, and complete the fault switching; In the case where there is at least one faulty master node in the primary priority data center, the Redis Cluster cluster performs automatic fault-tolerant switching, switches the first fault-free slave node of other secondary priority data centers to the corresponding update master node, and then determines whether there is a switchable second fault-free slave node in the current primary priority data center according to the current priority relationship of multiple data centers. If so, the second fault-free slave node is automatically switched to the update master node, and the number of master nodes in the current primary priority data center is controlled to be greater than or equal to the set threshold; Otherwise, obtain the data center with the most master nodes, and determine whether the data center with the most master nodes is a different data center from the current primary priority data center. If so, update the current priority relationship, and the data center with the most master nodes is the updated primary priority data center. If the update main priority data center is a secondary priority data center that originally included the first fault-free slave node, stop the automatic switching of the update main node; otherwise, obtain the cluster node information of the update main priority data center, and determine whether there is a switchable third fault-free slave node in the update main priority data center. If so, automatically switch the third fault-free slave node to the update master node, and control the number of master nodes in the update main priority data center to be greater than or equal to the set threshold.

Citation Information

Patent Citations

  • Cluster switching method, device and equipment

    CN113051110A

  • Cluster fault switching method and device and electronic equipment

    CN113810216A