Server health detection method and device, computer equipment and storage medium

By saving the virtual routing table identifier in the task structure of the target kernel and intercepting the socket function call, a socket for the specified VRF is created, which solves the problem of high resource consumption in the existing technology and realizes efficient health detection.

CN120743518APending Publication Date: 2025-10-03HANGZHOU DPTECH TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510854031.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-10-03

AI Technical Summary

Technical Problem

In network isolation scenarios with security requirements, existing technologies cannot effectively create sockets for designated virtual routing tables (VRFs), resulting in high resource consumption in the health detection process, especially in the case of multiple database servers, which puts a heavy burden on the equipment.

Method used

By saving the virtual routing table identifier of the database server in the task structure of the target kernel corresponding to the target thread and intercepting it when the socket function is called, a socket of the specified VRF is created and health detection is performed using the target thread.

Benefits of technology

The consumption of computing resources is reduced, especially in the case of multiple database servers, which significantly reduces the burden on equipment and ensures the execution of the health detection process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120743518A_ABST
    Figure CN120743518A_ABST
Patent Text Reader

Abstract

The invention provides a server health detection method and device, computer equipment and a storage medium, and the method comprises the steps: starting a target thread for carrying out health detection on a database server according to server information of the database server; searching a task structure body of a target kernel corresponding to the target thread based on the first identifier of the target thread, and storing a second identifier of a virtual routing forwarding table to which the database server belongs to the task structure body; when it is detected that the target thread calls a socket function to create a socket, calling of the socket function is intercepted, and the socket is created in a target kernel corresponding to the target thread according to parameters of the socket function; reading a second identifier from a task structure body corresponding to the target kernel, and setting a virtual routing forwarding table to which the socket belongs based on the second identifier; and performing health detection on the database server in the virtual routing forwarding table to which the socket belongs by utilizing the target thread.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a server health detection method, apparatus, computer equipment, and storage medium. Background Art

[0002] Load balancing technology determines the service availability of servers by performing health checks on them. This health check mechanism improves overall service availability and prevents server anomalies from impacting overall services. With the health check function enabled, if a server experiences an anomaly during a health check, the load balancing service will automatically distribute new requests to other servers with normal health checks. Once the server returns to normal operation, the load balancing technology will automatically restore it to the load balancing service. In related technologies, a health check process can be started for each server to perform health checks on the server. This health check process requires the creation of a socket for network communication.

[0003] In security-critical scenarios, to achieve network isolation for different scenarios, multiple virtual routing forwarding tables (VRFs) can be created on network devices. Each VRF has its own routing table and network interface, and VRFs are isolated from each other by default. In this case, a socket must specify a VRF to communicate within the corresponding VRF. Therefore, it is particularly important to develop a method for creating a socket that specifies a VRF. Summary of the Invention

[0004] In view of this, the present application provides a server health detection method, apparatus, computer equipment and storage medium.

[0005] Specifically, this application is implemented through the following technical solutions:

[0006] This embodiment of the present application provides a server health detection method, including:

[0007] Starting a target thread for performing health detection on the database server according to the server information of the database server;

[0008] Searching for a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and saving the second identifier of the virtual routing table to which the database server belongs to the task structure;

[0009] When detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function, and creating a socket in a target kernel corresponding to the target thread according to parameters of the socket function;

[0010] Reading the second identifier from the task structure corresponding to the target kernel, and setting the virtual routing forwarding table to which the socket belongs based on the second identifier;

[0011] The target thread is used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0012] Optionally, after creating a socket in the target kernel corresponding to the target thread, the method further includes:

[0013] Get the thread ID of the current thread;

[0014] When it is determined that the thread identifier matches the first identifier, determining whether the created socket is a socket of the target type according to the parameters of the socket function;

[0015] The step of reading the second identifier from the task structure corresponding to the target kernel and setting the virtual routing table to which the socket belongs based on the second identifier includes:

[0016] When it is determined that the socket is a socket of the target type, the second identifier is read from the task structure corresponding to the target kernel, and the virtual routing forwarding table to which the socket belongs is set based on the second identifier.

[0017] Optionally, determining whether the created socket is a socket of a target type according to parameters of the socket function includes:

[0018] Determining whether the parameter information of the parameter matches the preset information corresponding to the parameter;

[0019] If so, it is determined that the created socket is a socket of the target type.

[0020] Optionally, searching for a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and saving the second identifier of the virtual routing table to which the database server belongs to the task structure, includes:

[0021] Creating a target system call, wherein parameters of the target system call include the second identifier;

[0022] Based on the first identifier, determining a task structure of a target kernel corresponding to the target thread, wherein an identification field for storing a virtual routing forwarding table identifier is newly added to the task structure;

[0023] The target system call is used to save the second identifier into the identifier field of the task structure.

[0024] Optionally, the socket is stored in the target kernel in the form of a socket structure, and a target field for representing an identifier of a virtual routing forwarding table is provided in the socket structure; and setting the virtual routing forwarding table to which the socket belongs based on the second identifier includes:

[0025] The second identifier is set in the target field of the socket structure, wherein the virtual routing forwarding table corresponding to the second identifier is the virtual routing forwarding table to which the socket belongs.

[0026] Optionally, when detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function, and creating a socket in a target kernel corresponding to the target thread according to parameters of the socket function, includes:

[0027] When detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function and controlling the system running state to enter the kernel state from the user state;

[0028] In the kernel state, a socket is created in the target kernel corresponding to the target thread according to the parameters of the socket function.

[0029] Optionally, performing a health check on the database server in the virtual routing forwarding table to which the socket belongs by using the target thread includes:

[0030] After determining the virtual routing table to which the socket belongs, the control system operating state enters the user state from the kernel state;

[0031] Get the file descriptor generated in kernel mode to indicate the socket;

[0032] According to the file descriptor, the target thread is used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0033] The present application also provides a server health detection device, including:

[0034] A startup module, configured to start a target thread for performing health detection on the database server according to server information of the database server;

[0035] A search module, configured to search a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and save the second identifier of the virtual routing table to which the database server belongs to the task structure;

[0036] A creation module, configured to intercept the call of the socket function when detecting that the target thread calls a socket function to create a socket, and create a socket in a target kernel corresponding to the target thread according to parameters of the socket function;

[0037] A setting module, configured to read the second identifier from the task structure corresponding to the target kernel, and set the virtual routing table to which the socket belongs based on the second identifier;

[0038] The detection module is used to use the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0039] The present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the server health detection method described above is implemented.

[0040] This specification provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the server health detection method described above is implemented.

[0041] The method provided by the present application saves the second identifier of the virtual routing forwarding table to which the database server belongs to the task structure of the target kernel corresponding to the target thread, and intercepts the call of the socket function when the target thread calls the socket function to create a socket, and then creates a socket in the target kernel corresponding to the target thread according to the parameters of the socket function. Since the second identifier is stored in the task structure of the target kernel and the information of the socket created in the target kernel can be obtained, after obtaining the second identifier from the task structure of the target kernel, the virtual routing forwarding table to which the socket belongs can be set based on the second identifier, thereby creating a socket of a specified VRF in the target kernel, and the socket can be used by the target thread. Subsequently, the target thread can be used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs, thereby ensuring the execution of the health check process.

[0042] At the same time, in this application, for the database server, the target thread for health detection is started. Compared with the use of processes for health detection in related technologies, it can reduce the consumption of computing resources, especially when there are multiple database servers, which can greatly reduce the consumption of device resources and alleviate the burden on the device. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:

[0044] Figure 1 This is a flow chart of a server health detection method shown in an exemplary embodiment of the present application;

[0045] Figure 2 is a flow chart of a server health detection method shown in another exemplary embodiment of the present application;

[0046] Figure 3 is a schematic diagram of a server health detection device shown in an exemplary embodiment of the present application;

[0047] Figure 4 This is a structural diagram of a computer device provided by this application. DETAILED DESCRIPTION

[0048] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0049] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0050] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0051] In the related art, a system call is provided to modify or set the VRF to which a socket belongs. However, on embedded devices, connection to an Oracle database server is typically done through the Oracle Call Interface (OCI), a C / C++ programming interface provided by Oracle for interacting with the Oracle database. After a process on the embedded device creates a socket, setting the VRF to which the socket belongs through a system call is impossible because the Oracle-provided OCI library is not open source, making it impossible to specify the socket's VRF by modifying the source code.

[0052] In order to alleviate the above problems, the present application saves the second identifier of the virtual routing forwarding table to which the database server belongs to the task structure of the target kernel corresponding to the target thread, and intercepts the call of the socket function when the target thread calls the socket function to create a socket, and then creates a socket in the target kernel corresponding to the target thread according to the parameters of the socket function. Since the second identifier is stored in the task structure of the target kernel and the information of the socket created in the target kernel can be obtained, after obtaining the second identifier from the task structure of the target kernel, the virtual routing forwarding table to which the socket belongs can be set based on the second identifier, thereby creating a socket of a specified VRF in the target kernel, and the socket can be used by the target thread. Subsequently, the target thread can be used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs to ensure the execution of the health check process.

[0053] At the same time, in this application, for the database server, the target thread for health detection is started. Compared with the use of processes for health detection in related technologies, it can reduce the consumption of computing resources, especially when there are multiple database servers, which can greatly reduce the consumption of device resources and alleviate the burden on the device.

[0054] To facilitate understanding of the technical solution of the present disclosure, the technical terms used in the embodiments of the present disclosure are first explained:

[0055] Socket: Also commonly known as "socket", it is used to describe IP addresses and ports. It is a handle of a communication chain that can be used to implement communication between different virtual machines or different computers.

[0056] The socket function is a system call that can be used to allocate a socket and its resources based on the specified address family, data type, and protocol.

[0057] VRF is a virtual private network (VPN) routing table (referred to as virtual routing table in this application), also known as VPN-instance. There can be multiple routing tables in a device, each routing table is independent of each other, and the network segments can be the same.

[0058] To facilitate understanding of this embodiment, a server health detection method disclosed in an embodiment of the present disclosure is first described in detail. The server health detection method provided in the embodiment of the present disclosure may be executed by a load balancing device, wherein the load balancing device may be a computer device with certain computing capabilities, such as a terminal device or a server or other processing device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a computing device, etc. In some possible implementations, the server health detection method may be implemented by a processor invoking computer-readable instructions stored in a memory.

[0059] See also Figure 1 FIG. 1 is a flow chart of a server health detection method provided by an embodiment of the present disclosure, wherein the method includes steps S101 to S105, wherein:

[0060] S101: Start a target thread for performing health detection on a database server according to server information of the database server.

[0061] The server information of the database server includes but is not limited to: IP address, port, database server account, password, VRF information, etc. For example, the database server can be a real server that has Oracle database software installed and provides database services.

[0062] Based on the server information of the database server, a target thread for performing health checks is started for the database server. When there are multiple database servers, a target thread for performing health checks can be started for each database server. Exemplarily, a target thread can be started for a database server by calling the pthread_create function.

[0063] S102: searching for a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and saving the second identifier of the virtual routing forwarding table to which the database server belongs to the task structure.

[0064] In the kernel, the task structure task_struct is a very important structure used to represent and manage all information of a process or thread. Generally, each running process or thread has a corresponding task_struct instance.

[0065] During implementation, the task_struct of the target kernel corresponding to the target thread is searched according to the first identifier of the target thread, and the second identifier of the virtual routing forwarding table to which the database server belongs is saved in the task structure.

[0066] Optionally, searching for the task structure of the target kernel corresponding to the target thread based on the first identifier of the target thread, and saving the second identifier of the virtual routing forwarding table to which the database server belongs to the task structure, includes: creating a target system call, wherein the parameters of the target system call include the second identifier; determining the task structure of the target kernel corresponding to the target thread based on the first identifier, wherein an identifier field for saving the virtual routing forwarding table identifier is newly added to the task structure; and using the target system call to save the second identifier to the identifier field of the task structure.

[0067] During implementation, a target system call can be created, the parameters of which include the second identifier; and based on the first identifier, the task structure of the target kernel corresponding to the target thread is determined, wherein a new identification field (i.e., the vrf_id field) is added to the task_struct of the target kernel, which is used to store the VRF identifier.

[0068] The target system call is called. After receiving the target system call request, the target kernel saves the received second identifier to the identifier field of the task_struct of the target kernel (i.e., the vrf_id field of task_struct), thereby binding the second identifier of the VRF to the task_struct structure of the target thread.

[0069] By creating a target system call, the second identifier can be saved in the identifier field of the task_struct of the target kernel more simply and efficiently.

[0070] S103: When it is detected that the target thread calls a socket function to create a socket, the call of the socket function is intercepted, and a socket is created in a target kernel corresponding to the target thread according to parameters of the socket function.

[0071] Exemplarily, the target thread can call the OCI interface and create a socket through the socket function. When the call of the socket function is detected, the call of the socket function is intercepted and the kernel enters the socket creation process, that is, according to the parameters of the socket function, a socket is created in the target kernel corresponding to the target thread.

[0072] Optionally, when it is detected that the target thread calls a socket function to create a socket, the call of the socket function is intercepted, and a socket is created in the target kernel corresponding to the target thread according to the parameters of the socket function, including: when it is detected that the target thread calls a socket function to create a socket, the call of the socket function is intercepted, and the system running state is controlled from user state to kernel state; in the kernel state, a socket is created in the target kernel corresponding to the target thread according to the parameters of the socket function.

[0073] The system is divided into kernel and user states, with the target thread startup process occurring in user state. Upon detecting that the target thread is calling a socket function to create a socket, the system intercepts the call and controls the system's operating state from user state to kernel state, where kernel modifications can be made. In kernel state, the system obtains the parameters of the socket function called by the target thread and, based on the parameters passed in, creates a socket in the target kernel corresponding to the target thread.

[0074] The created socket is stored in the target kernel in the form of a socket structure (i.e., struct sock structure), and a target field for representing the identifier of the virtual routing table is provided in the socket structure. At this time, the target field in the structsock structure is an initialized value (e.g., 0).

[0075] The preceding process creates a socket in the kernel. Subsequently, the kernel can specify a VRF for the socket to implement health monitoring for the database server.

[0076] S104: Read the second identifier from the task structure corresponding to the target kernel, and set the virtual routing table to which the socket belongs based on the second identifier.

[0077] After creating a socket in the target kernel, a VRF to which the socket belongs can be specified. Specifically, a second identifier can be read from the task_struct structure of the target kernel and bound to the socket so that the VRF corresponding to the second identifier is set as the VRF to which the socket belongs.

[0078] Optionally, the socket is stored in the target kernel in the form of a socket structure, and a target field for indicating an identifier of a virtual routing table is provided in the socket structure.

[0079] The setting of the virtual routing forwarding table to which the socket belongs based on the second identifier includes: setting the second identifier in the target field of the socket structure, wherein the virtual routing forwarding table corresponding to the second identifier is the virtual routing forwarding table to which the socket belongs.

[0080] The struct sock structure of the socket is provided with an identification target field for representing the VRF. After the socket is created, the target field is initialized. After obtaining the second identifier, the second identifier can be written to the target field of the struct sock structure to set the VRF corresponding to the second identifier to the VRF to which the socket belongs.

[0081] S105: Utilize the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0082] After creating a socket of the specified VRF in the target kernel, the target thread can be used to perform health checks on the database server in the virtual routing forwarding table to which the socket belongs, so that the load balancing device can allocate task requests based on the health status of the database server.

[0083] Optionally, using the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs, includes: after determining the virtual routing forwarding table to which the socket belongs, controlling the operating state of the system from kernel state to user state; obtaining a file descriptor generated in kernel state for indicating the socket; and based on the file descriptor, using the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0084] After determining the VRF to which the socket belongs, the system's operating state is controlled to enter user mode from kernel mode, and in user mode, the file descriptor generated in kernel mode for indicating the socket is obtained. For example, the return value of the socket generated in kernel mode can be obtained, and this return value can be determined as the file descriptor corresponding to the socket. Since the second identifier of the VRF to which the socket belongs has been updated in the kernel mode, that is, the VRF to which the socket belongs has been specified, the target thread in user mode no longer needs to execute a system call to set the VRF to which the socket belongs. Based on the file descriptor, it can be determined that the socket has been successfully established, and the target thread can be used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0085] The present application saves the second identifier of the virtual routing forwarding table to which the database server belongs in the task structure of the target kernel corresponding to the target thread, and intercepts the call of the socket function when the target thread calls the socket function to create a socket, and then creates a socket in the target kernel corresponding to the target thread according to the parameters of the socket function. Since the second identifier is stored in the task structure of the target kernel and the information of the socket created in the target kernel can be obtained, after obtaining the second identifier from the task structure of the target kernel, the virtual routing forwarding table to which the socket belongs can be set based on the second identifier, thereby creating a socket of a specified VRF in the target kernel, and the socket can be used by the target thread. Subsequently, the target thread can be used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs, thereby ensuring the execution of the health check process.

[0086] At the same time, by starting a thread for performing health detection for the database server, compared with using a process to perform health detection on the database server in the related art, the consumption of device resources can be reduced and the burden on the device can be alleviated.

[0087] In an optional embodiment, after creating a socket in the target kernel corresponding to the target thread, the method further includes: obtaining the thread identifier of the current thread; when it is determined that the thread identifier matches the first identifier, determining whether the created socket is a socket of the target type based on the parameters of the socket function.

[0088] For example, when the kernel creates a socket, typically in the sock_create function, the kernel obtains process context information and the thread identifier of the current thread from the context information. If the thread identifier matches the first identifier, the current thread is the target thread. The kernel then determines whether the socket created in the target kernel corresponding to the target thread is of the target type. Specifically, the kernel determines whether the created socket is of the target type based on the parameters of the socket function.

[0089] Considering that the socket created by the target thread used for health detection is generally a target-type socket, the solution of this application is proposed for target-type sockets. Therefore, when determining that the thread identifier matches the first identifier, the parameters of the socket function are used to determine whether the created socket is a target-type socket. The target type can be set according to business needs. For example, the target type socket can be a Transmission Control Protocol (TCP) type socket.

[0090] Then, when it is determined that the socket is a socket of the target type, the second identifier is read from the task structure corresponding to the target kernel, and the virtual routing table to which the socket belongs is set based on the second identifier. When it is determined that the socket is not a socket of the target type, no subsequent processing is performed.

[0091] Optionally, determining whether the created socket is a socket of the target type based on the parameters of the socket function includes: determining whether parameter information of the parameters matches preset information corresponding to the parameters; if so, determining that the created socket is a socket of the target type.

[0092] A socket function generally has three parameters, such as int socket(int domain, int type, int protocol); the domain generally corresponds to the kernel family parameter, which is used to specify the protocol family, usually AF_INET (IPv4) or AF_INET6 (IPv6).

[0093] type is used to specify the type of socket. Common types are: SOCK_STREAM: provides connection-oriented byte stream, that is, TCP type; SOCK_DGRAM: provides connectionless datagram, that is, User Datagram Protocol (UDP) type.

[0094] The protocol is usually 0, which means that the protocol is automatically selected based on the domain and type, or a specific protocol can be specified, such as IPPROTO_TCP or IPPROTO_UDP.

[0095] After obtaining the parameters of the socket function, for each parameter, determine whether the parameter information of the parameter matches the preset information corresponding to the parameter, and the preset information is the information corresponding to the target type of socket; when the parameter information of multiple parameters matches the corresponding preset information, determine that the socket is a socket of the target type; if there is at least one parameter whose parameter information does not match the corresponding preset information, determine that the socket is not a socket of the target type.

[0096] For example, when the target type is TCP type, you can first determine whether the parameter information of the domain parameter in the socket function is AF_INET or AF_INET6. If not, it is determined that the socket is not a socket of the target type and no subsequent processing is required; if so, continue to judge the type parameter in the socket function to determine whether the parameter information of the type parameter is SOCK_STREAM. If not, it is determined that the socket is not a socket of the target type and no subsequent processing is required; if so, it can be determined that the socket is a socket of the target type.

[0097] Alternatively, you can further judge the protocol parameter in the socket function. When the parameter information of the type parameter is SOCK_STREAM, determine whether the parameter information of the protocol parameter is 0 or IPPROTO_TCP. If not, it is determined that the socket is not a socket of the target type; conversely, if so, it is determined that multiple parameters of the socke function all match the corresponding preset information, and determine that the socket is a socket of the target type.

[0098] During implementation, it is also possible to synchronously determine whether the parameter information of the domain parameter, type parameter, and protocol parameter matches the corresponding preset information respectively. If all match, it is determined that the socket is a socket of the target type; if there is at least one parameter that does not match the corresponding preset information, it is determined that the socket is not a socket of the target type.

[0099] Through the above process, it is possible to more accurately determine whether the socket is a target type socket, so that only the target type socket is processed and the non-target type socket is not processed, thereby improving the efficiency and accuracy of socket processing.

[0100] See also Figure 2 As shown, combined Figure 2 The server health detection method is exemplified. The method may include:

[0101] S201: Start the target thread.

[0102] That is, according to the server information of the database server, a target thread for performing health detection on the database server is started.

[0103] S202: Save the second identifier of the VRF in the target kernel.

[0104] That is, based on the first identifier of the target thread, the task structure of the target kernel corresponding to the target thread is searched, and the second identifier of the virtual routing table to which the database server belongs is saved in the vrf_id field of task_struct.

[0105] S203: Calling and intercepting socket functions.

[0106] That is, when it is detected that the target thread calls the socket function to create a socket, the call of the socket function is intercepted, and then the execution process of the kernel creating the socket is entered.

[0107] S204 , controlling the operating state of the system to enter the kernel state from the user state. In the kernel state, creating a socket in the target kernel corresponding to the target thread according to the parameters of the socket function.

[0108] S205 , in the execution flow of creating a socket in the target kernel, generally located in the sock_create function, in which the thread identifier of the current thread is obtained.

[0109] S206: Determine whether the thread identifier is the first identifier of the target thread. If so, execute S207; otherwise, do not perform subsequent processing.

[0110] S207. Detect whether the domain parameter in the socket function is AF_INET or AF_INET6, and whether the parameter information of the type parameter is SOCK_STREAM; if both are true, determine that the socket is a socket of the target type, and execute S208; otherwise, if the domain parameter does not match, and / or the type parameter does not match, determine that the socket is not a socket of the target type, and do not perform subsequent processing.

[0111] S208. Read the task structure of the target kernel to obtain the second identifier; and use the second identifier to set the VRF to which the socket belongs.

[0112] S209. Return a file descriptor indicating the socket.

[0113] S210: Perform health check in user mode.

[0114] That is, the target thread is used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0115] Corresponding to the aforementioned embodiment of the server health detection method, the present application also provides an embodiment of a server health detection device. Figure 3 The schematic diagram of the server health detection device provided for this application specifically includes:

[0116] A starting module 301 is used to start a target thread for performing health detection on the database server according to the server information of the database server;

[0117] A search module 302 is configured to search a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and save the second identifier of the virtual routing table to which the database server belongs to the task structure;

[0118] A creation module 303 is configured to intercept the call of the socket function when detecting that the target thread calls a socket function to create a socket, and create a socket in the target kernel corresponding to the target thread according to the parameters of the socket function;

[0119] A setting module 304 is configured to read the second identifier from the task structure corresponding to the target kernel, and set the virtual routing table to which the socket belongs based on the second identifier;

[0120] The detection module 305 is configured to utilize the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0121] Optionally, after creating a socket in the target kernel corresponding to the target thread, the creation module 303 is further configured to:

[0122] Get the thread ID of the current thread;

[0123] When it is determined that the thread identifier matches the first identifier, determining whether the created socket is a socket of the target type according to the parameters of the socket function;

[0124] The setting module 304 is configured to, when reading the second identifier from the task structure corresponding to the target kernel and setting the virtual routing table to which the socket belongs based on the second identifier:

[0125] When it is determined that the socket is a socket of the target type, the second identifier is read from the task structure corresponding to the target kernel, and the virtual routing forwarding table to which the socket belongs is set based on the second identifier.

[0126] Optionally, when determining whether the created socket is a socket of the target type according to the parameters of the socket function, the creation module 303 is configured to:

[0127] Determining whether the parameter information of the parameter matches the preset information corresponding to the parameter;

[0128] If so, it is determined that the created socket is a socket of the target type.

[0129] Optionally, the search module 302, when searching for a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread and saving the second identifier of the virtual routing table to which the database server belongs to the task structure, is configured to:

[0130] Creating a target system call, wherein parameters of the target system call include the second identifier;

[0131] Based on the first identifier, determining a task structure of a target kernel corresponding to the target thread, wherein an identification field for storing a virtual routing forwarding table identifier is newly added to the task structure;

[0132] The target system call is used to save the second identifier into the identifier field of the task structure.

[0133] Optionally, the socket is stored in the target kernel in the form of a socket structure, and a target field for representing an identifier of a virtual routing table is provided in the socket structure; the setting module 304, when setting the virtual routing table to which the socket belongs based on the second identifier, is used to:

[0134] The second identifier is set in the target field of the socket structure, wherein the virtual routing forwarding table corresponding to the second identifier is the virtual routing forwarding table to which the socket belongs.

[0135] Optionally, the creation module 303, when detecting that the target thread calls a socket function to create a socket, intercepts the call of the socket function, and creates a socket in the target kernel corresponding to the target thread according to the parameters of the socket function, is configured to:

[0136] When detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function and controlling the system running state to enter the kernel state from the user state;

[0137] In the kernel state, a socket is created in the target kernel corresponding to the target thread according to the parameters of the socket function.

[0138] Optionally, the detection module 305, when using the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs, is configured to:

[0139] After determining the virtual routing table to which the socket belongs, the control system operating state enters the user state from the kernel state;

[0140] Get the file descriptor generated in kernel mode to indicate the socket;

[0141] According to the file descriptor, the target thread is used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

[0142] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.

[0143] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.

[0144] The present application also provides a computer-readable storage medium, which stores a computer program. The computer program can be used to execute the server health detection method described in the above embodiment.

[0145] This application also provides a computer device, see Figure 4As shown, it is a structural diagram of the computer device provided by this application. At the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the server health detection method described in the above embodiment. Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0146] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0147] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0148] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0149] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1a process or multiple processes and / or boxes Figure 1 In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0150] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0151] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0152] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0153] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.

[0154] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.

[0155] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A server health detection method, characterized in that: The method comprises: Starting a target thread for performing health detection on the database server according to the server information of the database server; Searching for a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and saving the second identifier of the virtual routing table to which the database server belongs to the task structure; When detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function, and creating a socket in a target kernel corresponding to the target thread according to parameters of the socket function; Reading the second identifier from the task structure corresponding to the target kernel, and setting the virtual routing forwarding table to which the socket belongs based on the second identifier; The target thread is used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

2. The method according to claim 1, characterized in that After creating a socket in the target kernel corresponding to the target thread, the method further includes: Get the thread ID of the current thread; When it is determined that the thread identifier matches the first identifier, determining whether the created socket is a socket of the target type according to the parameters of the socket function; The step of reading the second identifier from the task structure corresponding to the target kernel and setting the virtual routing table to which the socket belongs based on the second identifier includes: When it is determined that the socket is a socket of the target type, the second identifier is read from the task structure corresponding to the target kernel, and the virtual routing forwarding table to which the socket belongs is set based on the second identifier.

3. The method according to claim 2, characterized in that Determining whether the created socket is a socket of a target type according to the parameters of the socket function includes: Determining whether the parameter information of the parameter matches the preset information corresponding to the parameter; If so, it is determined that the created socket is a socket of the target type.

4. The method according to claim 1, wherein The step of searching for a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and saving the second identifier of the virtual routing forwarding table to which the database server belongs to the task structure, includes: Creating a target system call, wherein parameters of the target system call include the second identifier; Based on the first identifier, determining a task structure of a target kernel corresponding to the target thread, wherein an identification field for storing a virtual routing forwarding table identifier is newly added to the task structure; The target system call is used to save the second identifier into the identifier field of the task structure.

5. The method according to claim 1, wherein The socket is stored in the target kernel in the form of a socket structure, and a target field for indicating an identifier of a virtual routing table is provided in the socket structure; The setting of the virtual routing forwarding table to which the socket belongs based on the second identifier includes: The second identifier is set in the target field of the socket structure, wherein the virtual routing forwarding table corresponding to the second identifier is the virtual routing forwarding table to which the socket belongs.

6. The method according to any one of claims 1 to 5, characterized in that: When detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function, and creating a socket in a target kernel corresponding to the target thread according to parameters of the socket function, including: When detecting that the target thread calls a socket function to create a socket, intercepting the call of the socket function and controlling the system running state to enter the kernel state from the user state; In the kernel state, a socket is created in the target kernel corresponding to the target thread according to the parameters of the socket function.

7. The method according to claim 6, characterized in that The step of utilizing the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs includes: After determining the virtual routing table to which the socket belongs, the control system operating state enters the user state from the kernel state; Get the file descriptor generated in kernel mode to indicate the socket; According to the file descriptor, the target thread is used to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

8. A server health detection device, characterized in that: The device comprises: A startup module, configured to start a target thread for performing health detection on the database server according to server information of the database server; A search module, configured to search a task structure of a target kernel corresponding to the target thread based on the first identifier of the target thread, and save the second identifier of the virtual routing table to which the database server belongs to the task structure; A creation module, configured to intercept the call of the socket function when detecting that the target thread calls a socket function to create a socket, and create a socket in a target kernel corresponding to the target thread according to parameters of the socket function; A setting module, configured to read the second identifier from the task structure corresponding to the target kernel, and set the virtual routing table to which the socket belongs based on the second identifier; The detection module is used to use the target thread to perform a health check on the database server in the virtual routing forwarding table to which the socket belongs.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the steps of the method according to any one of claims 1 to 7.