Time-series database cluster and its fault handling, operation method, and device

By creating a new virtual node in the timing database cluster and updating the host name mapping file, the high availability problem in the event of data node failure is solved, the stability and reliability of the system are improved, and the failure migration process is simplified.

CN113778761BActive Publication Date: 2025-07-25BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110943049.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-17
Publication Date
2025-07-25
Estimated Expiration
2041-08-17

AI Technical Summary

Technical Problem

Existing time-series database clusters are difficult to achieve high availability when data nodes fail, and metadata changes are complex, affecting system stability and reliability.

Method used

Create a new virtual node in the timing database cluster, copy the configuration file and data disk of the failed data node to the virtual node, and update the host name mapping file, so that the virtual node can replace the failed node to provide services and avoid metadata changes.

Benefits of technology

It realizes high availability of time-series database clusters when data node failures, improves system stability and reliability, and reduces the complexity of failure migration and metadata instability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113778761B_ABST
    Figure CN113778761B_ABST
Patent Text Reader

Abstract

The present application relates to a time series database cluster and its fault handling method, operation method, and device. The time series database cluster includes: at least one metadata node and multiple data nodes; the multiple data nodes are replicas of each other; the metadata node is used to store metadata, and the metadata at least includes the host names of the data nodes. The method includes: when it is detected that any data node fails, a virtual node is created; the configuration file of the failed data node is copied to the virtual node, and the data disk of the failed data node is mounted to the virtual node; in the host name mapping file of the time series database cluster, the IP address in the target mapping relationship is updated to the IP address of the virtual node, so that the virtual node replaces the failed data node to provide data services. Thus, when any data node in the time series database cluster fails, fault transfer can be achieved without modifying the metadata, making the time series database cluster highly available.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of time series databases, and particularly to a time series database cluster, a fault handling method, an operation method, and a device thereof. Background Art

[0002] Time series data refers to time series data (abbreviated as time series data), which is a data column that records the data of the same indicator in chronological order and is commonly found in IT infrastructure, operation and maintenance monitoring systems, and the Internet of Things. Correspondingly, a time series database is a specific type of database mainly used to store time series data.

[0003] In practice, implementing a time series database cluster solution is a very complex task, and at least the goal of high availability needs to be achieved, that is, when a data node in the cluster fails, the cluster has the ability to self-heal. Summary of the Invention

[0004] This application provides a time series database cluster, a fault handling method, an operation method, and a device thereof to improve the reliability and stability of the time series database cluster.

[0005] In a first aspect, this application provides a fault handling method for a time series database cluster. The time series database cluster includes: at least one metadata node and multiple data nodes; the data nodes are used to store time series data, and multiple data nodes are replicas of each other; the metadata node is used to store the metadata of the time series database cluster, and the metadata at least includes the host name of each data node; the method includes:

[0006] When it is detected that any one of the data nodes fails, a virtual node is created;

[0007] Copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node;

[0008] In the host name mapping file of the time series database cluster, update the IP address in the target mapping relationship to the IP address of the virtual node, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node;

[0009] Restart the time series database cluster so that the virtual node replaces the failed data node to provide data services.

[0010] In a possible implementation manner, the time series database cluster further includes a liveness detection component, and the liveness detection component is used to periodically send liveness detection messages to each data node;

[0011] The detection that any one of the data nodes fails includes:

[0012] For each of the data nodes, if an acknowledgment message returned by the data node based on the probing message is not received within the current timeout period, it is determined that the data node has failed. The current timeout period refers to: a time period starting from the time when the probing component last sent the probing message and with a set duration; or,

[0013] For each of the data nodes, if a heartbeat message sent by the data node is not received when a set period arrives, it is determined that the data node has failed.

[0014] In a second aspect, the present application provides an operation method for a time series database cluster, which is applied to the time series database cluster according to any one of the first aspects. The method includes:

[0015] When a data operation request is received, determine a target data node to be operated on from the time series database cluster;

[0016] Obtain the hostname of the target data node from the metadata;

[0017] Determine the target IP address corresponding to the obtained hostname from the hostname mapping file;

[0018] Based on the target IP address, perform a data operation corresponding to the data operation request on the target time series data to be operated on the target data node.

[0019] In a possible implementation manner, the determining a target data node to be operated on from the time series database cluster includes:

[0020] Based on the timestamp of the target time series data, determine the target shardgroup to which the target time series data belongs, where the timestamp is within the time range composed of the start time and the end time of the target shardgroup;

[0021] Determine all shards included in the target shardgroup;

[0022] Determine the data nodes bound to the shards as the data nodes to be operated on.

[0023] In a third aspect, the present application provides a time series database cluster, which at least includes: at least one metadata node, multiple data nodes, a probing component, and a virtual node creation component;

[0024] The data nodes are used to store time series data, and the multiple data nodes are replicas of each other;

[0025] The metadata node is used to store the metadata of the time series database cluster, and the metadata at least includes the host name of each data node;

[0026] The liveness detection component is used to detect the status of the data node, and the status includes normal and faulty;

[0027] The virtual node creation component is used to create a new virtual node when the liveness detection component detects that any data node fails; copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node; in the host name mapping file of the time series database cluster, update the IP address in the target mapping relationship to the IP address of the virtual node, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node; and restart the time series database cluster so that the virtual node provides data services instead of the failed data node.

[0028] In a possible implementation, the data disk is a cloud disk.

[0029] In a fourth aspect, the present application provides a fault handling device for a time series database cluster. The time series database cluster includes: at least one metadata node and multiple data nodes; the data nodes are used to store time series data, and multiple data nodes are replicas of each other; the metadata node is used to store the metadata of the time series database cluster, and the metadata at least includes the host name of each data node; the device includes:

[0030] A node creation module, which is used to create a new virtual node when it is detected that any data node fails;

[0031] A node configuration module, which is used to copy the configuration file of the failed data node to the virtual node and mount the data disk of the failed data node to the virtual node;

[0032] A mapping module, which is used to update the IP address in the target mapping relationship to the IP address of the virtual node in the host name mapping file of the time series database cluster, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node;

[0033] A restart module, which is used to restart the time series database cluster so that the virtual node provides data services instead of the failed data node.

[0034] In a fifth aspect, the present application provides an operation device for a time series database cluster, which is applied to the time series database cluster according to any one of the third aspects. The device includes:

[0035] A target determination module, configured to determine a target data node to be operated from the time-series database cluster when receiving a data operation request;

[0036] A first acquisition module, configured to acquire the host name of the target data node from the metadata;

[0037] A second acquisition module, configured to determine a target IP address corresponding to the acquired host name from the host name mapping file;

[0038] A data operation module, configured to perform a data operation corresponding to the data operation request on the target time-series data to be operated on the target data node based on the target IP address.

[0039] In a sixth aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0040] The memory is used to store a computer program;

[0041] The processor is configured to implement the steps of the method according to any one of the first aspect when executing the program stored on the memory.

[0042] In a seventh aspect, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method according to any one of the first aspect are implemented.

[0043] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art:

[0044] The technical solution provided by the embodiment of the present invention, by setting multiple data nodes in the time-series database cluster, when detecting that any data node fails, creating a virtual node, copying the configuration file of the failed data node to the virtual node, and mounting the data disk of the failed data node to the virtual node, enables the newly created virtual node to replace the original failed data node to provide data services, thereby realizing fault migration and making the time-series database cluster highly available; further, since when establishing the time-series database cluster, host names are used to configure the nodes participating in creating the cluster, and after fault migration, the host name of the newly created virtual node follows the host name of the original data node, it is possible to achieve that when the above-mentioned fault migration occurs, no changes need to be made to the metadata of the time-series database cluster, thereby improving the efficiency of fault migration of the time-series database cluster, and since the metadata of the time-series database cluster remains stable, the reliability and stability of the time-series database cluster can be improved. Description of the Drawings

[0045] The accompanying drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0047] Figure 1 It is a schematic diagram of the architecture of a time-series database cluster provided by an embodiment of the present application;

[0048] Figure 2 It is a schematic flowchart of a fault handling method for a time-series database cluster provided by an embodiment of the present application;

[0049] Figure 3 It is a schematic flowchart of an operation method for a time-series database cluster provided by an embodiment of the present application;

[0050] Figure 4 It is a schematic diagram of a fault handling device for a time-series database cluster provided by an embodiment of the present application;

[0051] Figure 5 It is a schematic diagram of an operation device for a time-series database cluster provided by an embodiment of the present application;

[0052] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts fall within the scope of protection of the present application.

[0054] Figure 1 It is a schematic diagram of the architecture of a time-series database cluster provided by an embodiment of the present application. As Figure 1 shown, the time-series database cluster 10 includes a metadata node 101, data nodes 102 to 104, a liveness detection component 105, and a virtual node creation component 106.

[0055] Among them, the metadata node 101 is used to store the metadata of the time series database cluster. Here, the metadata may include, but is not limited to: metadata node information, data node information, time series database information, etc. In the embodiments of the present application, the node information at least includes the hostname of the node. Optionally, it may further include the IP address, alias, etc. of the node. This means that in the embodiments of the present application, when establishing Figure 1 the time series database cluster 10 shown in the example, the nodes participating in creating the cluster are at least configured by the hostname. For example, as shown below, it is an example of the data node configuration file:

[0056] hostname="cluster.influxdb.238"

[0057] [clusterx]

[0058] #cluster node

[0059] #joins="10.69.58.54:8091, 10.69.32.214:8091, 10.69.32.51:8091"

[0060] joins="cluster.influxdb.54:8091, cluster.influxdb.214:8091, cluster.influxdb.51:8091"

[0061] In the above configuration file, hostname is the hostname of the data node, and joins is the node information of the other three nodes in the time series database cluster 10 except the data node with the hostname "cluster.influxdb.238", which may include the hostname and IP address.

[0062] Furthermore, the time series database cluster also has a hostname mapping file. The hostname mapping file, also known as the / etc / hosts file, is a file responsible for the quick resolution of IP addresses and hostnames (or domain names), and is saved in the / etc / directory in ASCII format. The hostname mapping file contains the mapping between IP addresses and hostnames, and may also include the aliases of the hosts. The access to the time series database cluster is all resolved by querying the hostname mapping file to obtain the IP address corresponding to a certain hostname, so as to achieve fast and convenient access. For example, as shown below, it is an example of the hostname mapping file:

[0063] 10.69.58.54cluster.influxdb.54

[0064] 10.69.32.214cluster.influxdb.214

[0065] 10.69.32.51cluster.influxdb.51

[0066] 10.69.32.238cluster.influxdb.238

[0067] Data nodes 102 - 104 are replicas of each other and are all used to store time series data. It can be understood that Figure 1 The illustrated time series database cluster stores time series data in a multi - replica form, which can improve data reliability and further enhance the stability and reliability of the time series database cluster.

[0068] Furthermore, the data nodes provide time series data storage services by mounting data disks. Optionally, the data disk is a cloud disk. It can be understood that by setting the data disk as a cloud disk, the local storage space of the data nodes can be greatly reduced.

[0069] It should be noted that in practice, the time series database cluster may include at least one metadata node and multiple data nodes. Figure 1 In the example, only one metadata node and three data nodes are included. Also, the metadata node and the data node can be the same node, that is, the node is used to store both time series data and the metadata of the time series database cluster. Figure 1 In the example, only the case where the metadata node and the data node are independent is taken. In addition, when the time series database cluster includes two or more metadata nodes, the two or more metadata nodes are backed up to each other. Through this setting, the metadata reliability can be improved, and further the stability and reliability of the time series database cluster can be enhanced.

[0070] The liveness detection component 105 is used to detect the status of the nodes in the time series database cluster. In the embodiments of the present application, it mainly detects the status of the data nodes. Here, the status of the nodes includes normal and faulty. As for how the liveness detection component 105 detects the node status, it is described in detail in the embodiments below Figure 2 and will not be elaborated here for now.

[0071] The virtual node creation component 106 is used to create a new virtual node when the liveness detection component 105 detects that any data node fails, and make the newly created virtual node be able to provide data services instead of the original faulty data node. Here, the data services include but are not limited to: data storage services, data query services, etc.

[0072] As an optional implementation, the virtual node creation component 106 can specifically be the Trove component. As for how the virtual node creation component 106 makes the newly created virtual node be able to provide data services instead of the original faulty data node, it is described in the embodiments belowFigure 2 The embodiments shown are described in detail and will not be elaborated here first.

[0073] Figure 2 The figure is a schematic flowchart of a method for handling faults in a time series database cluster provided by an embodiment of this application. The time series database cluster mentioned here can be Figure 1 the time series database cluster 10 shown in the example. As Figure 2 shown, it includes the following steps:

[0074] Step 201, when it is detected that any data node fails, create a virtual node.

[0075] As an embodiment, in Figure 1 the cluster architecture shown in the example, the liveness probe component 105 can periodically send liveness probe messages to each data node. Under normal circumstances, after receiving the liveness probe message, the data node can return a response message to the liveness probe component 105. Based on this, if the liveness probe component 105 receives a response message returned by the data node based on the liveness probe message within the current timeout period, it can be determined that the data node is normal; conversely, if the liveness probe component 105 does not receive a response message returned by the data node based on the liveness probe message within the current timeout period, it can be determined that the data node has failed. Here, the current timeout period refers to: a time period starting from the time when the liveness probe component sent the most recent liveness probe message and with a set duration (such as 1 second).

[0076] As another embodiment, each data node can send a heartbeat message to the liveness probe component 105 according to a set period, that is, under normal circumstances, the data node can periodically send a heartbeat message to the liveness probe component 105. Correspondingly, under normal circumstances, the liveness probe component 105 can receive the heartbeat messages sent by each data node every time the set period arrives. Based on this, if the liveness probe component 105 receives a heartbeat message sent by the data node when the set period arrives, it can be determined that the data node is normal; conversely, if the liveness probe component 105 does not receive a heartbeat message sent by the data node when the set period arrives, it can be determined that the data node has failed.

[0077] In addition, it should be noted that the liveness probe component 105 maintains node information of each data node in the time series database cluster, such as the host name, IP address, etc. Based on this, the liveness probe component 105 can send liveness probe messages to each data node, and then determine the status of each data node according to the received response messages, or can determine the status of each data node according to the received heartbeat messages.

[0078] In the embodiments of the present application, when it is detected that any data node fails, a virtual node can be newly created for the failed data node, so that the newly created virtual node can replace the failed data node to provide data services. It should be noted here that the number of newly created virtual nodes is greater than or equal to the number of failed data nodes, that is, for each failed data node, at least one virtual node is newly created.

[0079] Step 202: Copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node.

[0080] In the embodiments of the present application, after a virtual node is newly created for the failed data node, the configuration file of the failed data node is copied to the virtual node so that the newly created virtual node can use the configuration file of the original data node, and the data disk of the failed data node is mounted to the virtual node. It should be noted here that the newly created virtual node uses the configuration file of the original data node, which means that the newly created virtual node uses the hostname of the original data node.

[0081] For example, in Figure 1 the shown cluster architecture, assume that data node 102 fails, a virtual node 102' is newly created, the configuration file of data node 102 is copied to virtual node 102', and the cloud disk mounted on data node 102 is mounted to virtual node 102'. Through this kind of processing, it is equivalent to migrating the time series data on the original data node 102 to the newly created virtual node 102'.

[0082] Step 203: In the hostname mapping file of the time series database cluster, update the IP address in the target mapping relationship to the IP address of the virtual node, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node.

[0083] It can be understood that the IP address of the newly created virtual node is different from the IP address of the original failed data node. Therefore, to enable the newly created virtual node to replace the original failed data node, in the hostname mapping file of the time series database cluster, update the IP address in the mapping relationship (hereinafter referred to as the target correspondence relationship) corresponding to the failed data node to the IP address of the newly created virtual node. For example, assume that the data node with the hostname "cluster.influxdb.238" fails, and the IP address of the virtual node newly created for this data node is 10.69.32.235, then update 10.69.32.238cluster.influxdb.238 in the above-mentioned hostname mapping file to 10.69.32.235cluster.influxdb.238.

[0084] Step 204: Restart the time series database cluster so that the virtual node replaces the failed data node to provide data services.

[0085] In the embodiment of the present application, after performing the above steps 201 to 203, restarting the time series database cluster can make the virtual node effective, so that the virtual node replaces the failed data node to provide data services.

[0086] The technical solution provided by the embodiment of the present invention sets multiple data nodes in the time series database cluster. When it is detected that any data node fails, a virtual node is newly created, the configuration file of the failed data node is copied to the virtual node, and the data disk of the failed data node is mounted to the virtual node, so that the newly created virtual node can replace the original failed data node to provide data services, thereby realizing fault migration and making the time series database cluster highly available; further, since the host name is used to configure the nodes participating in creating the cluster when establishing the time series database cluster, and after the fault migration, the host name of the newly created virtual node follows the host name of the original data node, it is possible to achieve that no changes need to be made to the metadata of the time series database cluster during the above-mentioned fault migration, thereby improving the efficiency of fault migration of the time series database cluster, and since the metadata of the time series database cluster remains stable, the reliability and stability of the time series database cluster can be improved.

[0087] Figure 3 It is a schematic flowchart of an operation method for a time series database cluster provided by an embodiment of the present application. The time series database cluster mentioned here can be Figure 1 the time series database cluster 10 shown in the example. As Figure 3 shown, it includes the following steps:

[0088] Step 301: When a data operation request is received, determine the target data node to be operated on from the time series database cluster.

[0089] Step 302: Obtain the host name of the target data node from the metadata.

[0090] Step 303: Determine the target IP address corresponding to the obtained host name from the host name mapping file.

[0091] Step 304: Based on the target IP address, perform a data operation corresponding to the data operation request on the target time series data on the target data node.

[0092] In the embodiments of the present application, the data operation corresponding to the data operation request may be a data query operation or a data write operation, and the target time series data to be operated may be the time series data to be queried or the time series data to be written. Accordingly, the detailed implementation of the above steps 301 to 304 will be described separately from the data operations corresponding to the data operation requests being data query operations and data write operations.

[0093] First, when the data operation corresponding to the data operation request is a data query operation, the detailed implementation of the above steps 301 to 304 will be described:

[0094] The time series database cluster may have a load balancer, and the data operation requests sent by the client or other devices to the time series database cluster first reach this load balancer. After receiving the data operation request, the load balancer sends the data operation request to one of the data nodes. When starting up, the data node can pull the metadata of the time series database cluster from the metadata node.

[0095] As described above, the metadata may include time series database information. Accordingly, when receiving a data operation request, the data node first determines whether the database to be queried exists. If it exists, it determines the shardgroup to which the data to be queried belongs according to the timestamp of the data to be queried. The following is the structure of the shardgroup:

[0096] Type ShardGroupInfo struct{

[0097] ID unit64 / / Auto-incrementing id, uniquely identifying the shardgroup

[0098] StartTime time.Time / / Start time

[0099] EndTime time.Time / / End time

[0100] DeletedAt time.Time / / Deletion time

[0101] Shards[]ShardInfo / / Information of the shards in the shardgroup, such as shard ID

[0102] }

[0103] Based on the shardgroup structure shown above, after determining the shardgroup to which the data to be queried belongs, all shard IDs corresponding to the data to be queried can be determined, and then the data node IDs bound to the shard IDs can be determined. The data node corresponding to the data node ID is the data node to be operated on (hereinafter referred to as the target data node).

[0104] If the target data node is this data node (i.e., the data node that received the data operation request above), then this data node can perform the data query operation locally; if the target data node is not this data node, then this data node can further obtain the node information of the target data node from the metadata. In the embodiments of the present application, the node information at least includes the host name of the node. Therefore, this data node can obtain the host name of the target data node from the metadata.

[0105] Furthermore, the host name mapping file stores the mapping relationship between the host name and the IP address. Therefore, after this data node obtains the host name from the node information of the metadata, it can determine the target IP address corresponding to the obtained host name from the host name mapping file, that is, the IP address of the target data node. Then, the data operation request is sent to the target data node corresponding to the target IP address to perform the data query operation on the target data node.

[0106] In addition, after the data node performs the data query operation, the queried data is sent to the load balancer, and the load balancer forwards the data to the client. It should be noted that when the number of the above target data nodes is more than 1, after the load balancer receives the data queried by each target data node, it first merges the data and then forwards the merged data to the client.

[0107] Secondly, when the data operation corresponding to the data operation request is a data write operation, the detailed implementation of the above steps 301-304 will be described:

[0108] Similar to the above data query operation, after the load balancer receives the data operation request, it sends the data operation request to one of the data nodes. When the data node receives the data operation request, it first determines whether the database to be written exists. If it exists, it calculates the shardgroup to which the data to be written belongs according to the timestamp of the data to be written. Here, there are two cases:

[0109] Case 1: When the shardgroup to which the data to be written belongs exists, all shards included in it can be determined according to the structure of the shardgroup, and then according to the binding relationship between the shard ID and the data node ID, the data node corresponding to each shard can be determined, that is, the target data node to be operated on.

[0110] If the target data node is not this data node, this data node can further obtain the node information of the target data node from the metadata. In the embodiments of the present application, the node information at least includes the host name of the node. Therefore, this data node can obtain the host name of the target data node from the metadata.

[0111] Furthermore, the mapping relationship between the host name and the IP address is stored in the host name mapping file. Therefore, after this data node obtains the host name from the node information of the metadata, it can determine the target IP address corresponding to the obtained host name from the host name mapping file, that is, the IP address of the target data node. Then, the data operation request is sent to the target data node corresponding to the target IP address to perform a data query operation on the target data node.

[0112] Of course, if the target data node ID is this data node, the data write operation can be directly performed on this data node.

[0113] It should be noted that after the data node successfully executes the data write operation, it can return an indication message indicating successful data write to the client. After the client receives the indication messages sent by N data nodes, it can determine that the data write is successful. On the contrary, after receiving less than N indication messages sent by the data nodes, it can determine that the data write fails. When determining that the data write fails, the client can send a data operation request to the time series database cluster again after an interval of the set time to request to write data to the time series database cluster again. Here, N is greater than or equal to the number of replicas corresponding to the data to be written - 1.

[0114] Case 2: When the shardgroup to which the data to be written belongs does not exist, a new shardgroup is created. The start time of this shardgroup is the timestamp of the data to be written, and the end time is the start time plus the set time span. At the same time, a new shard ID is created and the data nodes that need to be bound are determined. As for the subsequent operations, reference can be made to the above description and will not be elaborated here.

[0115] It should be noted that the number of data nodes to which the above shard ID needs to be bound is determined by the number of replicas corresponding to the data to be written. For example, if the number of replicas of the data to be written is 3, the shard ID needs to be bound to 3 data nodes.

[0116] The technical solution provided by the embodiments of the present application, when receiving a data operation request, obtains the host name of the target data node to be operated from the metadata, determines the target IP address corresponding to the obtained host name from the host name mapping file, and based on the target IP address, executes a data operation corresponding to the data operation request on the target time-series data to be operated on the target data node. When establishing a time-series database cluster and using host names to configure the nodes participating in creating the cluster, data operations can be performed on the time-series database cluster. Moreover, since no changes need to be made to the metadata of the time-series database cluster during a failover, the metadata of the time-series database cluster can remain stable, making the time-series database cluster highly available.

[0117] Figure 4 It is a schematic diagram of a fault handling device for a time-series database cluster provided by the embodiments of the present application. The time-series database cluster mentioned here can be Figure 1 the exemplified time-series database cluster 10. As Figure 4 shown, the device includes:

[0118] A node creation module 41, configured to create a virtual node when it is detected that any one of the data nodes fails;

[0119] A node configuration module 42, configured to copy the configuration file of the failed data node to the virtual node and mount the data disk of the failed data node to the virtual node;

[0120] A mapping module 43, configured to update the IP address in the target mapping relationship to the IP address of the virtual node in the host name mapping file of the time-series database cluster, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node;

[0121] A restart module 44, configured to restart the time-series database cluster so that the virtual node provides data services instead of the failed data node.

[0122] In a possible implementation, the time-series database cluster further includes a liveness detection component, and the liveness detection component is configured to periodically send liveness messages to each data node; the device further includes (not shown in the figure): a fault detection module;

[0123] The fault detection module is specifically configured to:

[0124] For each data node, if an acknowledgment message returned by the data node based on the liveness message is not received within the current timeout period, it is determined that the data node has failed. The current timeout period refers to: a time period starting from the time when the liveness detection component last sent the liveness message and with a set duration as the duration; or,

[0125] For each of the data nodes, if a heartbeat message sent by the data node is not received when the set period arrives, it is determined that the data node has failed.

[0126] Figure 5 It is a schematic diagram of an operation device for a time series database cluster provided by an embodiment of the present application. The time series database cluster mentioned here can be Figure 1 the illustrated time series database cluster 10. As Figure 5 shown, the device includes:

[0127] A target determination module 51, configured to determine a target data node to be operated on from the time series database cluster when a data operation request is received;

[0128] A first acquisition module 52, configured to acquire the host name of the target data node from the metadata;

[0129] A second acquisition module 53, configured to determine a target IP address corresponding to the acquired host name from the host name mapping file;

[0130] A data operation module 54, configured to perform a data operation corresponding to the data operation request on the target time series data on the target data node based on the target IP address.

[0131] In a possible implementation manner, the target determination module 51 determines a target data node to be operated on from the time series database cluster, including:

[0132] Based on the time stamp of the target time series data, determine the target shardgroup to which the target time series data belongs, where the time stamp is within the time range composed of the start time and the end time of the target shardgroup;

[0133] Determine all shards included in the target shardgroup;

[0134] Determine the data node bound to the shard as the data node to be operated on.

[0135] As Figure 6 shown, an embodiment of the present application provides an electronic device, including a processor 611, a communication interface 612, a memory 613, and a communication bus 614. Among them, the processor 611, the communication interface 612, and the memory 613 communicate with each other through the communication bus 614.

[0136] The memory 613 is used to store a computer program;

[0137] In one embodiment of the present application, when the processor 611 executes the program stored on the memory 613, it implements the fault handling method of the time series database cluster provided in the foregoing method embodiment, including:

[0138] When it is detected that any one of the data nodes fails, a virtual node is created;

[0139] Copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node;

[0140] In the hostname mapping file of the time series database cluster, update the IP address in the target mapping relationship to the IP address of the virtual node, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node;

[0141] Restart the time series database cluster so that the virtual node provides data services instead of the failed data node.

[0142] Alternatively, implement the operation method of the time series database cluster provided in the foregoing method embodiment, including:

[0143] When a data operation request is received, determine the target data node to be operated on from the time series database cluster;

[0144] Obtain the hostname of the target data node from the metadata;

[0145] Determine the target IP address corresponding to the obtained hostname from the hostname mapping file;

[0146] Based on the target IP address, perform a data operation corresponding to the data operation request on the target time series data to be operated on the target data node.

[0147] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the fault handling method of the time series database cluster or the operation method of the time series database cluster provided in any one of the foregoing method embodiments.

[0148] It should be noted that in this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.

[0149] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can 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 these embodiments shown herein, but rather will conform to the broadest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for fault handling of a time series database cluster, characterized in that, The time series database cluster includes: at least one metadata node and multiple data nodes; the data nodes are used to store time series data, and the multiple data nodes are replicas of each other; the metadata node is used to store the metadata of the time series database cluster, and the metadata at least includes the host name of each data node; the method includes: When it is detected that any one of the data nodes fails, create virtual nodes, where the number of newly created virtual nodes is greater than or equal to the number of failed data nodes; Copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node, where the newly created virtual node uses the host name of the original data node; In the host name mapping file of the time series database cluster, update the IP address in the target mapping relationship to the IP address of the virtual node, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node; Restart the time series database cluster so that the virtual node replaces the failed data node to provide data services.

2. The method according to claim 1, wherein The time series database cluster further includes a liveness detection component, and the liveness detection component is used to periodically send liveness detection messages to each data node; The detection that any one of the data nodes fails includes: For each data node, if an acknowledgment message returned by the data node based on the liveness detection message is not received within the current timeout period, it is determined that the data node has failed. The current timeout period refers to: a time period starting from the time when the liveness detection component last sent the liveness detection message and with a set duration; or, For each data node, if a heartbeat message sent by the data node is not received when the set period arrives, it is determined that the data node has failed.

3. A method for operating a time series database cluster, characterized in that, Applied to the time series database cluster according to any one of claims 1 to 2, the method includes: When a data operation request is received, determine the target data node to be operated on from the time series database cluster; Obtain the host name of the target data node from the metadata; Determine the target IP address corresponding to the obtained host name from the host name mapping file; Based on the target IP address, perform a data operation corresponding to the data operation request on the target time series data to be operated on the target data node.

4. The method according to claim 3, characterized in that, The determination of the target data node to be operated on from the time series database cluster includes: Based on the timestamp of the target time series data, determine the target shardgroup to which the target time series data belongs, where the timestamp is within the time range composed of the start time and the end time of the target shardgroup; Determine all shards included in the target shardgroup; Determine the data node bound to the shard as the data node to be operated on.

5. A time series database cluster, characterized in that, The time series database cluster at least includes: at least one metadata node, multiple data nodes, a liveness detection component, and a virtual node creation component; The data node is used to store time-series data, and multiple said data nodes are replicas of each other; The metadata node is used to store the metadata of the time-series database cluster, and the metadata at least includes the host name of each said data node; The liveness detection component is used to detect the status of the data node, and the status includes normal and faulty; The virtual node creation component is used to create new virtual nodes when the liveness detection component detects that any one of the data nodes fails. The number of newly created virtual nodes is greater than or equal to the number of failed data nodes; copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node. The newly created virtual node uses the original host name of the data node; in the host name mapping file of the time-series database cluster, update the IP address in the target mapping relationship to the IP address of the virtual node, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node; and restart the time-series database cluster so that the virtual node replaces the failed data node to provide data services.

6. The cluster according to claim 5, wherein The data disk is a cloud disk.

7. A fault handling device for a time series database cluster, characterized in that The time-series database cluster includes: at least one metadata node and multiple data nodes; the data nodes are used to store time-series data, and multiple said data nodes are replicas of each other; the metadata node is used to store the metadata of the time-series database cluster, and the metadata at least includes the host name of each said data node; the device includes: The node creation module is used to create new virtual nodes when it detects that any one of the data nodes fails. The number of newly created virtual nodes is greater than or equal to the number of failed data nodes; The node configuration module is used to copy the configuration file of the failed data node to the virtual node, and mount the data disk of the failed data node to the virtual node. The newly created virtual node uses the original host name of the data node; The mapping module is used to update the IP address in the target mapping relationship to the IP address of the virtual node in the host name mapping file of the time-series database cluster, where the target mapping relationship refers to the mapping relationship corresponding to the failed data node; The restart module is used to restart the time-series database cluster so that the virtual node replaces the failed data node to provide data services.

8. An operating device for a time series database cluster, characterized in that Applied to the time-series database cluster according to any one of claims 5 to 6, the device includes: The target determination module is used to determine the target data node to be operated from the time-series database cluster when receiving a data operation request; The first acquisition module is used to acquire the host name of the target data node from the metadata; The second acquisition module is used to determine the target IP address corresponding to the acquired host name from the host name mapping file; A data operation module, configured to perform a data operation corresponding to the data operation request on target time-series data to be operated on the target data node based on the target IP address.

9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store computer programs; The processor is configured to implement the steps of the method according to any one of claims 1-4 when executing the program stored on the memory.

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

Citation Information

Patent Citations

  • Distributed file system data volume deployment method based on virtual address pool

    CN103475732A

  • High availability method and system for NAS cluster as well as electronic equipment and storage medium

    CN108923992A