A fast connection method, storage medium and device for database cluster

By introducing sentinel mechanism and connection pool management into the database cluster, the database connection delay and timeout problems in dual-network environments are solved, and fast connection and efficient business startup are achieved.

CN115988057BActive Publication Date: 2024-11-12CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310014406.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-05
Publication Date
2024-11-12
Estimated Expiration
2043-01-05

AI Technical Summary

Technical Problem

In a dual-network environment database cluster, connection delay and timeout problems caused by cluster master-secure switching or failure during service startup, especially in multi-module startup scenarios, resulting in a significant increase in startup time.

Method used

The sentinel mechanism is adopted to obtain and save the IP collection of multiple nodes, try to connect and judge the host node, record the sentinel IP to prioritize connection to the database cluster, and manage idle connections and upper limits in the connection pool to ensure quick connection to the database.

Benefits of technology

It realizes fast connection to the database cluster, reduces business startup time, and significantly saves waiting time when the faulty node exists, and improves the connection efficiency of the database cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115988057B_ABST
    Figure CN115988057B_ABST
Patent Text Reader

Abstract

The present invention provides a method, storage medium and device for quickly connecting a database cluster, including: obtaining a first preset IP set, wherein the first preset IP set stores the corresponding IPs of multiple nodes involved in the connection string for attempting to connect to the database cluster; taking out the IPs in the first preset IP set in sequence and recording them as connection IPs; attempting to connect to the corresponding node of the connection IP according to the connection IP; if the attempt result is a successful connection, determining whether the corresponding node of the connection IP is a host node; if so, recording the connection IP as a sentinel IP, which is the preferred IP when connecting to the database cluster. The method for quickly connecting a database cluster of the present invention introduces a mechanism for quickly starting only services when a database cluster fails, namely a sentinel mechanism, so as to improve the efficiency of connecting to the database cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of databases, and in particular to a fast connection method, storage medium and device for a database cluster. Background Art

[0002] When using services in a dual-network database cluster environment, users will face scenarios such as cluster master-slave switching and cluster dual-network switching. When the above scenarios occur, the business platform needs to be started normally, using the following methods: The first method is to start the business module and repeatedly try to connect to the cluster node until it connects to the normally started host node. The second method is to wait for the cluster to recover before starting the business module. In the first method, if there are multiple functional modules in the business module, and multiple functional modules need to access the connection database, at this time, it will take a long time to start the business module. In the second method, if there is a cluster node failure, the time to start the business module will also cause a timeout waiting time due to trying to connect to the failed node; if multiple modules are started sequentially, the startup time will become longer. Summary of the invention

[0003] An object of the present invention is to provide a method, storage medium and device for quickly connecting a database cluster that can solve any of the above problems.

[0004] A further object of the present invention is to increase the speed of connecting to a database cluster.

[0005] In particular, the present invention provides a method for quickly connecting a database cluster, comprising:

[0006] Obtain a first preset IP set, in which the first preset IP set stores corresponding IP addresses of multiple nodes involved in the connection string for attempting to connect to the database cluster;

[0007] Take out the IPs in the first preset IP set in sequence and record them as the connection IPs;

[0008] Try to connect to the corresponding node of the connection IP according to the connection IP;

[0009] If the attempt result is a successful connection, determine whether the node corresponding to the connected IP is the host node;

[0010] If yes, the connection IP is recorded as the sentinel IP. The sentinel IP is the preferred IP when connecting to the database cluster to improve the efficiency of connecting to the database cluster.

[0011] Furthermore, after the step of recording the connection IP as the sentinel IP, the following steps are further included:

[0012] Save the Sentinel IP.

[0013] Furthermore, the steps of saving the sentinel IP include:

[0014] Use mapping management for sentinel IP, where the key of sentinel IP mapping is a preset string and the value of sentinel IP mapping is the sentinel IP.

[0015] Further, the connection pool is managed by mapping, the key of the connection pool mapping is the connection string, the value of the connection pool mapping is the connection pool, and the sentinel IP is managed by mapping, and the following steps are included:

[0016] Get the connection string again and try to connect to the database cluster;

[0017] Get the connection pool corresponding to the connection string;

[0018] Determine whether there are idle connections in the connection pool;

[0019] If there is an idle connection, connect to the idle connection;

[0020] If there is no idle connection, determine whether the connections in the connection pool have reached the preset upper limit;

[0021] If the preset upper limit is not reached, the sentinel IP is used to try to connect to the database cluster;

[0022] If the attempt results in a successful connection, a connection object is created;

[0023] Add the connection object to the connection pool.

[0024] Furthermore, the step of using the sentinel IP to try to connect to the database cluster also includes:

[0025] If the attempt fails, multiple nodes of the database cluster are parsed from the connection string;

[0026] The IPs corresponding to the multiple nodes are stored in a second preset IP set;

[0027] Take out other IPs except the sentinel IP from the second preset IP set;

[0028] Try to connect to the database cluster based on other IP addresses;

[0029] If the attempt results in a successful connection, the corresponding sentinel IP is found in the sentinel mapping according to the preset string, and the sentinel IP is updated to another IP.

[0030] Furthermore, the steps of saving the sentinel IP include:

[0031] Use mapping management for sentinel IP, where the key of sentinel IP mapping is the connection string and the value of sentinel IP mapping is the sentinel IP.

[0032] Furthermore, after the step of saving the sentinel IP, the following steps are further included:

[0033] Update the Sentinel IP.

[0034] Furthermore, the steps of updating the sentinel IP include:

[0035] Get the connection string again and try to connect to the database cluster;

[0036] Parse multiple nodes of the database cluster from the connection string;

[0037] The IPs corresponding to the multiple nodes are stored in a second preset IP set;

[0038] The sentinel IP is stored in the second preset IP set and is located at the head end of the second preset IP set;

[0039] Take out IPs from the second preset IP set in sequence, and take out IPs from the second preset IP set in sequence including the sentinel IP;

[0040] Try to connect to the database cluster by taking out an IP from the second preset IP set;

[0041] Find the host IP of the database cluster based on the attempt results;

[0042] Compare the host IP with the sentinel IP to determine whether the host IP is consistent with the sentinel IP;

[0043] If not, change the sentinel IP to the host IP.

[0044] According to another aspect of the present invention, a machine-readable storage medium is provided, on which a machine-executable program is stored. When the machine-executable program is executed by a processor, any of the above-mentioned methods for quickly connecting a database cluster is implemented.

[0045] According to another aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, and the processor implements any of the above-mentioned methods for quickly connecting a database cluster when executing the machine executable program.

[0046] The fast connection method of the database cluster of the present invention includes: obtaining a first preset IP set, wherein the first preset IP set stores the corresponding IPs of multiple nodes involved in the connection string for attempting to connect to the database cluster; taking out the IPs in the first preset IP set in sequence and recording them as connection IPs; attempting to connect to the corresponding node of the connection IP according to the connection IP; if the attempt result is a successful connection, determining whether the corresponding node of the connection IP is a host node; if so, recording the connection IP as a sentinel IP, which is the preferred IP when connecting to the database cluster. The fast connection method of the database cluster of the present invention introduces a mechanism for rapid startup of services only when a database cluster fails - the sentinel mechanism, so as to improve the efficiency of connecting to the database cluster.

[0047] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0049] Figure 1 is a schematic architecture diagram of a database cluster according to an embodiment of the present invention;

[0050] Figure 2 is a schematic step diagram of a method for quickly connecting a database cluster according to an embodiment of the present invention;

[0051] Figure 3 yes Figure 2 A schematic diagram of the IP acquisition step in the quick connection method of the database cluster shown;

[0052] Figure 4 is a schematic step diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention;

[0053] Figure 5 is a schematic step diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention;

[0054] Figure 6 is a schematic step diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention;

[0055] Figure 7 is a schematic step diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention;

[0056] Figure 8 yes Figure 7 A schematic diagram of placing a sentinel IP into a second preset IP set in a quick connection method of a database cluster shown;

[0057] Fig. 9 is a schematic step diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention;

[0058] Fig.10 is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention; and

[0059] Fig.11 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0060] Figure 1 2 is a schematic diagram of the architecture of a database cluster according to an embodiment of the present invention. The architecture of the database cluster in this implementation may include an application terminal 200, a client terminal 100, and a network for connecting the application terminal 200 and the client terminal 100.

[0061] Figure 2 1 is a schematic diagram of the steps of a fast connection method for a database cluster according to an embodiment of the present invention. The fast connection method for a database cluster of this embodiment includes:

[0062] Step S202, obtain a first preset IP set. The first preset IP set stores the corresponding IPs of multiple nodes involved in the connection string for attempting to connect to the database cluster. The first preset IP set can be obtained by obtaining the connection string for attempting to connect to the database, parsing multiple nodes involved in the database from the connection string, putting the multiple nodes into a linked list, looping each node of the linked list, and storing the parsed IPs in the first preset IP set, thereby obtaining the first preset IP set.

[0063] Step S204, taking out IPs in the first preset IP set in sequence and recording them as connection IPs.

[0064] Step S206, try to connect to the corresponding node of the connecting IP according to the connecting IP. If the result of the attempt is successful, execute step S208. If the result of the attempt is failed, try using the IP located next to the connecting IP.

[0065] Step S208, determine whether the node corresponding to the connection IP is a host node. If yes, execute step S210. If no, search for the connection IP again.

[0066] Step S210, record the connection IP as the sentinel IP. The sentinel IP is the preferred IP when connecting to the database cluster to improve the efficiency of connecting to the database cluster.

[0067] Figure 3 yes Figure 2 Schematic diagram of the IP acquisition steps in the quick connection method of the database cluster shown in FIG. Figure 3 As shown, in the process of establishing the physical connection for the first time, the Host connected to the database is parsed from the connection string. The circular linked list stores the parsed IP corresponding to each node in the IP list (the first preset IP set).

[0068] Loop through the IP list, extract the IP address, build a socket connection to the database, and return an available connection. Determine if the database server being connected is a primary node, return the connection, exit the loop connection process, and save the found host node IP as the sentinel IP. If it is a standby node, continue to obtain the IP to create a new connection. After all the contents in the IP list are looped through, if the host node is still not found, an exception is thrown: Primary Host Server is not open, connect failed, and an empty connection object is returned.

[0069] Figure 4 FIG. 1 is a schematic diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention. Figure 4 As shown, the quick connection method of the database cluster of this embodiment includes:

[0070] Step S302: Obtain a first preset IP set.

[0071] Step S304, taking out IPs in the first preset IP set in sequence and recording them as connection IPs.

[0072] Step S306, try to connect to the corresponding node according to the connection IP. If the attempt result is successful, execute step S308.

[0073] Step S308, determine whether the node corresponding to the connected IP is a host node. If yes, execute step S310. If no, execute step S314.

[0074] Step S310, record the connecting IP as the sentinel IP.

[0075] Step S312, save the sentinel IP.

[0076] Step S314, try to obtain the IP located next to the connection IP. If the acquisition is successful, execute step S316. If not, execute step S318.

[0077] Step S316, cyclically taking out IPs in sequence until the end of the first preset IP set.

[0078] Step S318, looping to the end of the first preset IP set and throwing an exception, confirming that it is impossible to connect to the host.

[0079] The quick connection method of the database cluster of this embodiment further includes the step of recording the connection IP as the sentinel IP after: saving the sentinel IP. The step of saving the sentinel IP includes: using a mapping management for the sentinel IP, wherein the key of the sentinel IP mapping is a preset string, and the value of the sentinel IP mapping is the sentinel IP. In some embodiments, the saving mechanism of the sentinel IP is similar to the management mechanism of the connection pool, and is managed by a map, the key of the map is a preset string, i.e., connString, and the value of the map is the sentinel IP. In some embodiments, the preset string can be obtained through the corresponding connection string.

[0080] Figure 5 FIG. 1 is a schematic diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention. Figure 5 As shown, the fast connection method for the database cluster of this embodiment can also use mapping management for the connection pool, the key of the connection pool mapping is the connection string, and the value of the connection pool mapping is the connection pool. After the step of using mapping management for the sentinel IP, the fast connection method for the database cluster of this embodiment also includes:

[0081] Step S402, obtaining a connection string for attempting to connect to the database cluster again.

[0082] Step S404, obtaining a connection pool corresponding to the connection string.

[0083] Step S406, determine whether there is an idle connection in the connection pool. If not, execute step S408. If yes, connect to the idle connection.

[0084] Step S408, determining whether the number of connections in the connection pool reaches a preset upper limit. If not, executing step S410.

[0085] Step S410, using the sentinel IP to try to connect to the database cluster. If the attempt result is successful, then execute step S412.

[0086] Step S412: Create a connection object.

[0087] Step S414: adding the connection object to the connection pool.

[0088] Figure 6 : is a schematic diagram of the steps of a fast connection method for a database cluster according to another embodiment of the present invention. The fast connection method for a database cluster in this embodiment also includes:

[0089] Step S512, using the sentinel IP to try to connect to the database cluster. If the connection attempt fails, step S514 is executed.

[0090] Step S514, parse out multiple nodes of the database cluster from the connection string.

[0091] Step S516: store the IPs corresponding to the multiple nodes into a second preset IP set.

[0092] Step S518, taking out other IPs except the sentinel IP from the second preset IP set.

[0093] Step S518, try to connect to the database cluster according to other IPs. If the connection is successful, find the corresponding sentinel IP in the sentinel mapping according to the preset string, and update the sentinel IP to other IPs.

[0094] The fast connection method of the database cluster of this embodiment uses the connection string to find the corresponding connection pool, check whether there is an idle connection in the connection pool, and if there is an idle connection, return the idle connection. If there is no idle connection in the connection pool and the connection in the connection pool does not reach the specified upper limit, a new connection is established. Through the connection string, find the corresponding connection pool, confirm that there is no idle connection in the connection pool, and the number of connections has not reached the specified upper limit. Through the resolved IP address, establish a connection in a loop, and the sentinel IP is connected first. If the database connection is successfully established using the sentinel IP, create a connection object. Add the connection object to the connection pool and return the connection to the application end.

[0095] If the sentinel IP fails to connect to the database, try other IP connections. After the connection is successful, find the corresponding sentinel IP in the sentinel mapping through the connection string and update the sentinel IP. If all IPs are tried and no connection to the database is successful, an exception is thrown: Primary Host Server is not open, connect failed, and an empty connection object is returned.

[0096] The fast connection method for the database cluster of this embodiment adopts a connection pool, and the connection pool can be connected and reused. The mechanism for saving the sentinel IP of the fast connection method for the database cluster of this embodiment is to use a custom string as the key of the sentinel map. In this way, if different modules use the same cluster, then when different modules access the database, the connection information is extracted, and the corresponding sentinel IP is found in the sentinel map, so that multiple modules can be shared, reducing the trouble caused by different keys. If multiple modules are started serially, not every module accesses the database. The sentinel mechanism of this embodiment can save time: (m-1)*n*2*2, where m is the number of modules and n is the number of faulty nodes.

[0097] The quick connection method for the database cluster of this implementation further includes, after the step of saving the sentinel IP: updating the sentinel IP.

[0098] Figure 7 FIG. 1 is a schematic diagram of a method for quickly connecting a database cluster according to another embodiment of the present invention. The step of updating the sentinel IP in the method for quickly connecting a database cluster in this embodiment includes:

[0099] Step S602, obtaining a connection string for attempting to connect to the database cluster again.

[0100] Step S604: parse the connection string to obtain multiple nodes of the database cluster.

[0101] Step S606: store the IPs corresponding to the multiple nodes into a second preset IP set.

[0102] Step S608, storing the sentinel IP into the second preset IP set and locating it at the head end of the second preset IP set.

[0103] Step S610, sequentially taking out IPs from the second preset IP set, wherein the IPs sequentially taken out from the second preset IP set include the sentinel IP.

[0104] Step S612: Try to connect to the database cluster by taking out an IP from the second preset IP set.

[0105] Step S614, find the host IP of the database cluster according to the attempt result.

[0106] Step S616, compare the host IP with the sentinel IP to determine whether the host IP is consistent with the sentinel IP. If not, execute step S618.

[0107] Step S618, modify the sentinel IP to the host IP.

[0108] Figure 8 yes Figure 7 Schematic diagram of placing the sentinel IP into the second preset IP set in the fast connection method of the database cluster shown in FIG. Figure 7 As shown, the fast connection method of the database cluster of this embodiment includes parsing the connection nodes, Node1, Node2, and Node3, from the connection string, and storing the parsed nodes in a linked list. First, add the sentinel IP address to IPlist (the second preset IP set), then loop the linked list to each node, and store the parsed IP in IP list (the second preset IP set). Take out the IP address from IP list (the second preset IP set), connect to the database, find the host node IP address, compare the node with the sentinel IP, find that the host node IP is modified, update the sentinel IP, and return the connection.

[0109] The fast connection method for the database cluster of this embodiment fails when a node in the cluster fails, and the user uses multiple connections at the same time. The host node is at the last position in the connection string configuration; when connecting, because one node fails, a corresponding connection waiting situation will occur, and the connection time consumption will be greater than 2 (the number of IP addresses under the domain name) * connecttimeout (connection timeout, the default is 2 seconds); when the second physical connection is made, because of the existence of the sentinel IP, the sentinel IP will be connected first, and the connection time saved is 2 (the number of IP addresses under the domain name) * connect timeout (the default is 2 seconds); multiple physical connections save time of m (the number of physical connections) * n (the number of failed nodes) * 2 (the number of IP addresses under the node domain name) * connect timeout (connection timeout).

[0110] Fig. 9 It is a schematic step diagram of a fast connection method for a database cluster according to another embodiment of the present invention. The fast connection method for a database cluster of this embodiment includes a first physical connection establishment process and a second physical connection establishment process. In the process of establishing the physical connection for the first time, the Host connected to the database is parsed from the connection string, and the domain name resolution is performed on the Host to obtain the IP. The circular linked list stores the parsed IP in the IP list (first preset IP set) for each node. The IP list is read cyclically, the IP address is taken out, a socket connection to the database is constructed, an available connection is returned, the database server connected to is judged to be a host node, the connection is returned, the cyclic connection establishment process is exited, and the host node IP found is saved as a sentinel IP. In the process of establishing the physical connection for the second time, the connection nodes, Node1, Node2, and Node3, are parsed from the connection string, and the parsed nodes are stored in a linked list. First, the sentinel IP address is added to the IP list (second preset IP set), and then the circular linked list stores the parsed IP in the IP list (second preset IP set) for each node. Take out the IP address from the IP list (the second preset IP set), connect to the database, find the host node IP address, compare the node with the sentinel IP, find that the host node IP is modified, update the sentinel IP, and return the connection.

[0111] The detection method of the database cluster installation environment of this embodiment also includes a cleanup process. When there is an Unavailable item in the configuration detection or after the installation is completed, a preset data process of cleaning configuration items is executed on the servers in the cluster.

[0112] This embodiment also provides a machine-readable storage medium and a computer device. Fig.10is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention, Fig.11 is a schematic diagram of a computer device according to an embodiment of the present invention.

[0113] The machine-readable storage medium 40 stores a machine executable program 41 thereon. When the machine executable program 41 is executed by a processor, the method for quickly connecting a database cluster in any of the above embodiments can be implemented.

[0114] The computer device 50 may include a memory 520, a processor 510, and a machine executable program 41 stored in the memory 520 and running on the processor 510, and the processor 510 implements the fast connection method of the database cluster of any of the above embodiments when executing the machine executable program 41.

[0115] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by an instruction execution system, device or equipment (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or equipment and execute instructions), or used in combination with these instruction execution systems, devices or equipment.

[0116] For the purposes of the description of this embodiment, the machine-readable storage medium 40 may be any device that can contain, store, communicate, propagate or transmit a program for use with an instruction execution system, device or apparatus or in conjunction with such instruction execution systems, devices or apparatuses. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection having one or more wirings (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium 40 may even be paper or other suitable medium on which the program may be printed, because the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0117] It should be understood that each part of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.

[0118] The computer device 50 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 50 may be a cloud computing node. The computer device 50 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, target programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 50 may be implemented in a distributed cloud computing environment where remote processing devices linked through a communication network perform tasks. In a distributed cloud computing environment, program modules may be located on a local or remote computing system storage medium including a storage device.

[0119] The computer device 50 may include a processor 510 adapted to execute stored instructions, and a memory 520 providing temporary storage space for the operation of the instructions during operation. The processor 510 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 520 may include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.

[0120] Processor 510 can also be linked to a display interface suitable for connecting computer device 50 to a display device through a system interconnection. Display device can include a display screen as a built-in component of computer device 50. Display device can also include a computer monitor, a television or a projector, etc., which are externally connected to computer device 50. In addition, a network interface controller (NIC) can be suitable for connecting computer device 50 to a network through a system interconnection. In some embodiments, NIC can use any suitable interface or protocol (such as Internet Small Computer System Interface, etc.) to transmit data. The network can be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN) or the Internet, etc. A remote device can be connected to a computing device through a network.

[0121] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes may be made to the above method.

[0122] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A quick connection method for a database cluster, comprising: Obtain a first preset IP set, wherein the first preset IP set stores corresponding IP addresses of multiple nodes involved in a connection string for attempting to connect to the database cluster; Sequentially take out the IPs in the first preset IP set and record them as connection IPs; Attempt to connect to a corresponding node of the connection IP according to the connection IP; If the attempt result is a successful connection, determine whether the node corresponding to the connection IP is a host node; If yes, the connection IP is recorded as a sentinel IP, which is the preferred IP when connecting to the database cluster to improve the efficiency of connecting to the database cluster; Save the sentinel IP; Update the sentinel IP; The step of updating the sentinel IP includes: obtaining a connection string for attempting to connect to the database cluster again; parsing multiple nodes of the database cluster from the connection string; storing the IPs corresponding to the multiple nodes in a second preset IP set; storing the sentinel IP in the second preset IP set and locating it at the head end of the second preset IP set; taking out IPs from the second preset IP set in sequence, and the IPs taken out in sequence from the second preset IP set include the sentinel IP; attempting to connect to the database cluster based on the IP taken out from the second preset IP set; finding the host IP of the database cluster based on the attempt result; comparing the host IP with the sentinel IP to determine whether the host IP is consistent with the sentinel IP; if not, modifying the sentinel IP to the host IP.

2. The fast connection method for a database cluster according to claim 1, wherein: The step of storing the sentinel IP comprises: The sentinel IP is managed using a mapping, wherein the key of the sentinel IP mapping is a preset string, and the value of the sentinel IP mapping is the sentinel IP.

3. The fast connection method for a database cluster according to claim 2, wherein: The connection pool is managed by mapping, the key of the connection pool mapping is the connection string, the value of the connection pool mapping is the connection pool, and the sentinel IP is managed by mapping, and the following steps are included: Obtain a connection string again to attempt to connect to the database cluster; Obtain a connection pool corresponding to the connection string; Determine whether there is an idle connection in the connection pool; If there is an idle connection, connect to the idle connection; If there is no idle connection, determining whether the number of connections in the connection pool has reached a preset upper limit; If the preset upper limit is not reached, the sentinel IP is used to try to connect to the database cluster; If the attempt results in a successful connection, a connection object is created; Add the connection object to the connection pool.

4. The fast connection method for a database cluster according to claim 3, wherein: After the step of using the sentinel IP to attempt to connect to the database cluster, the following step is further included: If the attempt fails, then parsing the multiple nodes of the database cluster from the connection string; The IPs corresponding to the multiple nodes are stored in a second preset IP set; Take out other IPs except the sentinel IP from the second preset IP set; Try to connect to the database cluster according to the other IP address; If the attempt result is a successful connection, the corresponding sentinel IP is found in the sentinel IP mapping according to the preset character string, and the sentinel IP is updated to the other IP.

5. The fast connection method for a database cluster according to claim 1, wherein: The step of storing the sentinel IP comprises: The sentinel IP is managed using a mapping, wherein the key of the sentinel IP mapping is the connection string, and the value of the sentinel IP mapping is the sentinel IP.

6. A machine-readable storage medium having a machine executable program stored thereon, wherein the machine executable program, when executed by a processor, implements the method for quickly connecting a database cluster according to any one of claims 1 to 5.

7. A computer device, comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, wherein the processor implements the fast connection method for a database cluster according to any one of claims 1 to 5 when executing the machine executable program.