Database access method and apparatus
By establishing multiple connections between the Redis client and the proxy server and listening to status information, and switching access paths, the problem of access interruption during the upgrade of the Redis proxy application service was solved, and continuous access for the Redis client was achieved.
Patent Information
- Application Number
- CN202611536199.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-30
- Publication Date
- 2026-11-20
AI Technical Summary
During the upgrade and restart of the Redis proxy application service, Redis clients were unable to access the Redis database service normally.
By establishing a first connection and a second connection between the target client and the target proxy server, monitoring the status information of the first target proxy application service, and switching to the second connection when an upgrade is detected, access traffic is ensured to switch from the first connection to the second connection, thereby enabling access to the target database service through the target proxy server and the second target proxy application service.
During the upgrade of the Redis proxy application service, ensure that Redis clients can continuously access the Redis database service and avoid connection interruption.
Smart Images

Figure CN123145254A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of client-side technology, and in particular to a database access method and apparatus. Background Technology
[0002] With the continuous development of Redis containerization technology, in order to facilitate management, Redis clients use the Redis proxy application service to access the Redis database service deployed in the Redis server cluster. In some scenarios, Redis clients achieve high availability of the Redis proxy application service through the HAProxy proxy server. That is, Redis clients access the Redis database service deployed in the Redis server cluster through the HA Proxy proxy server and the Redis proxy application service.
[0003] When a new version of the Redis proxy application service exists, the old version needs to be upgraded and restarted. However, during the upgrade and restart process, the Redis proxy application service becomes unavailable, causing Redis clients accessing the Redis database service through the proxy service to lose connection and become unable to access the Redis database service normally, thus affecting the normal use of Redis clients. Summary of the Invention
[0004] This application provides a database access method and apparatus, the main purpose of which is to ensure that Redis clients can access Redis database services normally during the process of upgrading and restarting Redis proxy application services.
[0005] To address the aforementioned technical problems, this application provides the following technical solutions: In a first aspect, this application provides a database access method, which is applied to a target client, and the method includes: Monitor the status information corresponding to the first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, and the first connection is the connection between the target client and the target proxy server; When the status information corresponding to the first target proxy application service is detected to be pending upgrade, data communication is performed between the second target proxy server and the second target proxy application service through the second connection, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. The second connection is the connection between the target client and the target proxy server. The target server cluster contains multiple server nodes, and the target database service is deployed on the multiple server nodes.
[0006] Secondly, this application also provides a database access device, which is applied to a target client, and the device includes: The first listening unit is used to listen to the status information corresponding to the first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, and the first connection is the connection between the target client and the target proxy server; The second access unit is used to communicate with the second target proxy application service through the second connection and the target proxy server when the status information corresponding to the first target proxy application service is changed to pending upgrade, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. The second connection is the connection between the target client and the target proxy server. The target server cluster includes multiple server nodes, and the target database service is deployed on the multiple server nodes.
[0007] Thirdly, embodiments of this application provide a storage medium including a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the database access method described in the first aspect.
[0008] Fourthly, embodiments of this application provide a database access apparatus, the apparatus including a storage medium; and one or more processors, the storage medium being coupled to the processors, the processors being configured to execute program instructions stored in the storage medium; the program instructions, when executed, perform the database access method described in the first aspect.
[0009] By employing the above-described technical solution, the technical solution provided in this application has at least the following advantages: This application provides a database access method and apparatus. After a target client establishes a first connection and a second connection with a target proxy server, the target proxy server establishes connections with a first target proxy application service and a second target proxy application service, and the first and second target proxy application services establish connections with a target server cluster, the target client can then communicate with the first target proxy application service through the first connection and the target proxy server, thereby enabling the target client to access a target database service through the target proxy server and the first target proxy application service. During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client continuously monitors the status information corresponding to the first target proxy application service to determine whether the first target proxy application service is about to be upgraded. When the status information corresponding to the first target proxy application service changes to "pending upgrade," indicating that the first target proxy application service is about to become unavailable, the target client communicates with the second target proxy application service through the second connection and the target proxy server, thereby enabling the target client to access the target database service through the target proxy server and the second target proxy application service. In this application, when the target client accesses the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, and the first target proxy application service is about to be upgraded (i.e., the first target proxy application service is about to become unavailable), the target client can switch its access traffic from the first connection to the second connection, thereby enabling access to the target database service through the target proxy server and the second target proxy application service, so as to ensure that the target client can access the target database service normally.
[0010] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0011] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, with the same or corresponding reference numerals denoteing the same or corresponding parts, wherein: Figure 1 A flowchart of a database access method provided in an embodiment of this application is shown; Figure 2 A flowchart of another database access method provided in an embodiment of this application is shown; Figure 3A schematic diagram of a database access application scenario provided by an embodiment of this application is shown; Figure 4 This paper shows a block diagram of a database access device provided in an embodiment of this application; Figure 5 A block diagram of another database access device provided in an embodiment of this application is shown. Detailed Implementation
[0012] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.
[0013] Furthermore, the terms “first,” “second,” and similar terms used in this application do not indicate any order, quantity, or importance, but are merely used to distinguish different parts.
[0014] It should be noted that, unless otherwise stated, the technical or scientific terms used in this application shall have the ordinary meaning as understood by one of ordinary skill in the art to which this application pertains.
[0015] When a new version of the Redis proxy application service exists, the old version needs to be upgraded and restarted. However, during the upgrade and restart process, the Redis proxy application service becomes unavailable, causing Redis clients accessing the Redis database service through the proxy service to lose connection and become unable to access the Redis database service normally.
[0016] Therefore, in order to ensure that Redis clients can access the Redis database service normally during the upgrade and restart of the Redis proxy application service, this application provides a database access method, such as... Figure 1 As shown, the method includes at least 101-104.
[0017] 101. Monitor the status information corresponding to the first target proxy application service.
[0018] In this embodiment of the application, the execution subject in each step is the target client running on the target terminal device. The target terminal device may be, but is not limited to, a computer, a smartphone, a tablet computer, etc., and the target client is specifically a Redis client.
[0019] When a target client needs to access a target database service deployed in a target server cluster, the target client needs to establish a first connection and a second connection with the target proxy server. Specifically, the target client first establishes a first connection with the target proxy server using a first port, and then establishes a second connection with the target proxy server using a second port. The target proxy server is specifically an HA (High Availability) server. The proxy server consists of a first port and a second port. The target server cluster is specifically a Redis server cluster, comprising multiple server nodes, each a Redis server node, and the target database service is deployed on these nodes. After the target client establishes the first and second connections with the target proxy server, the target proxy server will then establish connections with both the first and second target proxy application services. At this point, the target client can communicate with the first target proxy application service through the first connection and the target proxy server, or with the second target proxy application service through the second connection. The first and second target proxy application services can be deployed on the same server or on different servers. The first target proxy application service is the one with the lowest load among the multiple first proxy application services, and the second target proxy application service is the one with the lowest load among the multiple second proxy application services. The proxy application service is an older version of the Redis proxy application service, while multiple secondary proxy application services are newer versions. After the target proxy server establishes connections with the first and second target proxy application services respectively, the first target proxy application service will then establish a connection with the target server cluster. Simultaneously, the second target proxy application services will also establish connections with the target server cluster. After the target client establishes the first and second connections with the target proxy server, the target proxy server establishes connections with the first and second target proxy application services respectively, and the first and second target proxy application services establish connections with the target server cluster respectively, the target client can then communicate with the first target proxy application service through the first connection and the target proxy server. After the target client communicates with the first target proxy application service through the first connection and the target proxy server, the target proxy server will then access the target server cluster through the first target proxy application service, thereby enabling the target client to access the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service.
[0020] During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client needs to continuously monitor the status information of the first target proxy application service in order to determine whether the first target proxy application service is about to be upgraded.
[0021] The status information corresponding to the first target agent application service is either "pending upgrade" or "upgrade completed". When the status information corresponding to the first target agent application service changes to "pending upgrade", it means that the first target agent application service is about to be upgraded. When the status information corresponding to the first target agent application service changes to "upgrade completed", it means that the first target agent application service has completed the upgrade and restarted. At this time, the first target agent application service is the latest version.
[0022] 102. When the status information corresponding to the first target proxy application service is detected to be changed to pending upgrade, data communication is conducted with the second target proxy application service through the second connection and the target proxy server, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service.
[0023] When the status information of the first target proxy application service changes to "pending upgrade," it can be determined that the first target proxy application service is about to be upgraded (i.e., the first target proxy application service will soon become unavailable). At this time, the target client needs to communicate with the second target proxy application service through the second connection and the target proxy server, that is, switch the access traffic from the first connection to the second connection. After the target client communicates with the second target proxy application service through the second connection and the target proxy server, the target proxy server will access the target server cluster through the second target proxy application service, thereby enabling the target client to access the target database service deployed in the target server cluster through the target proxy server and the second target proxy application service.
[0024] This application provides a database access method. This method enables a target client to establish a first connection and a second connection with a target proxy server. The target proxy server then establishes connections with a first target proxy application service and a second target proxy application service, and the first and second target proxy application services respectively establish connections with a target server cluster. After these connections, the target client can communicate with the first target proxy application service through the first connection and the target proxy server, thereby enabling the target client to access a target database service through the target proxy server and the first target proxy application service. During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client continuously monitors the status information corresponding to the first target proxy application service to determine whether the first target proxy application service is about to be upgraded. When the status information corresponding to the first target proxy application service changes to "pending upgrade," indicating that the first target proxy application service is about to become unavailable, the target client communicates with the second target proxy application service through the second connection and the target proxy server, thereby enabling the target client to access the target database service through the target proxy server and the second target proxy application service. In this embodiment of the application, when the target client accesses the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, and the first target proxy application service is about to be upgraded (i.e., the first target proxy application service is about to become unavailable), the target client can switch its access traffic from the first connection to the second connection, thereby enabling access to the target database service through the target proxy server and the second target proxy application service, so as to ensure that the target client can access the target database service normally.
[0025] To provide a more detailed explanation, this application provides another database access method, as detailed below. Figure 2 As shown, the method includes at least 201-206.
[0026] 201. Establish a first connection and a second connection with the target proxy server, so as to establish a connection with the first target proxy application service through the first connection and the target proxy server, and to establish a connection with the second target proxy application service through the second connection and the target proxy server.
[0027] Specifically, regarding step 201, establishing a first connection and a second connection with the target proxy server, so as to establish a connection with the first target proxy application service through the first connection and the target proxy server, and to establish a connection with the second target proxy application service through the second connection and the target proxy server, please refer to [reference needed]. Figure 1 The description of the corresponding part 101 will not be repeated here in the embodiments of this application.
[0028] Furthermore, in this embodiment, after the target client establishes a first connection and a second connection with the target proxy server, the target proxy server establishes connections with the first target proxy application service and the second target proxy application service respectively, and the first target proxy application service and the second target proxy application service establish connections with the target server cluster respectively, the target proxy server will send the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the first target server as proxy information to the target client through the first connection. At this time, the target client can receive the proxy information sent by the target proxy server through the first connection. Based on the proxy information, the target client can determine the identity information of the first target proxy application service and the first target server connected to it. The first target proxy application service is deployed in the first target server.
[0029] 202. Data communication is conducted between the first connection and the first target proxy server and the first target proxy application service, so that the target client can access the target server cluster through the target proxy server and the first target proxy application service.
[0030] Regarding step 202, which involves data communication between the first connection and the first target proxy server and the first target proxy application service, so that the target client can access the target server cluster through the target proxy server and the first target proxy application service, please refer to [reference needed]. Figure 1 The description of the corresponding part 101 will not be repeated here in the embodiments of this application.
[0031] 203. Monitor the status information corresponding to the first target proxy application service.
[0032] During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client needs to continuously monitor the status information of the first target proxy application service in order to determine whether the first target proxy application service is about to be upgraded.
[0033] Specifically, in this step, the target client can use either of the following two methods to listen to the status information corresponding to the first target proxy application service: (1) Wherein, the specified database stores a status information data table. For any proxy application service, the status information data table records the correspondence between the unique identifier of the proxy application service, the unique identifier of the server where the proxy application service is located, and the status information of the proxy application service. When the first target proxy application service needs to be upgraded, the service governance platform will change the status information of the first target proxy application service to "to be upgraded" in the status information data table according to the unique identifier of the first target proxy application service and the unique identifier of the first target server, and upgrade the first target proxy application service. When the first target proxy application service is upgraded and restarted, the service governance platform will change the status information of the first target proxy application service to "upgrade completed" in the status information data table according to the unique identifier of the first target proxy application service and the unique identifier of the first target server.
[0034] During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client continuously listens to the status information data table based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the first target server, so as to continuously listen to the status information corresponding to the first target proxy application service.
[0035] (2) The designated database also stores the proxy application service upgrade log. The proxy application service upgrade log records one or more upgrade information. For any upgrade message, the upgrade information records the correspondence between a unique identifier corresponding to a proxy application service, a unique identifier corresponding to the server where the proxy application service is located, and the status information corresponding to the proxy application service. When the first target proxy application service needs to be upgraded, the service governance platform will generate an upgrade message based on the unique identifier corresponding to the first target proxy application service, the unique identifier corresponding to the target server, and the status information (i.e., to be upgraded) corresponding to the first target proxy application service, and add the upgrade message to the proxy application service upgrade log. When the first target proxy application service is upgraded and restarted, the service governance platform will generate an upgrade message based on the unique identifier corresponding to the first target proxy application service, the unique identifier corresponding to the target server, and the status information (i.e., upgrade completed) corresponding to the first target proxy application service, and add the upgrade message to the proxy application service upgrade log.
[0036] During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client continuously listens to the upgrade log of the proxy application service based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the first target server, so as to continuously listen to the status information corresponding to the first target proxy application service.
[0037] Specifically, the database to be specified can be the etcd database.
[0038] 204. When the status information corresponding to the first target proxy application service is detected to be changed to pending upgrade, data communication is conducted with the second target proxy application service through the second connection and the target proxy server, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service.
[0039] Specifically, regarding step 204, when the status information corresponding to the first target proxy application service is detected to have changed to "pending upgrade," data communication is established between the second target proxy application service and the second target proxy server through the second connection, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. (See also...) Figure 1 The description of the corresponding part 102 will not be repeated here in the embodiments of this application.
[0040] Furthermore, in this embodiment of the application, before communicating with the second target proxy application service through the second connection and the target proxy server, the target client also needs to verify the connectivity of the second connection; when it is determined that the connectivity of the second connection is successfully verified, the target client can execute the step of communicating with the second target proxy application service through the second connection and the target proxy server. The specific process by which the target client verifies the connectivity of the second connection is as follows: First, the target client sends a verification request message to the target server cluster through the second connection. Specifically, the verification request message is sent to the target proxy server through the second connection, which then forwards it to the second target proxy application service, which in turn forwards it to the target proxy server. Second, the target client receives a verification response message from the target server cluster through the second connection. Specifically, the target proxy server sends the verification response message to the second target proxy application service, which in turn forwards it to the target proxy server. The target proxy server then forwards the verification response message to the target client through the second connection, allowing the target client to receive the verification response message. Finally, the target client determines whether the verification response message matches the expected response message. If they match, the connectivity verification of the second connection is successful; otherwise, the connectivity verification of the second connection fails.
[0041] When the connectivity verification of the second connection fails, the target client needs to output an error message to inform the user that the target client is currently unable to access the target database service normally.
[0042] Furthermore, in this embodiment, after the target client establishes a first connection and a second connection with the target proxy server, the target proxy server establishes connections with the first target proxy application service and the second target proxy application service respectively, and the first target proxy application service and the second target proxy application service establish connections with the target server cluster respectively, the target proxy server will also send the unique identifier corresponding to the second target proxy application service and the unique identifier corresponding to the second target server as proxy information to the target client through the second connection. At this time, the target client can receive the proxy information sent by the target proxy server through the second connection. Based on the proxy information, the target client can determine the identity information of the second target proxy application service and the second target server connected to it. The second target proxy application service is deployed in the second target server.
[0043] Furthermore, in this embodiment of the application, when it is determined that the connectivity verification of the second connection fails, the target client can also establish a third connection with the target proxy server, and send the unique identifier corresponding to the second target proxy application service and the unique identifier corresponding to the second target server to the target proxy server through the third connection, so that the target client can re-establish a connection with the second target proxy application server through the third connection and the target proxy server, thereby enabling the target client to access the target server cluster through the target proxy server and the second target proxy application service.
[0044] 205. Monitor the status information corresponding to the first target proxy application service.
[0045] During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the second target proxy application service, the target client also needs to continuously monitor the status information corresponding to the first target proxy application service in order to determine whether the first target proxy application service has been upgraded.
[0046] The specific process of the target client listening to the status information corresponding to the first target proxy application service can be referred to the description of step 203 above, and will not be repeated here in this embodiment of the application.
[0047] 206. When the status information corresponding to the first target proxy application service is detected to have changed to "upgrade complete", data communication with the first target proxy application service is re-established through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service.
[0048] When the status information corresponding to the first target proxy application service changes to "upgrade complete," it can be determined that the first target proxy application service has been upgraded and restarted (i.e., the first target proxy application service has been restored to availability). At this time, the target client can resume data communication with the first target proxy application service through the first connection and the target proxy server, that is, switch the access traffic back from the second connection to the first connection to alleviate the load pressure on the second target proxy application service. After the target client resumes data communication with the first target proxy application service through the first connection and the target proxy server, the target proxy server will resume accessing the target server cluster through the first target proxy application service, thereby enabling the target client to resume accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service.
[0049] Furthermore, in this embodiment, before re-establishing data communication with the first target proxy application service through the first connection and the target proxy server, the target client needs to verify the connectivity of the first connection. When the connectivity verification of the first connection is successful, the target client can then execute the step of re-establishing data communication with the first target proxy application service through the first connection and the target proxy server. The specific process of the target client verifying the connectivity of the first connection can refer to the specific process of the target client verifying the connectivity of the second connection described above, and will not be repeated in this embodiment.
[0050] Specifically, when the connectivity verification of the first connection fails, the target client needs to continue data communication with the target proxy server through the second connection; or establish a fourth connection with the target proxy server and send the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the first target server to the target proxy server through the fourth connection, so that the target client can re-establish a connection with the first target proxy application server through the fourth connection and the target proxy server, thereby enabling the target client to access the target server cluster again through the target proxy server and the first target proxy application service.
[0051] For the embodiments of this application, specific application scenarios can be as follows: Figure 3 As shown, but not limited to: The target database service is deployed in the target server cluster, which is specifically a Redis server cluster containing multiple server nodes, all of which are Redis server nodes. The target database service is specifically a Redis database service. Client A is specifically a Redis client, and proxy server A is specifically an HA Proxy server, which includes a first port and a second port. The target proxy application service A is the least loaded proxy application service a among multiple proxy application services a, which is an older version of the Redis proxy application service, and is deployed on target server A. The target proxy application service B is the least loaded proxy application service b among multiple proxy application services b, and is deployed on target server B. The specified database stores status information tables and proxy application service upgrade logs; the specified database can be an etcd database.
[0052] S1: Client A establishes a first connection and a second connection with proxy server A, so as to establish a connection with target proxy application service A through the first connection and proxy server A, and to establish a connection with target proxy application service B through the second connection and proxy server A.
[0053] When client A needs to access the target database service deployed in the target server cluster, client A needs to establish a first connection and a second connection with proxy server A. That is, client A first establishes a first connection with proxy server A containing a first port, and then establishes a second connection with proxy server A containing a second port.
[0054] After client A establishes the first and second connections with proxy server A, proxy server A will then establish connections with target proxy application service A and target proxy application service B respectively. At this time, client A can communicate with target proxy application service A through the first connection and proxy server A, and can also communicate with target proxy application service B through the second connection and proxy server A. After proxy server A establishes connections with target proxy application service A and target proxy application service B respectively, target proxy application service A will establish a connection with the target server cluster, and at the same time, target proxy application service B will also establish a connection with the target server cluster.
[0055] S2: Client A communicates with target proxy application service A through the first connection and proxy server A, so that client A can access the target server cluster through proxy server A and target proxy application service A.
[0056] After client A establishes a first connection and a second connection with proxy server A, proxy server A establishes connections with target proxy application service A and target proxy application service B respectively, and target proxy application service A and target proxy application service B establish connections with the target server cluster respectively, client A can then communicate with target proxy application service A through the first connection and proxy server A. After client A communicates with target proxy application service A through the first connection and proxy server A, proxy server A will access the target server cluster through target proxy application service A, thereby enabling client A to access the target database service deployed in the target server cluster through proxy server A and target proxy application service A.
[0057] S3: Client A listens for the status information corresponding to the target proxy application service A.
[0058] During the process of client A accessing the target database service deployed in the target server cluster through proxy server A and target proxy application service A, client A needs to continuously monitor the status information of the target proxy application service A in order to determine whether the target proxy application service A is about to be upgraded.
[0059] Among them, the status information corresponding to the target proxy application service A is either "pending upgrade" or "upgrade completed". When the status information corresponding to the target proxy application service A changes to "pending upgrade", it means that the target proxy application service A is about to be upgraded. When the status information corresponding to the target proxy application service A changes to "upgrade completed", it means that the target proxy application service A has completed the upgrade and restarted. At this time, the target proxy application service A is the latest version.
[0060] Furthermore, in this embodiment, after client A establishes a first connection and a second connection with proxy server A, proxy server A establishes connections with target proxy application service A and target proxy application service B respectively, and target proxy application service A and target proxy application service B establish connections with target server cluster respectively, proxy server A will send the unique identifier corresponding to target proxy application service A and the unique identifier corresponding to target server A as proxy information to client A through the first connection. At this time, client A can receive the proxy information sent by proxy server A through the first connection, and client A can determine the identity information of target proxy application service A and target server A connected with it based on the proxy information.
[0061] During the process of client A accessing the target database service deployed in the target server cluster through proxy server A and target proxy application service A, client A can continuously monitor the status information data table based on the unique identifiers corresponding to target proxy application service A and target server A, so as to continuously monitor the status information of target proxy application service A; client A can also continuously monitor the upgrade logs of proxy application service based on the unique identifiers corresponding to target proxy application service A and target server A, so as to continuously monitor the status information of target proxy application service A.
[0062] S4: When the status information corresponding to the target proxy application service A is detected to be pending upgrade, client A communicates with the target proxy application service B through the second connection and proxy server A, so that client A can access the target server cluster through proxy server A and target proxy application service B.
[0063] When the status information of the target proxy application service A changes to "pending upgrade," it can be determined that the target proxy application service A is about to be upgraded (i.e., the target proxy application service A will soon become unavailable). At this time, client A needs to communicate with the target proxy application service B through a second connection and proxy server A, that is, switch the access traffic from the first connection to the second connection. After client A communicates with the target proxy application service B through the second connection and proxy server A, proxy server A will access the target server cluster through the target proxy application service B, thereby enabling client A to access the target database service deployed in the target server cluster through proxy server A and target proxy application service B.
[0064] Furthermore, in this embodiment, after client A establishes a first connection and a second connection with proxy server A, proxy server A establishes connections with target proxy application service A and target proxy application service B respectively, and target proxy application service A and target proxy application service B establish connections with target server cluster respectively, proxy server A will also send the unique identifier corresponding to target proxy application service B and the unique identifier corresponding to target server B as proxy information to client A through the second connection. At this time, client A can receive the proxy information sent by proxy server A through the second connection, and client A can determine the identity information of target proxy application service B and target server B connected to it based on the proxy information.
[0065] Furthermore, in this embodiment of the application, before communicating with the target proxy application service B through the second connection and proxy server A, client A needs to verify the connectivity of the second connection; when the connectivity verification of the second connection is successful, client A can execute the step of communicating with the target proxy application service B through the second connection and proxy server A. The specific process by which client A verifies the connectivity of the second connection is as follows: First, client A sends a verification request message to the target server cluster through the second connection. Specifically, the verification request message is sent to proxy server A through the second connection, which then forwards it to the target proxy application service B. Finally, the target proxy application service B then forwards the verification request message to proxy server A. Second, client A receives the verification response message from the target server cluster through the second connection. Proxy server A sends the verification response message to the target proxy application service B, which then forwards it to proxy server A. Proxy server A then forwards the verification response message to client A through the second connection, allowing client A to receive the verification response message. Finally, client A determines whether the verification response message matches the expected response message. If they match, the connectivity verification of the second connection is successful; otherwise, the connectivity verification of the second connection fails.
[0066] When the connectivity verification of the second connection fails, client A can also establish a third connection with proxy server A and send the unique identifiers corresponding to the target proxy application service B and the target server B to proxy server A through the third connection. This allows client A to re-establish a connection with the target proxy application service B through the third connection and proxy server A, thereby enabling client A to access the target server cluster through proxy server A and the target proxy application service B.
[0067] S5: Client A continues to monitor the status information corresponding to the target proxy application service A.
[0068] During the process of client A accessing the target database service deployed in the target server cluster through proxy server A and target proxy application service B, client A also needs to continuously monitor the status information of the target proxy application service A to determine whether the target proxy application service A has been upgraded.
[0069] S6: When the status information corresponding to the target proxy application service A is changed to upgrade complete, client A re-establishes data communication with the target proxy application service A through the first connection and proxy server A, so that client A can access the target server cluster again through proxy server A and target proxy application service A.
[0070] When the status information corresponding to the target proxy application service A changes to "upgrade complete," it can be determined that the target proxy application service A has been upgraded and restarted (i.e., the target proxy application service A has been restored to availability). At this time, client A can resume data communication with the target proxy application service A through the first connection and proxy server A, that is, switch the access traffic back from the second connection to the first connection to alleviate the load pressure on the target proxy application service B. After client A resumes data communication with the target proxy application service A through the first connection and proxy server A, proxy server A will resume accessing the target server cluster through the target proxy application service A, thereby enabling client A to resume accessing the target database service deployed in the target server cluster through proxy server A and the target proxy application service A.
[0071] Furthermore, in this embodiment of the application, before re-establishing data communication with the target proxy application service A through the first connection and proxy server A, client A needs to verify the connectivity of the first connection; when the connectivity verification of the first connection is successful, client A can then execute the step of re-establishing data communication with the target proxy application service A through the first connection and proxy server A.
[0072] When the connectivity verification of the first connection fails, client A needs to continue data communication with proxy server A through the second connection; or establish a fourth connection with proxy server A and send the unique identifier corresponding to the target proxy application service A and the unique identifier corresponding to the target server A to proxy server A through the fourth connection, so that client A can re-establish a connection with the target proxy application service A through the fourth connection and proxy server A, thereby enabling client A to access the target server cluster again through proxy server A and target proxy application service A.
[0073] Furthermore, as a response to the above Figure 1 and Figure 2 In addition to the implementation of the method shown, another embodiment of this application also provides a database access device, which is applied to the target client. This device embodiment corresponds to the foregoing method embodiment. For ease of reading, this device embodiment will not repeat the details of the foregoing method embodiment, but it should be understood that the device in this embodiment can implement all the contents of the foregoing method embodiment. This device is applied to ensure that the Redis client can normally access the Redis database service during the upgrade and restart of the Redis proxy application service, specifically as follows... Figure 4 As shown, the device includes: The first listening unit 31 is used to listen to the status information corresponding to the first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, and the first connection is the connection between the target client and the target proxy server; The first access unit 32 is used to communicate with the second target proxy application service through the second connection and the target proxy server when the status information corresponding to the first target proxy application service is changed to pending upgrade, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. The second connection is the connection between the target client and the target proxy server. The target server cluster includes multiple server nodes, and the target database service is deployed on the multiple server nodes.
[0074] Furthermore, such as Figure 5 As shown, the device also includes: The second listening unit 33 is used to listen to the status information corresponding to the first target proxy application service; The second access unit 34 is further configured to, when it detects that the status information corresponding to the first target proxy application service has changed to upgrade complete, re-establish data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can re-access the target server cluster through the target proxy server and the first target proxy application service.
[0075] Furthermore, such as Figure 5 As shown, the device also includes: Establishment unit 35 is used to establish the first connection with the target proxy server, so as to establish a connection with the first target proxy application service through the first connection and the target proxy server; and to establish the second connection with the target proxy server, so as to establish a connection with the second target proxy application service through the second connection and the target proxy server. The second access unit 34 is further configured to perform data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster through the target proxy server and the first target proxy application service.
[0076] Furthermore, such as Figure 5 As shown, the device also includes: The receiving unit 36 is configured to receive proxy information sent by the target proxy server through the first connection, wherein the proxy information includes a unique identifier corresponding to the first target proxy application service and a unique identifier corresponding to the first target server, and the first target proxy application service is deployed in the first target server.
[0077] Furthermore, such as Figure 5 As shown, the first monitoring unit 31 is specifically used to: monitor a status information data table based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the target server, wherein, for any proxy application service, the status information data table records the correspondence between the unique identifier corresponding to the proxy application service, the unique identifier corresponding to the server where the proxy application service is located, and the status information corresponding to the proxy application service; or Listen to the upgrade log of the proxy application service based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the target server. The upgrade log of the proxy application service records one or more upgrade information. For any upgrade message, the upgrade information records the correspondence between the unique identifier corresponding to the proxy application service, the unique identifier corresponding to the server where the proxy application service is located, and the status information corresponding to the proxy application service.
[0078] Furthermore, such as Figure 5 As shown, the device also includes: The first verification unit 37 is used to verify the connectivity of the second connection; The first access unit 32 is specifically used to: when the first verification unit 37 determines that the connectivity verification of the second connection is successful, perform data communication with the second target proxy application service through the second connection and the target proxy server, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service.
[0079] Furthermore, such as Figure 5 As shown, the device also includes: The second verification unit 38 is used to verify the connectivity of the first connection; The second access unit 34 is specifically used to: when the second verification unit 38 determines that the connectivity verification of the first connection is successful, re-establish data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can re-access the target server cluster through the target proxy server and the first target proxy application service.
[0080] This application provides a database access method and apparatus. This embodiment establishes a first connection and a second connection between a target client and a target proxy server. The target proxy server then establishes connections with a first target proxy application service and a second target proxy application service, and the first and second target proxy application services establish connections with a target server cluster. After these connections, the target client can communicate with the first target proxy application service through the first connection and the target proxy server, thereby enabling the target client to access a target database service through the target proxy server and the first target proxy application service. During the process of the target client accessing the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, the target client continuously monitors the status information corresponding to the first target proxy application service to determine whether the first target proxy application service is about to be upgraded. When the status information corresponding to the first target proxy application service changes to "pending upgrade," indicating that the first target proxy application service is about to become unavailable, the target client communicates with the second target proxy application service through the second connection and the target proxy server, thereby enabling the target client to access the target database service through the target proxy server and the second target proxy application service. In this embodiment of the application, when the target client accesses the target database service deployed in the target server cluster through the target proxy server and the first target proxy application service, and the first target proxy application service is about to be upgraded (i.e., the first target proxy application service is about to become unavailable), the target client can switch its access traffic from the first connection to the second connection, thereby enabling access to the target database service through the target proxy server and the second target proxy application service, so as to ensure that the target client can access the target database service normally.
[0081] This application provides a storage medium that includes a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the database access method described above.
[0082] Storage media may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0083] This application also provides a database access apparatus, the apparatus including a storage medium and one or more processors, the storage medium being coupled to the processors, the processors being configured to execute program instructions stored in the storage medium; the program instructions, when executed, perform the database access method described above.
[0084] This application provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: Monitor the status information corresponding to the first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, and the first connection is the connection between the target client and the target proxy server; When the status information corresponding to the first target proxy application service is detected to be pending upgrade, data communication is performed between the second target proxy server and the second target proxy application service through the second connection, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. The second connection is the connection between the target client and the target proxy server. The target server cluster contains multiple server nodes, and the target database service is deployed on the multiple server nodes.
[0085] Furthermore, after the data communication between the second target proxy application service and the second target proxy server via the second connection, the method further includes: Monitor the status information corresponding to the first target proxy application service; When the status information corresponding to the first target proxy application service is detected to have changed to "upgrade complete", the target client re-establishes data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service.
[0086] Furthermore, before monitoring the status information corresponding to the first target proxy application service, the method further includes: Establish the first connection with the target proxy server, so as to establish a connection with the first target proxy application service through the first connection and the target proxy server; Establish the second connection with the target proxy server, so as to establish a connection with the second target proxy application service through the second connection and the target proxy server; The target client communicates with the target server and the first target proxy application service through the first connection, so that the target client can access the target server cluster through the target proxy server and the first target proxy application service.
[0087] Furthermore, the method also includes: The first connection receives proxy information sent by the target proxy server, wherein the proxy information includes a unique identifier corresponding to the first target proxy application service and a unique identifier corresponding to the first target server, and the first target proxy application service is deployed on the first target server.
[0088] Furthermore, the monitoring of the status information corresponding to the first target proxy application service includes: Based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the target server, a status information data table is monitored. For any proxy application service, the status information data table records the correspondence between the unique identifier corresponding to the proxy application service, the unique identifier corresponding to the server where the proxy application service resides, and the status information corresponding to the proxy application service; or Listen to the upgrade log of the proxy application service based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the target server. The upgrade log of the proxy application service records one or more upgrade information. For any upgrade message, the upgrade information records the correspondence between the unique identifier corresponding to the proxy application service, the unique identifier corresponding to the server where the proxy application service is located, and the status information corresponding to the proxy application service.
[0089] Furthermore, before the step of communicating data with the second target proxy application service through the second connection and the target proxy server to enable the target client to access the target server cluster through the target proxy server and the second target proxy application service, the method further includes: Verify the connectivity of the second connection; If the verification is successful, the process proceeds to the step of communicating data with the second target proxy application service through the second connection and the target proxy server, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service.
[0090] Furthermore, before re-establishing data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service, the method further includes: Verify the connectivity of the first connection; If the verification is successful, the process proceeds to re-establish data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service.
[0091] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing program code with the following initialization steps: monitoring the status information corresponding to a first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, the first connection being a connection between the target client and the target proxy server; when the status information corresponding to the first target proxy application service is detected to be pending upgrade, communicating with a second target proxy application service through a second connection and the target proxy server, so that the target client accesses a target server cluster through the target proxy server and the second target proxy application service, wherein the second connection is a connection between the target client and the target proxy server, the target server cluster comprising multiple server nodes, and a target database service deployed on the multiple server nodes.
[0092] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0093] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0094] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0095] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0096] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0097] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0098] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0099] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0100] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0101] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A database access method, characterized in that, The method is applied to the target client, and the method includes: Monitor the status information corresponding to the first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, and the first connection is the connection between the target client and the target proxy server; When the status information corresponding to the first target proxy application service is detected to be pending upgrade, data communication is performed between the second target proxy server and the second target proxy application service through the second connection, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. The second connection is the connection between the target client and the target proxy server. The target server cluster contains multiple server nodes, and the target database service is deployed on the multiple server nodes.
2. The method according to claim 1, characterized in that, After the data communication between the second target proxy application service and the second target proxy server via the second connection, the method further includes: Monitor the status information corresponding to the first target proxy application service; When the status information corresponding to the first target proxy application service is detected to have changed to "upgrade complete", the target client re-establishes data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service.
3. The method according to claim 1, characterized in that, Before monitoring the status information corresponding to the first target proxy application service, the method further includes: Establish the first connection with the target proxy server, so as to establish a connection with the first target proxy application service through the first connection and the target proxy server; Establish the second connection with the target proxy server, so as to establish a connection with the second target proxy application service through the second connection and the target proxy server; The target client communicates with the target server and the first target proxy application service through the first connection, so that the target client can access the target server cluster through the target proxy server and the first target proxy application service.
4. The method according to claim 3, characterized in that, The method further includes: The first connection receives proxy information sent by the target proxy server, wherein the proxy information includes a unique identifier corresponding to the first target proxy application service and a unique identifier corresponding to the first target server, and the first target proxy application service is deployed on the first target server.
5. The method according to claim 4, characterized in that, The status information corresponding to the first target proxy application service being monitored includes: Based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the target server, a status information data table is monitored. For any proxy application service, the status information data table records the correspondence between the unique identifier corresponding to the proxy application service, the unique identifier corresponding to the server where the proxy application service resides, and the status information corresponding to the proxy application service; or Listen to the upgrade log of the proxy application service based on the unique identifier corresponding to the first target proxy application service and the unique identifier corresponding to the target server. The upgrade log of the proxy application service records one or more upgrade information. For any upgrade message, the upgrade information records the correspondence between the unique identifier corresponding to the proxy application service, the unique identifier corresponding to the server where the proxy application service is located, and the status information corresponding to the proxy application service.
6. The method according to claim 1, characterized in that, Before the step of communicating data with the second target proxy application service via the second connection and the target proxy server to enable the target client to access the target server cluster through the target proxy server and the second target proxy application service, the method further includes: Verify the connectivity of the second connection; If the verification is successful, the process proceeds to the step of communicating data with the second target proxy application service through the second connection and the target proxy server, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service.
7. The method according to claim 2, characterized in that, Before re-establishing data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service, the method further includes: Verify the connectivity of the first connection; If the verification is successful, the process proceeds to re-establish data communication with the first target proxy application service through the first connection and the target proxy server, so that the target client can access the target server cluster again through the target proxy server and the first target proxy application service.
8. A database access device, characterized in that, The device is applied to a target client, and the device includes: The first listening unit is used to listen to the status information corresponding to the first target proxy application service, wherein the target client communicates with the first target proxy application service through a first connection and a target proxy server, and the first connection is the connection between the target client and the target proxy server; The second access unit is used to communicate with the second target proxy application service through the second connection and the target proxy server when the status information corresponding to the first target proxy application service is changed to pending upgrade, so that the target client can access the target server cluster through the target proxy server and the second target proxy application service. The second connection is the connection between the target client and the target proxy server. The target server cluster includes multiple server nodes, and the target database service is deployed on the multiple server nodes.
9. A storage medium, characterized in that, The storage medium includes a stored program, wherein, when the program is executed, it controls the device where the storage medium is located to perform the database access method according to any one of claims 1 to 7.
10. A database access device, characterized in that, The apparatus includes a storage medium; and one or more processors, the storage medium being coupled to the processors, the processors being configured to execute program instructions stored in the storage medium; the program instructions, when executed, perform the database access method according to any one of claims 1 to 7.
