Database cluster service method and device based on network environment detection and medium
By real-time detection of agent programs in the database cluster and automatically switch network segments, the problem of insufficient fault detection and recovery mechanisms in complex network environments in the prior art is solved, high availability and stability are achieved, and split brain phenomenon is avoided.
Patent Information
- Application Number
- CN202411352165.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-02-25
AI Technical Summary
The existing high-availability database cluster services lack flexible fault detection and recovery mechanisms in complex network environments, which makes it difficult to meet user needs, and is prone to split brain phenomena, resulting in data inconsistency and business interruption.
Through the preset monitoring program, the agent in the database cluster is detected in real time, the missing nodes are determined, and the connectivity detection of the main network segment and the standby network segment is carried out according to the characteristics of the network environment, and automatically switch to the available network segment to ensure the high availability of the database cluster.
It realizes rapid identification and response to network failures, avoids service interruptions caused by single point of failure, significantly improves the high availability and stability of database cluster services, and avoids the occurrence of split brain conditions.
Smart Images

Figure CN119520237A_ABST
Abstract
Description
Technical Field
[0001] The present specification relates to the technical field of database clusters, and in particular to a database cluster service method, device, and medium based on network environment detection. Background Art
[0002] In the production environment of database clusters, ensuring high availability and fast fault recovery capabilities is crucial to maintaining business continuity. In the face of emergencies such as network disconnection, power outages, and network failures between the primary and standby nodes of the primary database node, a robust high-availability management system is not only necessary, but also the cornerstone to ensure that the business is not affected. Currently, the brain split phenomenon is an extremely serious problem in high-availability clusters. It means that when the communication link of the cluster is disconnected, multiple nodes that should have been consistent may make decisions independently due to the inability to communicate with each other, eventually resulting in multiple master nodes in the cluster providing services to the outside world at the same time. This will not only cause data inconsistency, but may also cause confusion in client requests, seriously affecting the normal operation of the business. Therefore, how to ensure that only one node can continue to provide services as the primary node when the cluster splits is an important part of high-availability cluster services.
[0003] Many current high-availability products do have limitations in deployment methods, such as requiring all nodes to be in the same network segment, which limits the flexibility and scalability of the system. In a complex network environment, a single network segment failure may directly lead to the paralysis of the entire cluster, making it impossible to provide any services. The current high-availability cluster service also lacks a flexible fault detection and recovery mechanism, resulting in its fault recovery performance being unable to meet the actual business needs of users. Summary of the invention
[0004] In order to solve the above technical problems, one or more embodiments of this specification provide a database cluster service method, device and medium based on network environment detection.
[0005] One or more embodiments of this specification adopt the following technical solutions:
[0006] One or more embodiments of this specification provide a database cluster service method based on network environment detection, the method comprising:
[0007] Detect each agent program corresponding to the current database cluster according to the preset monitoring program to determine that the server corresponding to the abnormal agent program is the lost node;
[0008] Determine the network environment corresponding to the lost node, and if it is determined that the network environment is a multi-network environment, perform connectivity detection on the primary network segment ping point and the backup network segment ping point of the lost node based on the preset monitoring program to obtain a detection result;
[0009] According to the detection result, it is determined whether to start the switching between the primary network segment and the backup network segment, and the network segment configuration of the current database cluster is updated based on the switching result to realize the high availability service of the current database cluster.
[0010] Optionally, in one or more embodiments of the present specification, the detecting of each agent program corresponding to the current database cluster according to a preset monitoring program to determine that the server corresponding to the abnormal agent program is a disconnected node specifically includes:
[0011] The connection message of each node agent program in the current database cluster is received through the preset monitoring program; wherein the current database cluster includes a master node and at least one standby node, and the master node and the at least one standby node are configured with corresponding agent programs and corresponding databases.
[0012] If it is determined that the reception time of the connection message exceeds the preset specified time, the agent program is connected to the database of the server where the agent program is located based on the preset monitoring program;
[0013] If the agent program fails to communicate with the database, an abnormal agent program is obtained and the server where the abnormal agent program is located is determined to be a disconnected node.
[0014] Optionally, in one or more embodiments of the present specification, determining the network environment corresponding to the lost node specifically includes:
[0015] Obtain the network path corresponding to the server node where each agent program is located in the current database cluster to determine the network device and subnet corresponding to the server node where each agent program is located;
[0016] If it is determined that the network device is a single network device and a single subnet, then the network environment corresponding to the lost node is determined to be a single network environment;
[0017] If it is determined that the network device is a multi-network device and a multi-subnet, then it is determined that the network environment corresponding to the lost node is a multi-network environment.
[0018] Optionally, in one or more embodiments of the present specification, it is determined that the network environment is a multi-network environment, and connectivity detection is performed on the primary network segment ping point and the backup network segment ping point of the lost node based on the preset monitoring program to obtain the detection result, which specifically includes:
[0019] Performing connectivity detection on the main network segment ping point of the lost node based on the preset monitoring program to determine whether the main network segment ping point can be connected;
[0020] If it is determined that the primary network segment ping point is not connected, a connectivity test is performed on the backup network segment ping point of the disconnected node based on the preset monitoring program to obtain a test result; wherein the first test result includes: a dual network segment problem and a primary network segment problem;
[0021] If it is determined that the main network segment ping point is connected, determining whether the IP address of the lost node is connected based on the preset monitoring program;
[0022] If not, a connectivity check is performed on the backup network segment ping point of the lost node based on the preset monitoring program to obtain a test result.
[0023] Optionally, in one or more embodiments of the present specification, determining whether to start switching between the primary network segment and the backup network segment according to the detection result specifically includes:
[0024] If the detection result is a dual network segment problem, exit the preset monitoring program;
[0025] If the detection result is a problem with the primary network segment, the switching between the primary network segment and the backup network segment is initiated, and the primary network segment address and the backup network segment address of each node in the current database cluster are exchanged based on the preset monitoring program to obtain the switching result.
[0026] Optionally, in one or more embodiments of the present specification, updating the network segment configuration of the current database cluster based on the switching result to implement a high availability service of the current database cluster specifically includes:
[0027] Based on the switching result, updating the exchange result of the primary network segment address and the backup network segment address into the network segment configuration;
[0028] Based on the preset command statement, each of the standby nodes is controlled to reload the network segment configuration, so that each of the standby nodes follows the current main network segment address after switching.
[0029] Optionally, in one or more embodiments of the present specification, after determining the network environment corresponding to the lost node, the method further includes:
[0030] If it is determined that the network environment is a single network environment, then based on the preset monitoring program, a connectivity check is performed on the network segment ping point of the lost node;
[0031] If it is determined that the detection result is disconnected, the IP address corresponding to the disconnected node is unbound and the database is closed to remove the disconnected node from the current database cluster.
[0032] Optionally, in one or more embodiments of the present specification, if it is determined that the detection result is disconnected, then the IP address corresponding to the lost node is unbound and the database is closed to remove the lost node from the current database cluster, and the method further includes:
[0033] If it is determined that the lost node corresponds to the primary database, then the lost node is the primary node of the current database cluster;
[0034] If the lost node is a master node, obtaining the sequence number in the log file corresponding to the database of each standby node in the current database cluster;
[0035] It is determined that the database with the largest sequence number is the current primary database, and the standby node corresponding to the current primary database is the current primary node.
[0036] One or more embodiments of this specification provide a database cluster service device based on network environment detection, the device comprising:
[0037] at least one processor; and,
[0038] a memory communicatively connected to the at least one processor; wherein,
[0039] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: execute any of the above-mentioned methods.
[0040] One or more embodiments of the present specification provide a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured to execute any of the above-described methods.
[0041] At least one of the above technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects:
[0042] By real-time monitoring of the running status of each agent in the cluster and quickly identifying the disconnected nodes, this method can quickly respond to network failures or server failures to ensure the continuity and stability of the database cluster service. When a disconnected node is detected, the network segment connectivity can be further detected according to the characteristics of the network environment, and the network segment can be automatically switched to an available network segment, thereby avoiding service interruptions caused by single point failures and significantly improving the high availability of the database cluster service. In addition, by using external ping points for arbitration, the occurrence of brain splits in existing database cluster services is effectively avoided. In a multi-network environment, by intelligently switching the primary and standby network segments, it can be ensured that when any network segment fails, the database cluster service can quickly switch to an available network segment to continue running, which helps to make full use of network resources, avoid resource waste, and improve overall resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:
[0044] Figure 1 A schematic diagram of a database cluster service method flow based on network environment detection provided in an embodiment of this specification;
[0045] Figure 2 An overall architecture diagram of a database cluster service based on network environment detection provided in an embodiment of this specification;
[0046] Figure 3 A schematic diagram of a processing flow of a master node disconnecting from the network in an application scenario provided in an embodiment of this specification;
[0047] Figure 4 A schematic diagram of a dual network segment detection process in an application scenario provided by an embodiment of this specification;
[0048] Figure 5 A schematic diagram of a dual network segment switching process provided in an embodiment of this specification;
[0049] Figure 6 A schematic diagram of a database cluster service device structure based on network environment detection provided in an embodiment of this specification;
[0050] Figure 7 A schematic diagram of the structure of a non-volatile storage medium provided in an embodiment of this specification. DETAILED DESCRIPTION
[0051] The embodiments of this specification provide a database cluster service method, device and medium based on network environment detection.
[0052] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0053] like Figure 1 As shown, the embodiment of this specification provides a schematic diagram of a database cluster service method based on network environment detection. Figure 1 It can be seen that in one or more embodiments of this specification, a database cluster service method based on network environment detection includes:
[0054] S101: Detecting each agent program corresponding to the current database cluster according to a preset monitoring program to determine that the server corresponding to the abnormal agent program is a disconnected node.
[0055] In the production scenario of the database cluster, it is common to encounter scenarios such as the main database node disconnection, power outage, and network failure of the main and standby database nodes, which causes the database cluster to be unable to provide services normally. In order to promptly eliminate possible faults in the database cluster and ensure the normal operation of the database cluster, the embodiments of this specification will detect each agent program corresponding to the current database cluster according to the preset monitoring program, so as to determine that the server corresponding to the abnormal agent program is the disconnected node.
[0056] Specifically, in one or more embodiments of the present specification, the detecting of each agent program corresponding to the current database cluster according to the preset monitoring program to determine that the server corresponding to the abnormal agent program is a disconnected node specifically includes:
[0057] Receive connection messages from agent programs of each node in the current database cluster through the preset monitoring program; Figure 2 and Figure 3The current database cluster shown includes a master node and at least one standby node, and the master node and at least one standby node are configured with corresponding agents and corresponding databases. If it is determined that the reception time of the connection message exceeds the preset specified time, then in order to avoid the cluster service interruption problem caused by network failure, it is necessary to connect the agent with the database of the server where the agent is located according to the preset monitoring program. If the agent fails to connect with the database, the abnormal agent is obtained and the server where the abnormal agent is located is determined to be a lost node. That is, the current database cluster is monitored and managed based on the preset monitoring program. When the preset monitoring program determines that the agent message has not been received within the specified time, it will try to connect to the agent. If the agent cannot be connected, it will try to connect to the database on the agent server. If the database cannot be connected either, it is determined that the server where the agent is located is lost, which is called a lost node.
[0058] S102: Determine the network environment corresponding to the lost node. If it is determined that the network environment is a multi-network environment, perform connectivity detection on the primary network segment ping point and the backup network segment ping point of the lost node based on the preset monitoring program to obtain a detection result.
[0059] After determining the lost node in the current database cluster based on the above step S101, in order to realize the fault detection of the lost node and determine the corresponding maintenance strategy, the network environment corresponding to the lost node will be determined in the embodiment of this specification. If the network environment is determined to be a multi-network environment, then the connectivity detection of the main network segment ping point and the backup network segment ping point of the lost node is performed according to the pre-set monitoring program to determine the detection result of the lost node. By performing connectivity detection on the main network segment ping point and the backup network segment ping point of the lost node, it can be accurately determined which node network card problem caused the loss of connection, so as to maintain connectivity with other nodes through the subsequent dual network segment switching method, that is, through the backup network segment or other paths, to ensure the stability and reliability of the overall service. And for fault conditions such as network disconnection, arbitration is carried out with the help of external ping points to effectively avoid the occurrence of brain split.
[0060] Specifically, in one or more embodiments of the present specification, determining the network environment corresponding to the lost node specifically includes:
[0061] Get the network path corresponding to the server node where each agent program is located in the current database cluster to determine the network device and subnet corresponding to the server node where each agent program is located. If the network device is determined to be a single network device and a single subnet, then the network environment corresponding to the lost node is determined to be a single network environment. If the network device is determined to be multiple network devices and multiple subnets, then the network environment corresponding to the lost node can be determined to be a multiple network environment.
[0062] Further, in one or more embodiments of the present specification, after determining the network environment corresponding to the lost node, the method further includes:
[0063] like Figure 3 As shown in the figure, if the network environment is determined to be a single network environment, the network segment ping point of the lost node is tested for connectivity based on the preset monitoring program. If the detection result is determined to be disconnected, it is necessary to unbind the IP address corresponding to the lost node and close the database to remove the lost node from the current database cluster. When removing the lost node, an attempt will be made to unbind the virtual IP of the lost node and move the unbound virtual IP to other normal nodes to ensure high availability of the service. At the same time, when the agent program of the lost node cannot connect to the monitoring program, it will also try to connect to the ping point. If the ping point cannot be connected, the agent program will unbind the local virtual IP and stop the local database service.
[0064] After removing the lost node from the current database cluster, if it is determined that the lost node corresponds to the primary database, then the lost node is the primary node of the current database cluster. Figure 3 As shown in the figure, if the lost node is the master node, the monitoring program will select a new master node from the remaining nodes in the cluster and promote the database on the node to the master database. Then, it is necessary to obtain the serial number in the log file corresponding to the database of each standby node in the current database cluster. The database with the largest serial number is determined to be the current master database, and the standby node corresponding to the current master database is the current master node. If the lost node is a standby database, that is, a standby node, only the lost node is removed from the current database cluster. In addition, after the network of the lost node is restored, the monitoring program will notify the agent program of the lost node to let the database of the lost node return to the current database cluster.
[0065] Further, in one or more embodiments of the present specification, if the network environment is determined to be a multi-network environment, a connectivity test is performed on the primary network segment ping point and the backup network segment ping point of the lost node based on a preset monitoring program to obtain a test result, such as Figure 4 The specific process shown includes the following:
[0066] First, based on the preset monitoring program, the connectivity of the main network segment ping point of the lost node is tested to determine whether the main network segment ping point is connected. If it is determined that the main network segment ping point is not connected, the connectivity of the backup network segment ping point of the lost node is tested based on the preset monitoring program to obtain the test result; wherein, the first test result includes: dual network segment problem and main network segment problem. Figure 4Detailed explanation: It includes the following two types: (1) The monitoring program tries to connect to the main network segment ping point. If it cannot be connected, it means that there is a problem with the network card of the node where the monitoring program is located or the corresponding network segment. The monitoring program tries to connect to the backup network segment ping point and the backup IP of all nodes. If one or more cannot be connected, it means that there is also a problem with the backup network segment. This situation may be a scenario where the dual network cards of the node where the monitoring program is located are faulty or the network card of the node where the monitoring program is located is faulty and the network card of another node is faulty and the network cards are different, that is, there is a problem with the dual network segments. At this time, the subsequent operation corresponding to the detection result is the exit of the monitoring program. (2) The monitoring program tries to connect to the main network segment ping point. If it cannot be connected, it means that there is a problem with the network card of the node where the monitoring program is located or the corresponding network segment. The monitoring program tries to connect to the backup network segment ping point and the backup IP of all nodes. If all can be connected, it means that there is no problem with the backup network segment, that is, the main network segment problem. At this time, the subsequent operation corresponding to the detection result is the dual network segment switching process. By subdividing the detection results into dual network segment problems and main network segment problems, the scope and nature of the network failure can be more accurately determined. This refined fault classification provides clear guidance for subsequent maintenance work and helps to solve problems quickly and accurately. By timely detecting and handling network failures, this process helps to improve the stability of the entire system. Preventive inspections and repairs can prevent potential network problems from further deteriorating, thereby ensuring that the system can operate continuously and stably. In the existing technology, the problem that a single network segment failure may directly lead to the paralysis of the entire cluster and the inability to provide any services is avoided. With the help of external ping points for arbitration, the occurrence of brain splits is effectively avoided.
[0067] If it is determined that the main network segment ping point is connected, it means that there is no problem with the network card of the node where the monitoring program is located and the corresponding network segment. Then the preset monitoring program determines whether the IP address of the disconnected node is connected, that is, tries to connect to the main network segment ip of the node. If it can be connected, it means that there is no problem with the network card of the node, but the database and agent program of the node have problems. In this case, there is no need to switch the dual network segments. If it cannot be connected, it means that there may be a problem with the network card of the disconnected node, or the server of the node is powered off or disconnected from the network. Then the preset monitoring program performs a connectivity test on the backup network segment ping point of the disconnected node to obtain the test result. If it cannot be connected, it means that there may be a problem with the network card of the node, or the server of the node is powered off or disconnected from the network. There are several detection processes as follows: (1) The monitoring program tries to connect to the backup network segment ip of the node. If it cannot be connected, it tries to connect to the backup network segment ping point. If it can be connected, it means that the backup network card of the node is faulty or the server is powered off. At this time, the dual network card failure scenario on the same node is met, and the monitoring program removes the node and runs normally. (2) The monitoring program attempts to connect to the backup network segment IP of the node. If the connection fails, it attempts to connect to the backup network segment ping point. If the connection fails, it indicates that the backup network card of the node where the monitoring program is located is faulty, and the primary network card of the node is faulty or the node is powered off. If the network card of the node where the monitoring program is located is faulty and the network card of another node is faulty and the network cards are different, the monitoring program exits.
[0068] This process conducts comprehensive fault detection on the lost node through multiple steps, including connectivity detection of the main network segment ping point, node IP address, backup network segment IP and backup network segment ping point. This meticulous detection method can ensure accurate identification of the specific location and cause of the fault, providing a reliable basis for subsequent recovery work. Through the step-by-step elimination method, the process can efficiently locate the fault point. First check the main network segment ping point, then check the node IP address, and finally check the backup network segment IP and ping point. Each step has a clear detection target and judgment standard, which can quickly narrow the scope of the fault and improve the efficiency of fault location. Through the design and detection process of dual network segments, the solution enhances the robustness of the system. Even if a network segment has a problem, the system can still maintain communication through the backup network segment to ensure service continuity and stability. This redundant design improves the system's fault tolerance and disaster resistance.
[0069] S103: Determine whether to start switching between the primary network segment and the backup network segment according to the detection result, and update the network segment configuration of the current database cluster based on the switching result to achieve high availability service of the current database cluster.
[0070] In order to maintain communication through the backup network segment after a problem occurs in a network segment, the continuity and stability of the cluster service can be ensured. In the embodiments of this specification, it is determined whether to start the switch between the main network segment and the backup network segment based on the detection results, and the network segment configuration of the current database cluster is updated according to the switching results to achieve high availability services for the current database cluster. Specifically, in one or more embodiments of this specification, it is determined whether to start the switch between the main network segment and the backup network segment based on the detection results, which specifically includes the following process:
[0071] If the detection result is determined to be a dual network segment problem, then exit the preset monitoring program. If the detection result is a primary network segment problem, then start the switch between the primary network segment and the backup network segment, and exchange the primary network segment address and the backup network segment address of each node in the current database cluster according to the preset monitoring program to obtain the switching result. Further, in one or more embodiments of the present specification, the network segment configuration of the current database cluster is updated based on the switching result to achieve high availability services of the current database cluster, such as Figure 5 Specifically shown include:
[0072] Based on the switching result, the exchange result of the primary network segment address and the backup network segment address is updated to the network segment configuration. Then, according to the preset command statement, each backup node is controlled to reload the network segment configuration so that each backup node follows the current primary network segment address after the switch. In other words, the monitoring program performs a dual network segment switching process. The IP and backup IP of all nodes in the memory are exchanged and updated to the configuration file. Then, all backup databases in the cluster are connected and the host information in the primary_conninfo parameter is reloaded through SQL, so that all backup databases follow the IP of the new network segment of the primary database to complete the dual network segment switching operation.
[0073] like Figure 6 As shown, the embodiment of this specification provides a schematic diagram of the structure of a database cluster service device based on network environment detection. Figure 6 It can be seen that in one or more embodiments of this specification, a database cluster service device based on network environment detection includes:
[0074] at least one processor; and,
[0075] a memory communicatively connected to the at least one processor; wherein,
[0076] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: execute any of the above-mentioned methods.
[0077] like Figure 7As shown, the present specification provides a schematic diagram of the structure of a non-volatile storage medium. Figure 7 It can be seen that in one or more embodiments of this specification, a non-volatile storage medium stores computer executable instructions 701, and the computer executable instructions 701 can: execute any of the methods described above.
[0078] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0079] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0080] The above description is only one or more embodiments of this specification and is not intended to limit this specification. For those skilled in the art, one or more embodiments of this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included in the scope of the claims of this specification.
Claims
1. A database cluster service method based on network environment detection, characterized in that: The method comprises: Detect each agent program corresponding to the current database cluster according to the preset monitoring program to determine that the server corresponding to the abnormal agent program is the lost node; Determine the network environment corresponding to the lost node, and if it is determined that the network environment is a multi-network environment, perform connectivity detection on the primary network segment ping point and the backup network segment ping point of the lost node based on the preset monitoring program to obtain a detection result; According to the detection result, it is determined whether to start the switching between the primary network segment and the backup network segment, and the network segment configuration of the current database cluster is updated based on the switching result to realize the high availability service of the current database cluster.
2. A database cluster service method based on network environment detection according to claim 1, characterized in that: The detecting of each agent program corresponding to the current database cluster according to the preset monitoring program to determine that the server corresponding to the abnormal agent program is a disconnected node specifically includes: The connection message of each node agent program in the current database cluster is received through the preset monitoring program; wherein the current database cluster includes a master node and at least one standby node, and the master node and the at least one standby node are configured with corresponding agent programs and corresponding databases. If it is determined that the reception time of the connection message exceeds the preset specified time, the agent program is connected to the database of the server where the agent program is located based on the preset monitoring program; If the agent program fails to communicate with the database, an abnormal agent program is obtained and the server where the abnormal agent program is located is determined to be a disconnected node.
3. A database cluster service method based on network environment detection according to claim 1, characterized in that: Determining the network environment corresponding to the lost node specifically includes: Obtain the network path corresponding to the server node where each agent program is located in the current database cluster to determine the network device and subnet corresponding to the server node where each agent program is located; If it is determined that the network device is a single network device and a single subnet, then the network environment corresponding to the lost node is determined to be a single network environment; If it is determined that the network device is a multi-network device and a multi-subnet, then it is determined that the network environment corresponding to the lost node is a multi-network environment.
4. A database cluster service method based on network environment detection according to claim 1, characterized in that: Determining that the network environment is a multi-network environment, performing connectivity detection on the primary network segment ping point and the backup network segment ping point of the lost node based on the preset monitoring program to obtain a detection result, specifically including: Performing connectivity detection on the main network segment ping point of the lost node based on the preset monitoring program to determine whether the main network segment ping point can be connected; If it is determined that the primary network segment ping point is not connected, a connectivity test is performed on the backup network segment ping point of the disconnected node based on the preset monitoring program to obtain a test result; wherein the first test result includes: a dual network segment problem and a primary network segment problem; If it is determined that the main network segment ping point is connected, determining whether the IP address of the lost node is connected based on the preset monitoring program; If not, a connectivity check is performed on the backup network segment ping point of the lost node based on the preset monitoring program to obtain a test result.
5. A database cluster service method based on network environment detection according to claim 4, characterized in that: Determining whether to start switching between the primary network segment and the backup network segment according to the detection result specifically includes: If the detection result is a dual network segment problem, exit the preset monitoring program; If the detection result is a problem with the primary network segment, the switching between the primary network segment and the backup network segment is initiated, and the primary network segment address and the backup network segment address of each node in the current database cluster are exchanged based on the preset monitoring program to obtain the switching result.
6. A database cluster service method based on network environment detection according to claim 1, characterized in that: The network segment configuration of the current database cluster is updated based on the switching result to implement high availability services of the current database cluster, specifically including: Based on the switching result, updating the exchange result of the primary network segment address and the backup network segment address into the network segment configuration; Based on the preset command statement, each of the standby nodes is controlled to reload the network segment configuration, so that each of the standby nodes follows the current main network segment address after switching.
7. A database cluster service method based on network environment detection according to claim 1, characterized in that: After determining the network environment corresponding to the lost node, the method further includes: If it is determined that the network environment is a single network environment, then based on the preset monitoring program, a connectivity check is performed on the network segment ping point of the lost node; If it is determined that the detection result is disconnected, the IP address corresponding to the disconnected node is unbound and the database is closed to remove the disconnected node from the current database cluster.
8. A database cluster service method based on network environment detection according to claim 7, characterized in that: If it is determined that the detection result is disconnected, then the IP address corresponding to the disconnected node is unbound and the database is closed to remove the disconnected node from the current database cluster, and the method further includes: If it is determined that the lost node corresponds to the primary database, then the lost node is the primary node of the current database cluster; If the lost node is a master node, obtaining the sequence number in the log file corresponding to the database of each standby node in the current database cluster; It is determined that the database with the largest sequence number is the current primary database, and the standby node corresponding to the current primary database is the current primary node.
9. A database cluster service device based on network environment detection, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: execute any of the methods described in claims 1-8.
10. A non-volatile storage medium storing computer executable instructions, characterized in that: The computer executable instructions can: execute the method described in any one of claims 1 to 8.