Database connection method and device, electronic equipment and storage medium
By configuring the mapping relationship between the target domain name and the set of computing nodes in the distributed database and feeding back the network address of the healthy node, the high cost problem caused by configuring the IP address of all database nodes is solved, and a low-cost and highly reliable database connection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-07
AI Technical Summary
In a distributed database environment, applications need to configure the IP addresses of all possible database nodes when accessing the database, resulting in high configuration costs and complex management.
By configuring the mapping relationship between the target domain name and multiple sets of computing nodes in the database, and receiving the network address of the healthy node after the domain name resolution request, the application does not need to directly configure the network address of the computing node, but only needs to configure a unique target domain name to connect to the database node.
It reduces the complexity and cost of configuration and maintenance, improves the reliability of database connections, avoids connections to faulty or busy nodes, and enhances the reliability and flexibility of the system.
Smart Images

Figure CN121814731A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of distribution, in particular to a database connection method and device, electronic equipment and storage medium. BACKGROUND
[0002] In modern enterprise-level applications, database systems play a crucial role as the center of data storage and processing. With the rapid development of cloud computing, big data and Internet of Things technologies, traditional single-machine databases have been difficult to meet the growing data volume and processing needs. Therefore, distributed database systems have gradually become the mainstream solution in the field of data management due to their high scalability, high performance and strong consistency characteristics.
[0003] In the environment of a distributed database, application clients usually need to configure a list of static IP (Internet Protocol) addresses of multiple database compute nodes (CNs), and implement failover through a client retry mechanism to improve database high availability. In related technologies, when an application accesses a database, it needs to display the IP addresses of all CN nodes that it can connect in the URL (uniform resource locator) connection. This approach will result in significant operational overhead in maintaining and dynamically updating IP addresses as the cluster size expands or the node topology changes, thereby resulting in high configuration costs.
[0004] To address the above problems in the related art, no effective solutions have been proposed so far. SUMMARY
[0005] The main purpose of the present application is to provide a database connection method and device, electronic equipment and storage medium to solve the problem of high configuration cost in the related art when an application accesses a database, which needs to configure the IP addresses of all database nodes that it can connect in the network connection of the application.
[0006] To achieve the above purpose, according to one aspect of the present application, a database connection method is provided. The method comprises: in the case of receiving a domain name resolution request sent by a target application, extracting a target domain name from the domain name resolution request, wherein the target domain name is configured in the network connection of the target application, and the target domain name has a mapping relationship with a plurality of compute node sets of a database; determining the network address of the compute nodes in the plurality of compute node sets associated with the target domain name, wherein the health degree value of the compute nodes in the compute node set is greater than a preset degree value; sending the network address of the compute nodes in the plurality of compute node sets to the target application, wherein the target application connects to the database based on the network address.
[0007] Optionally, the database connection method further comprises: collecting a running index of the computing node before determining the network address of the computing node in the computing node set associated with the target domain name; determining the health degree value of the computing node based on the running index of the computing node.
[0008] Optionally, the database connection method further comprises: determining a delay index of the computing node from the running index, and calculating a first health sub-value of the computing node based on the delay index and a first weight value; determining a load index of the computing node from the running index, and calculating a second health sub-value of the computing node based on the load index and a second weight value; determining a packet loss rate of the computing node from the running index, and calculating a third health sub-value of the computing node based on the packet loss rate and a third weight value; determining the health degree value of the computing node based on at least one of the first health sub-value, the second health sub-value, and the third health sub-value.
[0009] Optionally, the database connection method further comprises: after determining the health degree value of the computing node based on the running index of the computing node, in a case where the health degree value of the computing node is less than or equal to a preset degree value, determining whether there is a computing node set including the computing node; in a case where there is a computing node set including the computing node, removing the computing node from the computing node set.
[0010] Optionally, the database connection method further comprises: determining the network address of the computing node in the computing node set associated with the target domain name, comprising: obtaining a domain name resolution table matched with the target domain name, and determining the network address of the computing node in the computing node set associated with the target domain name from the domain name resolution table; after removing the computing node from the computing node set, the method further comprises: deleting the network address of the computing node from the domain name resolution table.
[0011] Optionally, the database connection method further comprises: after determining the health degree value of the computing node based on the running index of the computing node, in a case where the health degree value of the computing node is greater than a preset degree value, determining whether there is a computing node set including the computing node; in a case where there is no computing node set including the computing node, adding the computing node to the computing node set.
[0012] Optionally, the database connection method further comprises: in a case where the computing node set update instruction is received, determining a computing node set pointed to by the computing node set update instruction from the plurality of computing node sets to obtain a target computing node set; performing update processing on the target computing node set based on an update operation in the computing node set update instruction to obtain an updated target computing node set.
[0013] In order to achieve the above object, according to another aspect of the present application, a database connection apparatus is provided. The apparatus comprises: an extraction module configured to extract a target domain name from a domain name resolution request in a case that the domain name resolution request is received from a target application, wherein the target domain name is configured in a network connection of the target application, and the target domain name has a mapping relationship with a plurality of computing node sets of a database; a first determination module configured to determine a network address of a computing node in the plurality of computing node sets associated with the target domain name, wherein a health degree value of the computing node in the plurality of computing node sets is greater than a preset degree value; and a sending module configured to send the network address of the computing node in the plurality of computing node sets to the target application, wherein the target application is connected to the database based on the network address.
[0014] Optionally, the database connection apparatus further comprises: an acquisition module configured to acquire a running index of the computing node; and a second determination module configured to determine the health degree value of the computing node based on the running index of the computing node.
[0015] Optionally, the second determination module further comprises: a first calculation submodule configured to determine a delay index of the computing node from the running index, and calculate a first health sub-value of the computing node based on the delay index and a first weight value; a second calculation submodule configured to determine a load index of the computing node from the running index, and calculate a second health sub-value of the computing node based on the load index and a second weight value; a third calculation submodule configured to determine a packet loss rate of the computing node from the running index, and calculate a third health sub-value of the computing node based on the packet loss rate and a third weight value; and a first determination submodule configured to determine the health degree value of the computing node based on at least one of the first health sub-value, the second health sub-value and the third health sub-value.
[0016] Optionally, the database connection apparatus further comprises: a first judgment module configured to judge whether there is a computing node set including the computing node in a case that the health degree value of the computing node is less than or equal to the preset degree value; and a removal module configured to remove the computing node from the computing node set in a case that there is the computing node set including the computing node.
[0017] Optionally, the first determination module further comprises: a second determination submodule configured to acquire a domain name resolution table matched with the target domain name, and determine the network address of the computing node in the plurality of computing node sets associated with the target domain name from the domain name resolution table; and the database connection apparatus further comprises: a deletion module configured to delete the network address of the computing node from the domain name resolution table.
[0018] Optionally, the database connection apparatus further comprises a second judging module configured to judge whether there is a computing node set comprising the computing node in a case where the health degree value of the computing node is greater than the preset degree value; and a processing module configured to add the computing node to the computing node set in a case where there is no computing node set comprising the computing node.
[0019] Optionally, the database connection apparatus further comprises a third determining module configured to determine a computing node set pointed to by the computing node set updating instruction from the plurality of computing node sets in a case where the computing node set updating instruction is received, to obtain a target computing node set; and an updating module configured to update the target computing node set based on an updating operation in the computing node set updating instruction, to obtain an updated target computing node set.
[0020] In order to achieve the above object, according to another aspect of the present application, a computer readable storage medium is provided, which comprises a stored executable program, wherein the computer readable storage medium controls the device where the computer readable storage medium is located to execute the database connection method when the executable program is run.
[0021] In order to achieve the above object, according to another aspect of the present application, an electronic device is provided, which comprises a memory storing an executable program; and a processor configured to run the program, wherein the program is executed to perform the database connection method when the program is run.
[0022] In order to achieve the above object, according to another aspect of the present application, a computer program product is provided, which comprises computer instructions, and the computer instructions are executed by a processor to implement the steps of the database connection method.
[0023] In the embodiments of the present application, by configuring the target domain name in the network connection of the target application, and designing the mapping relationship between the target domain name and the plurality of computing node sets of the database, in a case where the domain name resolution request is received, the network address of the database computing node is fed back to the target application based on the target domain name, which realizes that in the database connection establishment scenario, the application does not need to directly configure the network address of the computing node, and only needs to configure the unique target domain name to obtain the network address of the database node which needs to be connected, thereby effectively reducing the complexity of configuration and maintenance, and reducing the configuration cost. In addition, by associating the computing node with the health degree value greater than the preset degree value with the target domain name, the target application side is avoided from establishing the database connection with the faulty or busy computing node, thereby the reliability of the database connection can be improved.
[0024] It can be seen that the method provided in the application achieves the purpose of configuring a single domain name in the network connection of an application to realize database connection, realizes the technical effect of reducing configuration cost, and solves the technical problem of high configuration cost in the related art that all IP addresses of database nodes that an application can connect need to be configured in the network connection of the application when the application accesses a database. BRIEF DESCRIPTION OF DRAWINGS
[0025] The accompanying drawings, which form a part of the present application, are intended to provide further understanding of the present application and serve as an explanation of the illustrative embodiments of the present application and are not intended to impose any undue limitation upon the present application. In the drawings:
[0026] Figure 1 is a hardware structure block diagram of a computer terminal according to an embodiment of the present application;
[0027] Figure 2 is a flowchart of a database connection method according to an embodiment of the present application;
[0028] Figure 3 is a schematic diagram of a target processing system according to an embodiment of the present application;
[0029] Figure 4 is a schematic diagram of a database connection device according to an embodiment of the present application;
[0030] Figure 5 is a structure block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative labor should fall within the protection scope of the present application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and in the above drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0033] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, analyzed data, etc.) involved in the present application are information and data authorized by the user or authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of related data comply with relevant laws, regulations and standards, necessary security measures are taken, do not violate public order and good customs, and provide corresponding operation portal for user to choose authorization or refusal. For example, the system and related users or institutions are provided with an interface to provide the user with a corresponding operation portal for the user to choose to agree or refuse the automatic decision result; if the user chooses to refuse, the expert decision process is entered.
[0034] Embodiment 1
[0035] According to the embodiments of the present application, an embodiment of a database connection method is also provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in an order different from that shown herein.
[0036] The method embodiment provided by the embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing the database connection method is shown. As Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor (MCU) or a field-programmable gate array (FPGA), etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output (I / O) interface, a Universal Serial Bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0037] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0038] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the database connection method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the aforementioned database connection method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0039] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network interface controller (NIC) that can be connected to other network devices through a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module that is configured to communicate with the Internet wirelessly.
[0040] The display can be a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or a mobile device).
[0041] In the above operating environment, the present application provides a database connection method as shown in Figure 2 Figure 2 FIG. 1 is a flowchart of the database connection method according to an embodiment of the present application.
[0042] In step S201, when receiving a domain name resolution request sent by a target application, a target domain name is extracted from the domain name resolution request, wherein the target domain name is configured in a network connection of the target application, and the target domain name has a mapping relationship with a plurality of computing node sets of a database.
[0043] Optionally, an electronic device, an application system, a server, and the like can be taken as an execution subject of the present application. In the embodiment, a target processing system is taken as the execution subject to execute the above database connection method, and the target processing system can include a database.
[0044] In an optional embodiment, the target application can also be understood as a client. When the target application needs to access the database, the target application sends a domain name resolution request to the target processing system to request a network address (i.e., an IP address) of a computing node in the database. Optionally, the database is a distributed database, and the database includes a plurality of computing nodes. The computing node is a node responsible for processing business logic and user requests. The computing node can perform operations such as optimization of SQL (Structured Query Language) queries, generation of execution plans, and integration of data.
[0045] Optionally, the domain name resolution request contains a smart domain name (i.e., target domain name) that the target application wants to access, which is a simple identifier used to replace a complex static IP list in the application configuration, and which has a mapping relationship with a plurality of computing node sets in the database. For example, in the target application, the smart domain name and the computing node set that the target application expects to access can be specified by a JDBC (Java Database Connectivity) URL, which can be represented as follows: "jdbc:mysql: / / smartdb.company.cn?cnGroup=lj_a&backCnGroup=lj_b". Among them, "smartdb.company.cn" is the smart domain name, "lj_a" is the primary computing node set that the target application expects to access, and "lj_b" is the backup computing node set that the target application expects to access. The computing node set includes a plurality of computing nodes in the database, the computing nodes in different computing node sets are different, and different computing node sets can be deployed in different parks. The target application can initiate a domain name resolution request through the smart domain name specified in the JDBC URL (i.e., network connection) or similar database connection configuration file.
[0046] In step S202, the network address of the computing node in the plurality of computing node sets associated with the target domain name is determined, wherein the health degree value of the computing node in the computing node set is greater than a preset degree value.
[0047] In an optional embodiment, a domain name resolution table can be maintained in the target processing system, which is used to record the association between the target domain name and the plurality of computing node sets, and the computing nodes and their network addresses included in each computing node set.
[0048] The content of the domain name resolution table can be dynamically changed. Specifically, the computing nodes included in the computing node set in the domain name resolution table are dynamically changed according to the health degree value. For example, the system periodically monitors the health status of each CN, and when a node failure is detected, the CN is temporarily excluded from the corresponding CNGroup (computing node set), and the smart domain name resolution record is updated, i.e., the domain name resolution table is updated, and then the failed node is retained in the "to be recovered list" for subsequent recovery.
[0049] Optionally, the health degree value of the computing node can be determined in real time according to the running index of the node, and the running index of the node can include at least one of the following: delay, QPS (Queries Per Second), load rate, and packet loss rate.
[0050] In step S203, the network address of the computing node in the plurality of computing node sets is sent to the target application, and the target application connects to the database based on the network address.
[0051] Optionally, the system can feed back the network address of the screened healthy computing node to the target application.
[0052] In an optional embodiment, after the application program receives the network addresses, it can directly establish a database connection based on the network addresses to access the required data resource.
[0053] In another optional embodiment, after the application program receives the network addresses, it can determine the network address to which a database connection needs to be established based on the computing node set specified in the URL, and then connect to the network address. For example, the target application screens the network addresses belonging to the computing node set in the URL from the received network addresses, and then establishes a database connection based on the screened network addresses. The IP addresses of the computing nodes in the computing node set specified in the URL can be preset in the application program.
[0054] For example, the target application automatically selects the nearest CNGroup (such as a park) according to the resolution result of the intelligent domain name, and switches to the standby group node computing set without sensing when the main group computing node set fails.
[0055] In the embodiments of the present application, by configuring the target domain name in the network connection of the target application, and designing a mapping relationship between the target domain name and the plurality of computing node sets of the database, in the case of receiving a domain name resolution request, the network address of the database computing node is fed back to the target application based on the target domain name, which realizes that in the scenario of establishing a database connection, the application does not need to directly configure the network address of the computing node, and only needs to configure a unique target domain name to obtain the network address of the database node to which it needs to connect, thereby effectively reducing the complexity of configuration and maintenance and reducing the configuration cost. In addition, by associating the computing node with a health degree value greater than a preset degree value with the target domain name, the target application side is prevented from establishing a database connection with a faulty or busy computing node, thereby improving the reliability of the database connection.
[0056] Therefore, the method provided in the present application achieves the purpose of configuring a single domain name in the network connection of the application to realize database connection, achieves the technical effect of reducing the configuration cost, and solves the technical problem of high configuration cost in the related art when the application accesses the database, that is, the IP addresses of all the database nodes that the application can connect to need to be configured in the network connection of the application.
[0057] Optionally, in the database connection method provided in the embodiments of the present application, before determining the network address of the computing node in the set of computing nodes associated with the target domain name, the method further comprises: collecting a running index of the computing node; and determining a health degree value of the computing node based on the running index of the computing node.
[0058] Optionally, the target processing system can periodically or continuously monitor each CN to obtain the above-mentioned index data through a network interface, an operating system interface or a special monitoring agent software. The running index can include at least one of the following: network delay, query per second, memory usage, packet loss rate, which reflect the real-time performance and health status of the computing node.
[0059] After obtaining the running index, the health degree value of the computing node is determined based on the running index of the computing node. For example, according to a preset weight model, the multiple indexes are converted into a numerical value for evaluating the overall health status of the computing node. For another example, the running index value is substituted into a preset health degree value calculation formula to obtain the health degree value.
[0060] It should be noted that, by the above manner, the system can continuously monitor and evaluate the running state of the computing node, so that the performance change can be captured and responded in time, thereby improving the reliability of the database connection.
[0061] Optionally, in the database connection method provided in the embodiments of the present application, the health degree value of the computing node is determined based on the running index of the computing node, comprising: determining a delay index of the computing node from the running index, and calculating a first health sub-value of the computing node based on the delay index and a first weight value; determining a load index of the computing node from the running index, and calculating a second health sub-value of the computing node based on the load index and a second weight value; determining a packet loss rate of the computing node from the running index, and calculating a third health sub-value of the computing node based on the packet loss rate and a third weight value; and determining the health degree value of the computing node based on at least one of the first health sub-value, the second health sub-value and the third health sub-value.
[0062] In an optional embodiment, the target processing system can extract a delay-related parameter from the running index. The delay index reflects the time for the computing node to process a request, and the delay index can include at least one of the following: network delay, processing delay. For example, in the case where the delay index includes the processing delay, the delay data is converted into a standardized delay index, for example, a ratio between the delay and a normal value (i.e. a delay reference value) can be calculated to obtain a first numerical value latency_ratio. Then w1 x (1-latency_ratio) is calculated to obtain the first health sub-value, where w1 is the first weight value.
[0063] In an optional embodiment, the load indicator can include at least one of a CPU (Central Processing Unit) occupancy rate and a memory occupancy rate. For example, in the case where the load indicator includes the CPU occupancy rate, a ratio between the CPU occupancy rate and a maximum CPU occupancy rate allowed is calculated to obtain a second value load_ratio, and then w2×(1-load_ratio) is calculated to obtain a second health sub-value. The aforementioned w2 is a second weight value.
[0064] In an optional embodiment, the packet loss rate is an important indicator for measuring data transmission reliability. If the packet loss rate is too high, it may mean that the network connection is unstable or the node processing is abnormal. The target processing system can statistically calculate the average packet loss rate of the computing node within a certain time, and then convert the packet loss rate into a standardized packet loss rate, for example, calculate a ratio between the average packet loss rate and a normal value (i.e., a packet loss rate reference value) to obtain a third value error_rate. Then w3×(1-error_rate) is calculated to obtain a third health sub-value, and the aforementioned w3 is a third weight value.
[0065] After obtaining the first health sub-value, the second health sub-value, and the third health sub-value, the first health sub-value, the second health sub-value, and the third health sub-value can be added to obtain a health degree value. That is, the health degree value Health can be represented as follows:
[0066] Health=w1×(1-latency_ratio)+w2×(1-load_ratio)+w3×(1-error_rate);
[0067] Optionally, the first weight value, the second weight value, and the third weight value described above can be preset values.
[0068] It should be noted that by performing health evaluation on the computing node based on the multi-dimensional performance indicators, the accuracy of the health degree value obtained can be effectively improved.
[0069] Optionally, in the database connection method provided in the embodiments of the present application, after determining the health degree value of the computing node based on the running indicators of the computing node, the method further includes: in the case where the health degree value of the computing node is less than or equal to a preset degree value, determining whether there is a computing node set including the computing node; and in the case where there is a computing node set including the computing node, removing the computing node from the computing node set.
[0070] Optionally, after the calculation of the health degree value of the computing node is completed, it is further determined whether the value is lower than a preset health threshold (i.e., a preset degree value). If the health degree value of the computing node is lower than the preset degree value, it means that the node is currently in an unstable state or has poor performance and is no longer suitable for receiving a new connection request. In this case, it is determined whether there is a CNGroup (i.e., a computing node set) including the computing node. If the node indeed belongs to a certain CNGroup, the computing node is removed from the CNGroup; if it does not belong to any CNGroup, no further measures need to be taken.
[0071] It should be noted that in this way, the CN node with a health degree value lower than the preset threshold can be identified and isolated in real time, avoiding its continuous reception of connection requests, reducing the failure rate and delay of the overall system, and thus the reliability of the database connection can be improved.
[0072] Optionally, in the database connection method provided in the embodiments of the present application, the network address of the computing node in the plurality of computing node sets associated with the target domain name is determined, including: obtaining a domain name resolution table matched with the target domain name, and determining the network address of the computing node in the plurality of computing node sets associated with the target domain name from the domain name resolution table; after the computing node is removed from the computing node set, the method further includes: deleting the network address of the computing node from the domain name resolution table.
[0073] Optionally, the target processing system can maintain a domain name resolution table, which records the mapping relationship between each intelligent domain name and a plurality of CNGroups, and the network address of the CN node in each CNGroup. When a resolution request of a target domain name is received, the system looks up the domain name resolution table, extracts the CNGroup information associated with the domain name and the network address of the CN node.
[0074] When a certain CN node is identified as unhealthy and removed from the CNGroup to which it belongs, in order to enable subsequent application requests to be resolved to the latest computing node set state, the domain name resolution table can be updated to remove the network address of the CN node. So as to avoid the application from obtaining the network address of the unhealthy node.
[0075] In an optional embodiment, each CNGroup corresponds to a set of serviceable CN nodes, and the meta information of the CNGroup can be uniformly maintained by an operation and maintenance personnel. When the CN node is added, removed, migrated or maintained, the grouping can be dynamically modified. After each CNGroup update, instant synchronization of the domain name resolution table is triggered, so that the application side always returns the latest healthy node. The JDBC driver automatically performs connection switching after detecting the domain name change, without the need to restart the application.
[0076] It should be noted that by removing the CN node from the CNGroup and synchronously updating the domain name resolution table when the health value of the CN node is lower than the preset threshold, the system can effectively isolate the faulty node in time, cut off the connection between the faulty node and the target application, and thus improve the reliability of the database connection.
[0077] Optionally, in the database connection method provided in the embodiments of the present application, after determining the health value of the computing node based on the running index of the computing node, the method further includes: in the case where the health value of the computing node is greater than a preset degree value, determining whether there is a computing node set including the computing node; and in the case where there is no computing node set including the computing node, adding the computing node to the computing node set.
[0078] Optionally, after the health value of the computing node is determined, it is determined whether the value exceeds a preset health threshold (i.e., the preset degree value). If the health value is higher than the threshold, it means that the computing node is in a good running state and can effectively process database requests. Then, the system confirms whether the CN node in the good health state belongs to a certain CNGroup. For a newly deployed or just recovered CN node, it needs to be added to a CNGroup.
[0079] Optionally, if it is determined that the healthy computing node is not added to any CNGroup, the system adds the computing node to a CNGroup to expand the processing capacity of the cluster and improve load balancing. Conversely, if it is determined that the healthy computing node is added to any CNGroup, no subsequent processing is performed.
[0080] In an optional embodiment, the computing node can be added to the computing node set that it has ever joined. If the computing node has never been added to the computing node set before, the computing node set of the park to which the computing node belongs can be determined as the computing node set to which the computing node needs to be added.
[0081] It should be noted that by the above method, the CN node in the good health state is added to the computing node set in time, and whether it is a newly deployed node or a recovered node, it can be quickly put into service, thereby improving the reliability of the database connection. For the application layer, the addition of the new node is automatic and imperceptible, and the application still accesses through the intelligent domain name, without the need to change any configuration, so that the enhanced service performance and stability can be enjoyed, thereby effectively reducing the configuration cost.
[0082] Optionally, in the database connection method provided in the embodiments of the present application, in the case where the computing node set updating instruction is received, the computing node set updating instruction is used to determine a computing node set from the plurality of computing node sets, and a target computing node set is obtained; and the target computing node set is updated based on the update operation in the computing node set updating instruction, and an updated target computing node set is obtained.
[0083] The database administrator may issue an updating instruction of a computing node set (CNGroup) according to the database performance requirement, the CN node state change or the system architecture adjustment, so as to optimize the database service. The computing node set updating instruction may include adding or deleting a CN node, or changing the priority and attribute of the CN node.
[0084] After the system receives the computing node set updating instruction, the identifier of the CNGroup (such as lj_a) is extracted therefrom, and the specific CNGroup is located according to the identifier. After the target CNGroup is determined, the system starts to execute the specific operation described in the updating instruction, such as adding or deleting a CN node, so as to achieve the optimization target of the CNGroup.
[0085] It should be noted that, by the above method, the flexibility of the computing node set is realized, so as to improve the flexibility and adaptability of the database connection scheme.
[0086] In an optional embodiment, Figure 3 is a schematic diagram of a target processing system according to the embodiments of the present application, such as Figure 3As shown, the target processing system can include an intelligent domain name resolution unit, a CNGroup management unit, a computing node, a storage node unit, and a fault detection and synchronization unit. The target application accesses the database through the JDBC URL to specify the intelligent domain name and CNGroup information, and the target application automatically selects the nearest CNGroup (such as a park) according to the resolution result of the intelligent domain name, and switches to the standby group without sensing when the main group fails. The intelligent domain name resolution unit provides a unified database access entry for the target application, exposes the intelligent domain name (such as smartdb.company.cn) to the outside, and maps it to multiple CNGroups. The CNGroup management unit is used to define CN groups, each CNGroup corresponds to a set of serviceable CN nodes, and the meta information of the CNGroup is uniformly maintained by the operation and maintenance personnel. When the CN node is added, removed, migrated or maintained, the group can be dynamically modified. The computing node is a node in the database responsible for processing business logic and user requests, and multiple computing nodes are deployed in each park. The storage node unit is used to store data and execute the SQL tasks distributed by the computing node. The fault detection and synchronization unit is used to periodically monitor the health status of each CN, temporarily exclude the CN from the corresponding CNGroup when a node failure is detected, update the domain name resolution table, and keep the failed node in the "to be restored list" for subsequent regression. The fault detection and synchronization unit includes an index collection unit, a health degree calculation unit, a group reconstruction unit, and a domain name synchronization unit. The index collection unit is used to periodically collect the running indexes (such as delay, QPS, load rate, packet loss rate, etc.) of each CN. The health degree calculation unit is used to calculate the comprehensive health score of each CN according to the running indexes. The group reconstruction unit is used to temporarily remove a CN from the CNGroup when the health degree of the CN is lower than the threshold T1, and rejoin when the health degree is restored. The domain name synchronization unit is used to trigger the real-time synchronization of the domain name resolution table after each CNGroup update, so that the application side always returns the latest healthy node.
[0087] In an optional embodiment, the target processing system can perform the following steps to implement the database connection method in this embodiment:
[0088] Step 1, the application initiates a connection to the database client, specifies the intelligent domain name and CNGroup information based on the JDBC URL, and the application only needs to configure the intelligent domain name and the logical group name, without needing to care about the specific IP, realizing seamless switching and access transparency.
[0089] Step 2, a unified logical access portal is provided through the intelligent domain name resolution unit, and the intelligent domain name is exposed to the outside, and the module dynamically updates the resolution result according to the grouping state provided by the CNGroup management unit: when the CN node is added or deleted, the DNS (Domain Name System) is automatically synchronized; when the CN fails, the DNS automatically excludes the corresponding IP. At the same time, the main CNGroup+backup CNGroup mapping is maintained internally to realize cross-park high availability. Support monitoring and delay monitoring for dynamic optimization of access path.
[0090] Step 3, the CN grouping is managed by the CNGroup management unit based on a declaration similar to DDL (Data Definition Language), which is uniformly maintained by the operation and maintenance personnel, dynamically adds or deletes nodes, synchronizes the grouping state in real time, automatically resolves the fault node, and synchronizes the state with the intelligent domain name resolution module.
[0091] Step 4, the fault detection and synchronization unit periodically monitors the health status of each CN, the index collection unit collects CN node performance indicators, and the health degree calculation unit and the grouping reconstruction unit dynamically adjust the CNGroup member structure and priority allocation to realize global access optimal path selection, avoid manual maintenance and misoperation, and improve the cross-park database access performance and stability.
[0092] Step 5, when step 4 detects a fault condition, the CNGroup management unit removes the fault node, and the intelligent domain name resolution unit is updated synchronously, and the application is re-resolved through the domain name to automatically connect the healthy node; in the case of excessive load, etc., a new node can be expanded through the CNGroup management unit, and the intelligent domain name is updated synchronously, and the application side is connected without sensing changes.
[0093] Step 6, if all can be normally accessed, there is no fault, etc., the application directly accesses the CN node corresponding to the CNGroup; if there is a fault, etc., the fault can be repaired and automatically re-joined to the CN node corresponding to the CNGroup.
[0094] Therefore, the method provided by the application achieves the purpose of configuring a single domain name in the network connection of the application to realize database connection, realizes the technical effect of reducing configuration cost, and solves the technical problem of high configuration cost in the related art when the application accesses the database.
[0095] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0096] Embodiment 2
[0097] The embodiment of the present application also provides a database connection apparatus. It should be noted that the database connection apparatus of the embodiment of the present application can be used to execute the database connection method provided by the embodiment of the present application. The database connection apparatus provided by the embodiment of the present application is introduced as follows.
[0098] According to the embodiment of the present application, a device for implementing the above-mentioned database connection method is also provided, as shown in Figure 4 The device comprises:
[0099] The extraction module 401 is configured to extract a target domain name from the domain name resolution request in a case where the domain name resolution request sent by the target application is received, wherein the target domain name is configured in the network connection of the target application, and the target domain name has a mapping relationship with a plurality of computing node sets of a database.
[0100] The first determination module 402 is configured to determine the network address of the computing node in the plurality of computing node sets associated with the target domain name, wherein the health degree value of the computing node in the computing node set is greater than a preset degree value.
[0101] The sending module 403 is configured to send the network address of the computing node in the plurality of computing node sets to the target application, wherein the target application connects to the database based on the network address.
[0102] Therefore, the method provided by the present application achieves the purpose of configuring a single domain name in the network connection of the application to realize the database connection, realizes the technical effect of reducing the configuration cost, and solves the technical problem of high configuration cost in the related art that all IP addresses of the database nodes that the application can connect need to be configured in the network connection of the application when the application accesses the database.
[0103] Optionally, in the database connection apparatus provided by the embodiment of the present application, the database connection apparatus further comprises: a collection module configured to collect the running index of the computing node; and a second determination module configured to determine the health degree value of the computing node based on the running index of the computing node.
[0104] Optionally, in the database connection apparatus provided by the embodiment of the present application, the second determining module further comprises: a first calculating submodule, configured to determine a delay index of the computing node from the running index, and calculate a first health sub-value of the computing node based on the delay index and a first weight value; a second calculating submodule, configured to determine a load index of the computing node from the running index, and calculate a second health sub-value of the computing node based on the load index and a second weight value; a third calculating submodule, configured to determine a packet loss rate of the computing node from the running index, and calculate a third health sub-value of the computing node based on the packet loss rate and a third weight value; and a first determining submodule, configured to determine the health degree value of the computing node based on at least one of the first health sub-value, the second health sub-value and the third health sub-value.
[0105] Optionally, in the database connection apparatus provided by the embodiment of the present application, the database connection apparatus further comprises: a first judging module, configured to judge whether there is a computing node set comprising the computing node in the case that the health degree value of the computing node is less than or equal to a preset degree value; and a removing module, configured to remove the computing node from the computing node set in the case that there is the computing node set comprising the computing node.
[0106] Optionally, in the database connection apparatus provided by the embodiment of the present application, the first determining module further comprises: a second determining submodule, configured to acquire a domain name resolution table matched with the target domain name, and determine the network address of the computing node in the computing node set associated with the target domain name from the domain name resolution table; and the database connection apparatus further comprises: a deleting module, configured to delete the network address of the computing node from the domain name resolution table.
[0107] Optionally, in the database connection apparatus provided by the embodiment of the present application, the database connection apparatus further comprises: a second judging module, configured to judge whether there is a computing node set comprising the computing node in the case that the health degree value of the computing node is greater than a preset degree value; and a processing module, configured to add the computing node to the computing node set in the case that there is no computing node set comprising the computing node.
[0108] Optionally, in the database connection apparatus provided by the embodiment of the present application, the database connection apparatus further comprises: a third determining module, configured to determine a computing node set pointed to by a computing node set updating instruction from the plurality of computing node sets in the case that the computing node set updating instruction is received, to obtain a target computing node set; and an updating module, configured to perform updating processing on the target computing node set based on an updating operation in the computing node set updating instruction, to obtain an updated target computing node set.
[0109] It should be noted that the extraction module 401, the first determination module 402 and the sending module 403 correspond to steps S201 to S203 in Embodiment 1, and the three modules have the same instances and application scenarios as the corresponding steps, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware components or software components stored in the memory (for example, the memory 104) and processed by one or more processors (for example, the processors 102a, 102b,..., 102n), and the above modules can also be run in the computer terminal 10 provided in Embodiment 1 as part of the device.
[0110] Embodiment 3
[0111] Embodiments of the present application can provide an electronic device, Figure 5 is a structural block diagram of an electronic device according to an embodiment of the present application. As Figure 5 indicated, the electronic device can include one or more (only one is shown in the figure) processors 1002, a memory 1004, a storage controller, and a peripheral interface, wherein the peripheral interface is connected with a radio frequency module, an audio module, and a display. Figure 5
[0112] The memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functions and data processing by running the software programs and modules stored in the memory, that is, implements the above-mentioned methods. The memory can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory can further include a memory remotely arranged with respect to the processor, and the remote memory can be connected to the terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0113] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: in the case that a domain name resolution request sent by a target application is received, extracting a target domain name from the domain name resolution request, wherein the target domain name is configured in the network connection of the target application, and the target domain name has a mapping relationship with a plurality of computing node sets of a database; determining the network address of the computing node in the plurality of computing node sets associated with the target domain name, wherein the health degree value of the computing node in the computing node set is greater than a preset degree value; sending the network address of the computing node in the plurality of computing node sets to the target application, wherein the target application connects with the database based on the network address.
[0114] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: collecting running indexes of the computing nodes in the computing node set associated with the target domain name before determining the network addresses of the computing nodes; and determining the health degree values of the computing nodes based on the running indexes of the computing nodes.
[0115] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: determining a delay index of the computing node from the running indexes, and calculating a first health sub-value of the computing node based on the delay index and a first weight value; determining a load index of the computing node from the running indexes, and calculating a second health sub-value of the computing node based on the load index and a second weight value; determining a packet loss rate of the computing node from the running indexes, and calculating a third health sub-value of the computing node based on the packet loss rate and a third weight value; and determining the health degree value of the computing node based on at least one of the first health sub-value, the second health sub-value and the third health sub-value.
[0116] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: after determining the health degree value of the computing node based on the running indexes of the computing node, if the health degree value of the computing node is less than or equal to a preset degree value, determining whether there is a computing node set including the computing node; and if there is the computing node set including the computing node, removing the computing node from the computing node set.
[0117] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: determining the network addresses of the computing nodes in the computing node set associated with the target domain name, including: obtaining a domain name resolution table matched with the target domain name, and determining the network addresses of the computing nodes in the computing node set associated with the target domain name from the domain name resolution table; and after removing the computing node from the computing node set, the method further includes: deleting the network address of the computing node from the domain name resolution table.
[0118] The processor can further call information and application programs stored in the memory through the transmission device to perform the following steps: after determining the health degree value of the computing node based on the running indexes of the computing node, if the health degree value of the computing node is greater than a preset degree value, determining whether there is a computing node set including the computing node; and if there is not the computing node set including the computing node, adding the computing node to the computing node set.
[0119] The processor can call information and application programs stored in the memory through the transmission device to perform the following steps: in the case of receiving a computing node set update instruction, determining a computing node set pointed to by the computing node set update instruction from a plurality of computing node sets, to obtain a target computing node set; updating the target computing node set based on the update operation in the computing node set update instruction to obtain an updated target computing node set.
[0120] In the embodiment of the present application, by configuring the target domain name in the network connection of the target application, and designing a mapping relationship between the target domain name and the plurality of computing node sets of the database, in the case of receiving a domain name resolution request, the network address of the database computing node is fed back to the target application based on the target domain name, which realizes that in the database connection establishment scenario, the application does not need to directly configure the network address of the computing node, and only needs to configure a unique target domain name to obtain the network address of the database node it needs to connect, thereby effectively reducing the complexity of configuration and maintenance, and reducing the configuration cost. In addition, by associating the computing node with a health degree value greater than a preset degree value with the target domain name, the target application side is prevented from establishing a database connection with a faulty or busy computing node, thereby improving the reliability of the database connection.
[0121] Therefore, the method provided in the present application achieves the purpose of configuring a single domain name in the network connection of the application to realize the database connection, achieves the technical effect of reducing the configuration cost, and solves the technical problem of high configuration cost in the related art when the application accesses the database, that is, the IP addresses of all the database nodes that the application can connect need to be configured in the network connection of the application.
[0122] Those skilled in the art can understand that Figure 5 The structure shown is only schematic, and the electronic device can also be a terminal device such as a smart phone, a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, and the like. Figure 5 It does not limit the structure of the above-mentioned electronic device. For example, the electronic device can further include more or less components (such as a network interface, a display device, and the like) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 5 For example, the electronic device can further include more or less components (such as a network interface, a display device, and the like) than those shown in the figure, or have a different configuration from that shown in the figure. Figure 5 For example, the electronic device can further include more or less components (such as a network interface, a display device, and the like) than those shown in the figure, or have a different configuration from that shown in the figure.
[0123] Those skilled in the art can understand that all or part of the steps of various methods in the above embodiments can be completed by instructing the terminal device related hardware through a program, and the program can be stored in a computer readable storage medium, which can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0124] Embodiment 4
[0125] The embodiments of the present application further provide a storage medium. Optionally, in the embodiments, the storage medium can be used to store the program code executed by the database connection method provided in the embodiment 1.
[0126] Optionally, in the embodiments, the storage medium can be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.
[0127] The present application further provides a computer program product, which, when executed on a data processing device, is adapted to execute the steps of the database connection method.
[0128] The serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.
[0129] In the above embodiments of the present application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0130] In the several embodiments provided by the present application, it should be understood that the disclosed technology can be implemented in other ways. Of course, the unit described as the division is only a logical function division, and there can be another division way in actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, unit or module, and can be electrical or other forms.
[0131] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiments.
[0132] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0133] When the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in the form of a contribution to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes various media that can store program codes, such as a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, etc.
[0134] The above is only the preferred embodiment of the present application, and it should be pointed out that, for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should be considered as the protection scope of the present application.
Claims
1. A database connection method, characterized in that, include: Upon receiving a domain name resolution request from the target application, the target domain name is extracted from the domain name resolution request. The target domain name is configured in the network connection of the target application, and the target domain name has a mapping relationship with multiple sets of computing nodes in the database. Determine the network address of the computing node in the set of multiple computing nodes associated with the target domain name, wherein the health status value of the computing node in the set of computing nodes is greater than a preset status value; The network addresses of the computing nodes in the plurality of computing node sets are sent to the target application, wherein the target application connects to the database based on the network addresses.
2. The method according to claim 1, characterized in that, Before determining the network addresses of the computing nodes in the set of multiple computing nodes associated with the target domain name, the method further includes: Collect the operational metrics of the computing nodes; The health status value of the computing node is determined based on its operational metrics.
3. The method according to claim 2, characterized in that, The health status value of the computing node is determined based on its operational metrics, including: The latency index of the computing node is determined from the operational metrics, and the first health sub-value of the computing node is calculated based on the latency index and the first weight value. The load index of the computing node is determined from the operating indicators, and the second health sub-value of the computing node is calculated based on the load index and the second weight value. The packet loss rate of the computing node is determined from the operational metrics, and the third health sub-value of the computing node is calculated based on the packet loss rate and the third weight value. The health status value of the computing node is determined based on at least one of the first health sub-value, the second health sub-value, and the third health sub-value.
4. The method according to claim 2, characterized in that, After determining the health status value of the computing node based on its operational metrics, the method further includes: If the health status value of the computing node is less than or equal to the preset status value, determine whether there exists a set of computing nodes that includes the computing node. If a set of compute nodes exists that includes the compute node, remove the compute node from that set of compute nodes.
5. The method according to claim 4, characterized in that, Determining the network addresses of computing nodes in a set of multiple computing nodes associated with the target domain name includes: Obtain the domain name resolution table matching the target domain name, and determine the network address of the computing node in the set of multiple computing nodes associated with the target domain name from the domain name resolution table; After removing the compute node from the set of compute nodes, the method further includes: Remove the network address of the compute node from the domain name resolution table.
6. The method according to claim 2, characterized in that, After determining the health status value of the computing node based on its operational metrics, the method further includes: If the health status value of the computing node is greater than the preset status value, determine whether there exists a set of computing nodes that includes the computing node. If there is no set of computing nodes that includes the computing node, add the computing node to the set of computing nodes.
7. The method according to claim 1, characterized in that, The method further includes: Upon receiving a compute node set update instruction, the compute node set to which the compute node set update instruction points is determined from the plurality of compute node sets to obtain the target compute node set; The target computing node set is updated based on the update operation in the computing node set update instruction to obtain the updated target computing node set.
8. A database connection device, characterized in that, include: An extraction module is used to extract a target domain name from a domain name resolution request sent by a target application upon receiving such a request. The target domain name is configured in the network connection of the target application, and the target domain name has a mapping relationship with a set of multiple computing nodes in the database. The first determining module is used to determine the network address of the computing node in the set of multiple computing nodes associated with the target domain name, wherein the health status value of the computing node in the set of computing nodes is greater than a preset status value; The sending module is used to send the network addresses of the computing nodes in the plurality of computing node sets to the target application, wherein the target application connects to the database based on the network addresses.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the database connection method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program executes the database connection method according to any one of claims 1 to 7 when it runs.