Distributed database replication time delay query method and device and electronic equipment
By obtaining the server deployment information of the distributed database and determining the host server group, and accurately issuing the replication delay query statement, the performance loss problem during replication delay data acquisition in the distributed database is solved, query efficiency is improved and the efficient operation of the system is ensured.
Patent Information
- Application Number
- CN202411968707.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-25
AI Technical Summary
In the distributed database scenario, due to the large number of nodes, performance loss problems during replication delay data acquisition, especially as the number of nodes increases, performance loss tends to grow exponentially.
When executing replication delay query statements, first obtain the server deployment information of the query area, and determine the host server group that needs to be issued when replication delay query statements, and accurately send the query statements to these host server groups.
It effectively solves the performance loss problem caused by the large number of distributed database nodes, improves query efficiency, and ensures efficient operation of the system.
Smart Images

Figure CN119884212A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for querying replication delay of a distributed database. Background Art
[0002] Usually, database monitoring collects replication delay data between the master and standby servers to evaluate the security of data synchronization between the master and standby servers. Currently, the common method for collecting replication delay data between the master and standby servers is to monitor each master and standby server, and aggregate the collected data to the monitoring server, display it on the monitoring interface, or trigger an alarm based on the preset threshold.
[0003] However, in the scenario of centralized databases, the performance impact can be ignored because the network structure is relatively simple and the number of nodes is small. However, when applied to the scenario of distributed databases, the problem of performance loss becomes particularly prominent because the distributed database network is usually large in scale and has a large number of nodes. Moreover, as the number of nodes increases, the performance loss tends to increase exponentially.
[0004] Therefore, there is an urgent need to develop a distributed database replication delay query method, device, electronic device and storage medium to solve one or more of the above-mentioned problems. Summary of the invention
[0005] In view of this, in order to solve the above-mentioned technical problems or part of the technical problems, an embodiment of the present invention provides a method, device, electronic device and storage medium for querying replication delay of a distributed database.
[0006] In a first aspect, the present application provides a method for querying replication delay of a distributed database, the method comprising:
[0007] Receiving a replication delay query statement, wherein the replication delay query statement is used to query the replication delay between the standby server and the host server in the distributed database;
[0008] In response to the replication delay query statement, acquiring server deployment information of the query area;
[0009] Based on the server deployment information, determining a host server group included in the query area;
[0010] The replication delay query statement is sent to the host server group to obtain replication delay data returned by the host server group in response to the replication delay query statement.
[0011] In a possible implementation manner, before sending the replication delay query statement to the host server group, the method further includes:
[0012] Obtaining the server type of each host server in the host server group in turn;
[0013] The host servers in the host server group are divided into a first host server and a second host server according to the server type.
[0014] In a possible implementation manner, sending the replication delay query statement to the host server group includes:
[0015] Sending the replication delay query statement to the first host server through a first query channel, where the first query channel is a data transmission channel between the first host server and the collector established based on a distributed database computing node;
[0016] The replication delay query statement is sent to the second host server through a second query channel, where the second query channel is a data transmission channel between the second host server and the collector.
[0017] In a possible implementation manner, obtaining the replication delay data returned by the host server group in response to the replication delay query statement includes:
[0018] obtaining, through a first query channel, first replication delay data returned by a first host server among the host servers in response to the replication delay query statement, wherein the first replication delay data is delay data generated when the first host server and a standby server connected to the first host server perform data replication;
[0019] The second replication delay data returned by the second host server in the host server in response to the replication delay query statement is obtained through the second query channel. The second replication delay data is the delay data generated when the second host server and the backup server connected to the second host server perform data replication.
[0020] In a possible implementation, before acquiring the server deployment information of the query area, the method includes:
[0021] Determine a geographical area set corresponding to the query area, wherein the geographical area set includes a local area and a foreign area;
[0022] Using the host server corresponding to the local area as the first host server;
[0023] A logical main server is selected from a set of backup servers corresponding to the remote area as a second host server of the remote area, and the second host server is connected to the first host server.
[0024] In a possible implementation, the second host server is connected to the first host server via an asynchronous replication link.
[0025] In a possible implementation, both the first host server and the second host server are connected to the standby server via a semi-synchronous replication link.
[0026] In a second aspect, the present application provides a cloud database deployment device, the device comprising:
[0027] A receiving module, used to receive a replication delay query statement, wherein the replication delay query statement is used to query the replication delay between the standby server and the host server in the distributed database;
[0028] An acquisition module, configured to acquire server deployment information of a query area in response to the replication delay query statement;
[0029] A determination module, configured to determine a host server group included in the query area based on the server deployment information;
[0030] The sending module is used to send the replication delay query statement to the host server group, and obtain the replication delay data returned by the host server group in response to the replication delay query statement.
[0031] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the distributed database replication delay query method described in any one of the embodiments of the first aspect are implemented.
[0032] In a fourth aspect, the present application further provides a computer storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the distributed database replication delay query method described in any one of the embodiments of the first aspect are implemented.
[0033] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application, when executing a replication delay query statement, first obtains the server deployment information of the query area, determines the host server group to which the replication delay query statement needs to be issued based on the server deployment information, and then accurately issues the replication delay query statement to the host server group, so that the local host in the host server returns the replication delay data of all standby machines in the area where the host is located through CN, and the remote logical host LM returns the replication delay data of all standby machines in its own area, which solves the performance loss problem caused by a large number of distributed database nodes and improves query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0036] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0037] Figure 1 A schematic diagram of a flow chart of a distributed database replication delay query method provided in an embodiment of the present application;
[0038] Figure 2 A schematic diagram of a flow chart of another distributed database replication delay query method provided in an embodiment of the present application;
[0039] Figure 3 A data collection flow chart of a distributed database replication delay query method provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of the structure of a distributed database replication delay query device provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0043] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0044] This method is usually used in centralized databases with one master and multiple backups because of its small scale, simplicity, and negligible performance loss. In a distributed database, such as the GoldenDB distributed database, a tenant database has multiple shards, for example, 100 shards, each with 6 replicas (1 master and 5 backups), distributed in three central computer rooms in two cities. For a database of this size, the replication delay data is collected once, and each backup node collects the data (the master node does not collect the data). It is necessary to execute 500 collection commands at a time, and then the 500 results are transmitted to the monitoring server through the network, and the monitoring server parses and stores them in the database. Because of the large scale of distributed databases, the total performance overhead of collecting replication delay data once is relatively large.
[0045] In order to solve the problem in the prior art that the distributed database network scale is usually large and the number of nodes is large, resulting in a large amount of performance loss, the present application provides a distributed database replication delay query method, device, electronic device and storage medium. In the process of executing the replication delay query statement, it is first necessary to obtain the server deployment information of the query area, and then determine the host server group to which the replication delay query statement needs to be issued based on the deployment information to ensure that the query statement can be accurately sent to the correct host server group. Once the target host server group is determined, the replication delay query statement will be accurately issued to these host server groups. Among the host servers, the local host will play a key role and return the replication delay data of all standby machines in the host area through the CN (control node). At the same time, the remote logical host LM (logical manager) will also return the replication delay data of all standby machines in its own area. In this way, the performance loss problem caused by the large number of distributed database nodes can be effectively solved, the data processing flow is optimized, and the query efficiency is significantly improved, ensuring the efficient operation of the entire system.
[0046] For example, for a tenant database with 100 shards, each shard has 6 copies (1 master and 5 backups), distributed in 2 regions, of which region 1 has 1 host and 3 backups, and region 2 has 1 logical master and one backup. In the original solution, each acquisition replication delay required 500 acquisition commands to be executed, 500 results to be transmitted, and 500 parsing and storage. In the current solution, region 1 has 1 acquisition command, 1 result, and 1 parsing and storage; region 2 has 100 acquisition commands, 100 results, and 100 parsing and storage; a total of 101 acquisition commands, 101 transmissions, and 101 parsing and storage. If the distributed database network only has copies in the local area and no copies in other regions, it only needs to execute 1 acquisition command, transmit 1 result, and parse and store once, which optimizes the data processing flow and significantly improves query efficiency.
[0047] Figure 1 A schematic diagram of a distributed database replication delay query method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method specifically includes:
[0048] S101, receiving a replication delay query statement, where the replication delay query statement is used to query the replication delay between a standby server and a host server in a distributed database;
[0049] In this embodiment, database monitoring collects replication delay data between the primary and standby machines to evaluate the security of data synchronization between the primary and standby machines. The collector receives the replication delay query statement sent by the monitoring server to query the replication delay between the standby server and the host server in the distributed database.
[0050] S102, in response to the replication delay query statement, obtaining server deployment information of the query area;
[0051] In this embodiment, after receiving the replication delay query statement, in response to the proposed replication delay query statement, server deployment information related to the query area is obtained.
[0052] Specifically, key factors such as the geographical location of the server, the connection relationship between servers, and the server type are obtained.
[0053] In this embodiment, the server deployment information of the query area includes but is not limited to key factors such as the geographical location of the server, the connection relationship between the servers, and the server type. Through this information, different types of host servers, such as the first host server and the second host server, and the replication delay data between them can be effectively identified and distinguished.
[0054] S103, determining a host server group included in the query area based on the server deployment information;
[0055] The host and standby machines of a distributed database correspond to data nodes and computing nodes respectively. The main function of the data node is to store data and perform data operations such as adding, deleting, modifying, and checking. The server type, hardware resources, and installed software of the host and standby machines are usually the same. The management node assigns them a master or standby role. This role is logical. There can only be one host in a shard, and the others are standby machines.
[0056] A distributed database has multiple shards, each of which has a master and multiple backup machines. The master and backup roles are changeable. If a master fails, the management node will select a backup machine from the backup machines to become the new master, and the original master will be downgraded to a backup machine. The backup machine is a redundant node set up for disaster recovery needs. It is a redundant copy of the master machine. The backup machine establishes a connection with the master machine to synchronize data, thereby ensuring that there are multiple copies of the data and they are consistent.
[0057] Specifically, the computing node connects to the host and sends SQL requests to the host; the host stores data, executes the SQL statements sent by the computing node CN, and returns the results to CN.
[0058] In this embodiment, after acquiring the server deployment information, the deployment information is analyzed to obtain the server configuration and the network topology structure, thereby determining the host server group included in the query area.
[0059] The host server group is composed of a plurality of host servers or logical host servers with pre-divided address areas.
[0060] S104: Send the replication delay query statement to the host server group to obtain replication delay data returned by the host server group in response to the replication delay query statement.
[0061] In this embodiment, after the host server group in the query area is determined, the replication delay query statement is sent to the host servers in the host server group, so that the host server returns the replication delay data between the host server and the backup server.
[0062] The replication delay query method of a distributed database provided in an embodiment of the present application, when executing a replication delay query statement, first obtains the server deployment information of the query area, determines the host server group to which the replication delay query statement needs to be issued based on the server deployment information, and then accurately issues the replication delay query statement to the host server group, so that the local host in the host server returns the replication delay data of all standby machines in the area where the host is located through CN, and the remote logical host LM returns the replication delay data of all standby machines in its own area, thereby solving the performance loss problem caused by the large number of distributed database nodes and significantly improving the query efficiency.
[0063] In an optional solution of the embodiment of the present invention, before sending the replication delay query statement to the host server group, the method further includes:
[0064] Obtaining the server type of each host server in the host server group in turn;
[0065] The host servers in the host server group are divided into a first host server and a second host server according to the server type.
[0066] In this embodiment, before sending the replication delay query statement to the host server group, the type information of each server in the host server group is first determined.
[0067] Specifically, each host server in the mentioned host server group is checked in turn to obtain their respective server type information; then, based on the obtained server type information, all host servers in the host server group are classified to divide them into two different groups, namely the first host server group and the second host server group.
[0068] For example, Figure 3 As shown, in area 1, there is a standby server (S) and a main server (M), while in area 2, there is a standby server (LS) and a logical main server (LM), and the host server group is composed of the main server (M) of area 1 and the logical main server (LM) of area 2. By identifying the type of the host server, it can be determined whether the host belongs to a physical host server or a logical host server; based on the identification of this server type, the host server group is effectively classified, so as to realize efficient query of the replication delay data of the standby machines in different areas.
[0069] In an optional solution of the embodiment of the present invention, the sending the replication delay query statement to the host server group includes:
[0070] Sending the replication delay query statement to the first host server through a first query channel, where the first query channel is a data transmission channel between the first host server and the collector established based on a distributed database computing node;
[0071] In this embodiment, a data transmission channel is established between the first host server and the collector based on the distributed database computing node, and then the replication delay query statement is sent to the first host server through the first query channel, thereby realizing stable and secure data transmission between the first host server and the data collector.
[0072] For example, Figure 3As shown, the collector sends a query replication delay SQL request to the computing node CN, and the computing node CN sends a query replication delay SQL request to the host M of all shards.
[0073] The replication delay query statement is sent to the second host server through a second query channel, where the second query channel is a data transmission channel between the second host server and the collector.
[0074] In this embodiment, a data transmission channel is established between the second host server and the collector, and then the replication delay query statement is sent to the second host server through the second query channel, thereby achieving stable and secure data transmission between the second host server and the data collector.
[0075] For example, Figure 3 As shown, the collector is directly connected to the logical master LM of each shard and sends a SQL request to query the replication delay.
[0076] In an optional solution of the embodiment of the present invention, obtaining the replication delay data returned by the host server group in response to the replication delay query statement includes:
[0077] obtaining, through a first query channel, first replication delay data returned by a first host server among the host servers in response to the replication delay query statement, wherein the first replication delay data is delay data generated when the first host server and a standby server connected to the first host server perform data replication;
[0078] In this embodiment, first replication delay data generated when a first host server and a standby server connected to the first host server perform a data replication operation is obtained through a first query channel.
[0079] For example, the host M returns the replication delay data of all semi-synchronous standby machines it has to the computing node, and the computing node summarizes and returns it to the collector. Figure 1 As shown, the collector obtains the replication delay data of all backup machines in the entire area 1 through the computing node CN.
[0080] The second replication delay data returned by the second host server in the host server in response to the replication delay query statement is obtained through the second query channel. The second replication delay data is the delay data generated when the second host server and the backup server connected to the second host server perform data replication.
[0081] In this embodiment, first replication delay data generated when the second host server and the standby server connected to the second host server perform a data replication operation is obtained through the second query channel.
[0082] Exemplarily, the logical master returns its own replication delay and the replication delay data of the standby machine with which it has established a semi-synchronous replication link to the collector. Figure 1 As shown in the figure, the collector obtains the replication delay data of all backup machines in area 2.
[0083] In addition, after collecting the replication delay data, the collector actively reports the collected replication delay data of all standby machines to the monitoring server. The monitoring server analyzes the reported replication delay data to determine whether there is a situation where the replication delay is too high. If it is found that the replication delay exceeds the preset threshold, the monitoring server will trigger an alarm and send relevant information to the database administrator. The monitoring server can also be responsible for recording and storing historical replication delay data to facilitate subsequent performance analysis and troubleshooting. In this way, the database administrator can understand the database replication status in a timely manner to ensure data consistency and system stability.
[0084] The distributed database replication delay query method provided in the embodiment of the present application periodically sends a replication delay query SQL request to the computing node CN and each shard logical host LM through the collector, and CN returns the replication delay data of all backup machines in the area where the host is located, and the logical host LM returns the replication delay data of all backup machines in its own area.
[0085] Figure 2 A flow chart of another distributed database replication delay query method provided in an embodiment of the present application is shown as follows: Figure 2 The method shown includes:
[0086] S201, determining a geographical area set corresponding to the query area, wherein the geographical area set includes a local area and a remote area;
[0087] S202, using the host server corresponding to the local area as the first host server;
[0088] S203: Select a logical main server from a set of backup servers corresponding to the remote area as a second host server in the remote area, and connect the second host server to the first host server.
[0089] In this embodiment, the geographical area set corresponding to the query area is determined, and the geographical area set includes the local area and the remote area, as well as the IP addresses of the local area and the remote area; the host server in the local area is used as the first host server, that is, the main server, and a logical main server is selected from the backup server set corresponding to the remote area, and the logical main server is used as the second host server in the remote area, and finally the second host server is connected to the first host server.
[0090] For example, Figure 3 As shown, a logical host LM is selected from region 2 to establish an asynchronous replication link with the host M in region 1 as a standby host. The host sends a log synchronization request to the logical host and continues to execute without waiting for an ACK response.
[0091] In an optional solution of the embodiment of the present invention, the second host server is connected to the first host server via an asynchronous replication link.
[0092] Asynchronous replication means that the master sends a log synchronization request to the standby and continues to execute without waiting for the standby to reply with an ACK response. In the same shard, the standby is located in a different area from the master. Due to the long geographical distance, the network communication delay is relatively large. At this time, the semi-synchronous mechanism cannot be used to synchronize with the master, and an asynchronous link needs to be established.
[0093] An asynchronous replication link is a communication path that data replication technology relies on. In the field of data storage, asynchronous replication means that the data replication operation is not performed simultaneously with the source data update operation. In other words, after the source system (such as a database server) updates the data, it will not wait for the replication system (such as a backup database server) to complete the data replication before continuing to the next operation. The asynchronous replication link is the connection channel used to transmit the data that needs to be replicated between the source and the target.
[0094] In this embodiment, the second host server establishes a connection with the first host server through an asynchronous replication link.
[0095] In an optional solution of the embodiment of the present invention, both the first host server and the second host server are connected to the standby server via a semi-synchronous replication link.
[0096] In a semi-synchronous replication link, when a transaction is committed on the master node (such as the master database server), the master node will send the transaction data and related log information to one or more standby nodes (such as standby database servers). The master node will wait for the slave node to return a confirmation signal of successful reception. This confirmation signal indicates that the slave node has successfully received the transaction data and has written the data to the cache or log of its own storage system (such as a disk, etc.).
[0097] In this embodiment, the host server is connected to the standby server via a semi-synchronous replication link.
[0098] For example, the backup machine reports the replication delay data to the master in the ACK response. Semi-synchronization means that the master establishes a link with the backup machine, sends a log synchronization request, and then waits for the backup machine to reply with an ACK response; the backup machine receives the log synchronization request and replies with an ACK response to the master; after the master receives the ACK response, it continues to execute; the backup machines in the same region can establish a semi-synchronous replication link with the master because of their short geographical distance and low latency. Figure 3 The backup machine (S) and the master machine (M) in area 1, and the backup machine (LS) and the logical master machine (LM) in area 2. The ACK response is modified here to carry the replication delay of the backup machine relative to the master machine, including the synchronization delay and the playback delay. The master receives the ACK response and parses it to obtain the replication delay of the backup machine. In this way, in the semi-synchronous area, the master has the replication delay data of all the backup machines synchronized with it.
[0099] The distributed database replication delay query method provided in the embodiment of the present application groups the backup machines by geographical region, and the DN nodes in the same region are divided into the host (or logical host) and the backup machine, and a semi-synchronous replication link is established between the backup machine and the host. The DN nodes in the remote region select the logical host and establish an asynchronous replication link with the host in the local region.
[0100] Figure 4 A schematic diagram of the structure of a distributed database replication delay query device provided in an embodiment of the present application, such as Figure 4 As shown, the device specifically includes:
[0101] A receiving module 401 is used to receive a replication delay query statement, where the replication delay query statement is used to query the replication delay between the standby server and the host server in the distributed database;
[0102] An acquisition module 402 is used to acquire server deployment information of a query area in response to the replication delay query statement;
[0103] A determination module 403 is used to determine a host server group included in the query area based on the server deployment information;
[0104] The sending module 404 is used to send the replication delay query statement to the host server group to obtain the replication delay data returned by the host server group in response to the replication delay query statement.
[0105] In a possible implementation, the sending module 404 is further configured to sequentially obtain a server type of each host server in the host server group; and divide the host servers in the host server group into a first host server and a second host server according to the server type.
[0106] In one possible implementation, the sending module 404 is also used to send the replication delay query statement to the first host server through a first query channel, where the first query channel is a data transmission channel between the first host server and the collector established based on a distributed database computing node; and to send the replication delay query statement to the second host server through a second query channel, where the second query channel is a data transmission channel between the second host server and the collector.
[0107] In one possible embodiment, the sending module 404 is also used to obtain, through a first query channel, first replication delay data returned by a first host server among the host servers in response to the replication delay query statement, wherein the first replication delay data is delay data generated when the first host server and the backup server connected to the first host server perform data replication; and obtain, through a second query channel, second replication delay data returned by a second host server among the host servers in response to the replication delay query statement, wherein the second replication delay data is delay data generated when the second host server and the backup server connected to the second host server perform data replication.
[0108] In one possible embodiment, the acquisition module 402 is also used to determine a set of geographical areas corresponding to the query area, the set of geographical areas including a local area and a remote area; use the host server corresponding to the local area as the first host server; select a logical main server from the set of backup servers corresponding to the remote area as the second host server of the remote area, and connect the second host server to the first host server.
[0109] The distributed database replication delay query device provided in this embodiment can be as follows: Figure 4 The distributed database replication delay query device shown in can be executed as follows Figure 1-3 All steps of the replication delay query of the distributed database in the Figure 1-3 The technical effect of distributed database replication delay query is shown in the figure. For details, please refer to Figure 1-3 For the sake of brevity, the relevant description is not repeated here.
[0110] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0111] Figure 5A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, an embodiment of the present application provides an electronic device, including a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504; the memory 503 is used to store computer programs; the processor 501 is used to execute the program stored in the memory 503, and implement the steps of the distributed database replication delay query method provided by any of the aforementioned method embodiments:
[0112] Receive a replication delay query statement, where the replication delay query statement is used to query the replication delay between a backup server and a host server in a distributed database; in response to the replication delay query statement, obtain server deployment information of a query area; based on the server deployment information, determine a host server group included in the query area; send the replication delay query statement to the host server group, and obtain replication delay data returned by the host server group in response to the replication delay query statement.
[0113] In a possible implementation, the server type of each host server in the host server group is obtained in turn; and the host servers in the host server group are divided into a first host server and a second host server according to the server type.
[0114] In one possible implementation, the replication delay query statement is sent to the first host server through a first query channel, where the first query channel is a data transmission channel between the first host server and the collector established based on a distributed database computing node; the replication delay query statement is sent to the second host server through a second query channel, where the second query channel is a data transmission channel between the second host server and the collector.
[0115] In one possible implementation, first replication delay data returned by a first host server among the host servers in response to the replication delay query statement is obtained through a first query channel, wherein the first replication delay data is delay data generated when the first host server and a backup server connected to the first host server perform data replication; second replication delay data returned by a second host server among the host servers in response to the replication delay query statement is obtained through a second query channel, wherein the second replication delay data is delay data generated when the second host server and a backup server connected to the second host server perform data replication.
[0116] In one possible implementation, a set of geographic areas corresponding to the query area is determined, the set of geographic areas including a local area and a remote area; a host server corresponding to the local area is used as a first host server; a logical main server is selected from a set of backup servers corresponding to the remote area as a second host server for the remote area, and the second host server is connected to the first host server.
[0117] In a possible implementation, the second host server is connected to the first host server via an asynchronous replication link.
[0118] In a possible implementation, both the first host server and the second host server are connected to a standby server via a semi-synchronous replication link.
[0119] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0121] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0122] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A distributed database replication delay query method, characterized in that: include: Receiving a replication delay query statement, wherein the replication delay query statement is used to query the replication delay between the standby server and the host server in the distributed database; In response to the replication delay query statement, acquiring server deployment information of the query area; Based on the server deployment information, determining a host server group included in the query area; The replication delay query statement is sent to the host server group to obtain replication delay data returned by the host server group in response to the replication delay query statement.
2. The method according to claim 1, characterized in that: Before sending the replication delay query statement to the host server group, the method further includes: Obtaining the server type of each host server in the host server group in turn; The host servers in the host server group are divided into a first host server and a second host server according to the server type.
3. The method according to claim 2, characterized in that The sending the replication delay query statement to the host server group includes: Sending the replication delay query statement to the first host server through a first query channel, where the first query channel is a data transmission channel between the first host server and the collector established based on a distributed database computing node; The replication delay query statement is sent to the second host server through a second query channel, where the second query channel is a data transmission channel between the second host server and the collector.
4. The method according to claim 3, characterized in that: The obtaining the replication delay data returned by the host server group in response to the replication delay query statement includes: obtaining, through a first query channel, first replication delay data returned by a first host server among the host servers in response to the replication delay query statement, wherein the first replication delay data is delay data generated when the first host server and a standby server connected to the first host server perform data replication; The second replication delay data returned by the second host server in the host server in response to the replication delay query statement is obtained through the second query channel. The second replication delay data is the delay data generated when the second host server and the backup server connected to the second host server perform data replication.
5. The method according to claim 1, characterized in that Before acquiring the server deployment information of the query area, the method includes: Determine a geographical area set corresponding to the query area, wherein the geographical area set includes a local area and a foreign area; Using the host server corresponding to the local area as the first host server; A logical main server is selected from a set of backup servers corresponding to the remote area as a second host server of the remote area, and the second host server is connected to the first host server.
6. The method according to claim 5, characterized in that The second host server is connected to the first host server via an asynchronous replication link.
7. The method according to claim 4, characterized in that The first host server and the second host server are both connected to the standby server via a semi-synchronous replication link.
8. A distributed database replication delay query device, characterized in that: A receiving module, used to receive a replication delay query statement, wherein the replication delay query statement is used to query the replication delay between the standby server and the host server in the distributed database; An acquisition module, configured to acquire server deployment information of a query area in response to the replication delay query statement; A determination module, configured to determine a host server group included in the query area based on the server deployment information; The sending module is used to send the replication delay query statement to the host server group, and obtain the replication delay data returned by the host server group in response to the replication delay query statement.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the distributed database replication delay query method according to any one of claims 1 to 7 are implemented.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the distributed database replication delay query method according to any one of claims 1 to 7 are implemented.