Distributed time series database expansion method and system
By introducing new nodes in a distributed timing database, the expansion of capacity initialization, metadata, and timing data expansion have been performed, and the problem of distributed timing database expansion has been solved, and the storage capacity and computing power are improved. Essence
Patent Information
- Application Number
- CN202410721148.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-06-05
AI Technical Summary
Without changing the storage of existing nodes, how to achieve the expansion of distributed timing databases to cope with the pressure of data capacity and computing power brought about by business expansion.
The new node is used as an existing cluster as an expansion node to perform the initialization of capacity expansion, and the timing data that needs to be expanded is obtained to perform metadata expansion and timing data expansion, including character switching and copy migration to increase the storage capacity and computing power of the cluster.
Realize the expansion of the storage capacity of the cluster, increase the computing power, support more complicated data analysis and processing, and improve the capacity and performance of the system.
Smart Images

Figure CN118626559B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of distributed databases, and in particular to a capacity expansion method and system for a distributed time series database. Background Art
[0002] Time series data is a series of data based on time, and a time series database is a database that stores time series data, supporting fast data writing, persistence, multi-dimensional aggregation query, etc.
[0003] In the Internet scenario, a large amount of time series data will be generated. For example, Baidu's unmanned vehicle data collection has a data volume of nearly 8T per day. In order to be able to store, analyze and aggregate query a large amount of time series data, today's time series database is a good choice.
[0004] Distributed time series databases use a distributed architecture, are specifically used to process and store time series data, and have the characteristics of a distributed architecture. Generally speaking, time series data is stored in the form of multiple copies, that is, each copy of time series data is backed up on multiple nodes in the cluster, which can distribute the query and storage load to each node, improving the read and write performance, stability, and fault tolerance of the entire database.
[0005] When deploying a time series database, the capacity of the platform is often planned and evaluated to meet the characteristics of large data volumes in today's scenarios. However, as the business expands, the system's data capacity and computing power will be under great pressure, so it is necessary to increase the data capacity and computing power of the existing system.
[0006] In order to increase the data capacity and computing power of the entire database cluster, how to achieve distributed database expansion without changing the storage of existing nodes is a technical problem that needs to be solved. Summary of the invention
[0007] The technical task of the present invention is to address the above shortcomings and provide a method and system for expanding the capacity of a distributed time series database to solve the technical problem of how to expand the capacity of a distributed database without changing the storage of existing nodes.
[0008] The present invention provides a method for expanding the capacity of a distributed time series database, comprising the following steps:
[0009] Initialization startup of expansion: The new node is added to the existing cluster as an expansion node through the startup command, and it is determined whether the expansion node is initialized for the first time. If so, the time series data that needs to be expanded in the cluster is obtained, and the node is expanded according to the expansion rules. The node expansion follows serial execution;
[0010] Metadata expansion: For time series data that needs to be expanded, obtain the master node corresponding to the time series data, obtain the metadata stored in the master node and return it to the expansion node, and create the metadata of the expansion node based on the returned metadata;
[0011] Time series data expansion: For the time series data copies that need to be migrated, add time series data copies in the current expansion node. If the time series data copy that needs to be migrated is the primary copy, switch the role of the time series data copy and remove the redundant time series data copies to restore the original number of time series data copies in the cluster.
[0012] Preferably, the expansion initialization startup includes the following steps:
[0013] The new node is added to the existing cluster as an expansion node through the startup command;
[0014] Determine whether the expansion node is initialized and started for the first time. If not, the expansion node is started normally without node expansion. If yes, proceed to the next step.
[0015] Obtain the time series data that needs to be expanded in the cluster, and determine whether there is time series data that needs to be expanded. If so, according to the expansion rules, the expanded node starts normally without node expansion. If not, proceed to the next step;
[0016] Determine whether there is a node in the current cluster that is undergoing node expansion. If yes, wait for a predetermined time and then determine whether there is a node in the current cluster that is undergoing node expansion. If no, expand the node according to the expansion rule.
[0017] Preferably, metadata expansion includes the following steps:
[0018] For time series data that needs to be expanded, obtain the master node where the time series data copy is located;
[0019] Send a request through RPC to obtain the metadata stored in the remote node, and return the obtained metadata to the expansion node;
[0020] The obtained metadata is created in the storage of the expansion node.
[0021] Preferably, the time series data expansion includes the following steps:
[0022] Based on the data distribution and node storage pressure in the current cluster, calculate the time series data copies that need to be migrated and obtain the calculation results;
[0023] According to the calculation results, add a copy of the time series data that needs to be migrated to the current expansion node. When adding a copy of the time series data, back up a new copy from the master copy of the time series data;
[0024] For the time series data copy that needs to be migrated, determine whether the time series data copy migrated to the current expansion node is the primary copy. If so, switch the role of the time series data copy, switch the time series data copy in the original node to the backup copy, and convert the time series data copy in the expansion node to the primary copy;
[0025] After the role switch is completed, the time series data replicas are removed from the original nodes to restore the original number of time series data replicas in the cluster.
[0026] In a second aspect, the present invention provides a capacity expansion system for a distributed time series database, including a capacity expansion initialization startup module, a metadata capacity expansion module, and a time series data capacity expansion module;
[0027] The expansion initialization startup module is used to perform the following: the new node is added to the existing cluster as an expansion node through the startup command, and it is determined whether the expansion node is initialized and started for the first time. If so, the time series data that needs to be expanded in the cluster is obtained, and the node is expanded according to the expansion rules. The node expansion follows serial execution;
[0028] The metadata expansion module is used to perform the following: for the time series data that needs to be expanded, obtain the master node corresponding to the time series data, obtain the metadata stored in the master node and return it to the expansion node, and create the metadata of the expansion node based on the returned metadata;
[0029] The time series data expansion module is used to perform the following: for the time series data copies that need to be migrated, add time series data copies in the current expansion node; if the time series data copy that needs to be migrated is the primary copy, switch the role of the time series data copy, and remove the redundant time series data copies to restore the original number of time series data copies in the cluster.
[0030] Preferably, the expansion initialization startup module is used to perform the following operations:
[0031] The new node is added to the existing cluster as an expansion node through the startup command;
[0032] Determine whether the expansion node is initialized and started for the first time. If not, the expansion node is started normally without node expansion. If yes, proceed to the next step.
[0033] Obtain the time series data that needs to be expanded in the cluster, and determine whether there is time series data that needs to be expanded. If so, according to the expansion rules, the expanded node starts normally without node expansion. If not, proceed to the next step;
[0034] Determine whether there is a node in the current cluster that is undergoing node expansion. If yes, wait for a predetermined time and then determine whether there is a node in the current cluster that is undergoing node expansion. If no, expand the node according to the expansion rule.
[0035] Preferably, the metadata expansion module is used to perform the following:
[0036] For time series data that needs to be expanded, obtain the master node where the time series data copy is located;
[0037] Send a request through RPC to obtain the metadata stored in the remote node, and return the obtained metadata to the expansion node;
[0038] The obtained metadata is created in the storage of the expansion node.
[0039] Preferably, the time series data expansion module is used to perform the following:
[0040] Based on the data distribution and node storage pressure in the current cluster, calculate the time series data copies that need to be migrated and obtain the calculation results;
[0041] According to the calculation results, add a copy of the time series data that needs to be migrated to the current expansion node. When adding a copy of the time series data, back up a new copy from the master copy of the time series data;
[0042] For the time series data copy that needs to be migrated, determine whether the time series data copy migrated to the current expansion node is the primary copy. If so, switch the role of the time series data copy, switch the time series data copy in the original node to the backup copy, and convert the time series data copy in the expansion node to the primary copy;
[0043] After the role switch is completed, the time series data replicas are removed from the original nodes to restore the original number of time series data replicas in the cluster.
[0044] The distributed time series database expansion method and system of the present invention have the following advantages:
[0045] 1. The storage capacity of the cluster is expanded, providing more space for complex data analysis and improving system capacity;
[0046] 2. With the participation of more nodes, computing power and other performance will also be improved, thus improving system performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0048] The present invention is further described below in conjunction with the accompanying drawings.
[0049] Figure 1 This is a flowchart of a method for expanding the capacity of a distributed time series database in Example 1;
[0050] Figure 2 This is a flowchart of capacity expansion initialization startup in a capacity expansion method for a distributed time series database in Example 1;
[0051] Figure 3 This is a flowchart of metadata expansion in a distributed time series database expansion method in Example 1;
[0052] Figure 4 This is a flow chart of expanding the capacity of time series data in a method for expanding the capacity of a distributed time series database in Example 1;
[0053] Figure 5 This is a schematic diagram of adding a replica in a method for expanding capacity of a distributed time series database in Example 1;
[0054] Figure 6 This is a schematic diagram of the role switching of the primary and backup copies in a method for expanding the capacity of a distributed time series database in Example 1;
[0055] Figure 7 This is a schematic diagram of removing replicas in a method for expanding capacity of a distributed time series database in Example 1. DETAILED DESCRIPTION
[0056] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
[0057] The embodiments of the present invention provide a distributed time series database expansion method and system, which are used to solve the technical problem of how to achieve distributed database expansion without changing the storage of existing nodes.
[0058] Embodiment 1:
[0059] The present invention discloses a method for expanding a distributed time series database, comprising three steps of expansion initialization startup, metadata expansion, and time series data expansion.
[0060] Step S100: Initialization startup of expansion: the new node is added to the existing cluster as an expansion node through a startup command, and it is determined whether the expansion node is initialized for the first time. If so, the time series data that needs to be expanded in the cluster is obtained, and the node is expanded according to the expansion rules. The node expansion follows serial execution.
[0061] As a specific implementation of the expansion initialization startup, this step includes the following operations:
[0062] (1) The new node is added to the existing cluster as an expansion node through the startup command;
[0063] (2) determining whether the expansion node is initialized and started for the first time; if not, the expansion node is started normally without node expansion; if yes, executing the next step;
[0064] (3) Obtain the time series data that needs to be expanded in the cluster, and determine whether the time series data that needs to be expanded is empty. If so, according to the expansion rules, the expanded node starts normally without the need to expand the node. If not, proceed to the next step;
[0065] (4) Determine whether there is a node in the current cluster that is undergoing node expansion. If so, wait for a predetermined time and then determine whether there is a node in the current cluster that is undergoing node expansion. If not, expand the node according to the expansion rule.
[0066] As Figure 2 As shown in the figure, when the expansion is initially started, the node joins the existing cluster through the startup command. Expansion is required when and only when the node is initialized for the first time. When the node is restarted, normal startup does not require expansion. Second, obtain the time series data that needs to be expanded in the cluster. According to the specific expansion rules, if the obtained time series data that needs to be expanded is empty, normal startup does not require expansion. Third, concurrent control of expanding multiple nodes at the same time, judge whether there are nodes in the current cluster that are being expanded, so as to control the serial execution of the expanded nodes.
[0067] Step S200 Metadata expansion: For the time series data that needs to be expanded, the master node corresponding to the time series data is obtained, and the metadata stored in the master node is obtained and returned to the expansion node, and the metadata of the expansion node is created based on the returned metadata.
[0068] As a specific implementation of metadata expansion, this step includes the following operations:
[0069] (1) For time series data that needs to be expanded, obtain the master node where the time series data copy is located;
[0070] (2) Send a request through RPC to obtain the metadata stored in the remote node, and return the obtained metadata to the expansion node;
[0071] (3) The obtained metadata is created in the storage of the expansion node.
[0072] like Figure 3As shown in the figure, in a distributed database, data is often stored in a high-availability storage method with multiple copies. Therefore, first, the master node where the time series data copy is located is obtained; secondly, a request is sent through the RPC method to obtain the metadata in the remote node storage and return it to the expansion node; finally, the obtained metadata is used to create the storage in the expansion node.
[0073] Step S300: Time series data expansion: For the time series data copies that need to be migrated, add time series data copies in the current expansion node. If the time series data copy that needs to be migrated is the primary copy, switch the role of the time series data copy and remove the redundant time series data copies to restore the original number of time series data copies in the cluster.
[0074] As a specific implementation of time series data expansion, this step includes the following operations:
[0075] (1) Based on the data distribution and node storage pressure in the current cluster, calculate the time series data copies that need to be migrated and obtain the calculation results;
[0076] (2) Based on the calculation results, add a copy of the time series data that needs to be migrated to the current expansion node. When adding a copy of the time series data, back up a new copy from the master copy of the time series data;
[0077] (3) For the time series data copy that needs to be migrated, determine whether the time series data copy migrated to the current expansion node is the primary copy. If so, switch the role of the time series data copy, switch the time series data copy in the original node to the backup copy, and convert the time series data copy in the expansion node to the primary copy;
[0078] (4) After the role switch is completed, the time series data copies are removed from the original nodes to restore the original number of time series data copies in the cluster.
[0079] For the storage of time series data, a multi-copy storage method is used in the distributed database, that is, each copy is distributed on different nodes. At the same time, each copy is divided into a primary copy and a backup copy. The primary copy is the object of writing and querying operations, and the backup copy is a backup of the primary copy data. When expanding capacity, in order to solve the storage and computing pressure of nodes in the existing cluster, data can be migrated to some nodes with high pressure to achieve the purpose of expansion. Figure 4 As shown in the flowchart, first, according to the data distribution in the current cluster, node storage pressure and other indicators, the time series data replicas that need to be migrated are calculated; second, according to the calculation results, the calculated replicas that need to be migrated are first added to the current expansion node ( Figure 5When adding a replica, a new replica is backed up from all primary replicas. Since adding a replica is an asynchronous operation, after adding a replica, you need to wait for the addition of the time series data replica to be completed; thirdly, if the replica to be migrated to the current node is the primary replica, a role switch of the time series data replica is required ( Figure 6 Finally, after the replica switch is completed, the number of replicas of the original time series data in the cluster needs to be restored and the redundant replicas need to be removed ( Figure 7 Remove the replica) to complete the expansion of distributed time series data.
[0080] Embodiment 2:
[0081] The present invention discloses a capacity expansion system for a distributed time series database, comprising a capacity expansion initialization startup module, a metadata capacity expansion module and a time series data capacity expansion module.
[0082] The expansion initialization startup module is used to perform the following: the new node joins the existing cluster as an expansion node through a startup command, determines whether the expansion node is initialized for the first time, and if so, obtains the time series data that needs to be expanded in the cluster, and expands the node according to the expansion rules. The node expansion follows serial execution.
[0083] As a specific implementation of the expansion initialization startup module, this module is used to perform the following operations:
[0084] (1) The new node is added to the existing cluster as an expansion node through the startup command;
[0085] (2) determining whether the expansion node is initialized and started for the first time; if not, the expansion node is started normally without node expansion; if yes, executing the next step;
[0086] (3) Obtain the time series data that needs to be expanded in the cluster, and determine whether the time series data that needs to be expanded is empty. If so, according to the expansion rules, the expanded node starts normally without the need to expand the node. If not, proceed to the next step;
[0087] (4) Determine whether there is a node in the current cluster that is undergoing node expansion. If so, wait for a predetermined time and then determine whether there is a node in the current cluster that is undergoing node expansion. If not, expand the node according to the expansion rule.
[0088] The metadata expansion module is used to perform the following: for the time series data that needs to be expanded, obtain the master node corresponding to the time series data, obtain the metadata stored in the master node and return it to the expansion node, and create the metadata of the expansion node based on the returned metadata.
[0089] As a specific implementation of the metadata expansion module, this module is used to perform the following operations:
[0090] (1) For time series data that needs to be expanded, obtain the master node where the time series data copy is located;
[0091] (2) Send a request through RPC to obtain the metadata stored in the remote node, and return the obtained metadata to the expansion node;
[0092] (3) The obtained metadata is created in the storage of the expansion node.
[0093] The time series data expansion module is used to perform the following: For the time series data copies that need to be migrated, add the time series data copies in the current expansion node. If the time series data copy that needs to be migrated is the primary copy, switch the role of the time series data copy and remove the redundant time series data copies to restore the original number of time series data copies in the cluster.
[0094] As a specific implementation of the time series data expansion module, this module is used to perform the following operations:
[0095] (1) Based on the data distribution and node storage pressure in the current cluster, calculate the time series data copies that need to be migrated and obtain the calculation results;
[0096] (2) Based on the calculation results, add a copy of the time series data that needs to be migrated to the current expansion node. When adding a copy of the time series data, back up a new copy from the master copy of the time series data;
[0097] (3) For the time series data copy that needs to be migrated, determine whether the time series data copy migrated to the current expansion node is the primary copy. If so, switch the role of the time series data copy, switch the time series data copy in the original node to the backup copy, and convert the time series data copy in the expansion node to the primary copy;
[0098] (4) After the role switch is completed, the time series data copies are removed from the original nodes to restore the original number of time series data copies in the cluster.
[0099] The present invention has been shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the means in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. A method for expanding the capacity of a distributed time series database, characterized in that: The steps include: Initialization startup of expansion: The new node is added to the existing cluster as an expansion node through the startup command, and it is determined whether the expansion node is initialized for the first time. If so, the time series data that needs to be expanded in the cluster is obtained, and the node is expanded according to the expansion rules. The node expansion follows serial execution; Metadata expansion: For time series data that needs to be expanded, obtain the master node corresponding to the time series data, obtain the metadata stored in the master node and return it to the expansion node, and create the metadata of the expansion node based on the returned metadata; Time series data expansion: Based on the data distribution and node storage pressure in the current cluster, calculate the time series data copies that need to be migrated and obtain the calculation results; According to the calculation results, add a copy of the time series data that needs to be migrated to the current expansion node. When adding a copy of the time series data, back up a new copy from the master copy of the time series data; For the time series data copy that needs to be migrated, determine whether the time series data copy migrated to the current expanded node is the primary copy. If so, switch the role of the time series data copy, switch the time series data copy in the original node to the backup copy, and convert the time series data copy in the expanded node to the primary copy; after the role switch is completed, remove the time series data copy from the original node to restore the original number of time series data copies in the cluster.
2. The method for expanding the capacity of a distributed time series database according to claim 1, characterized in that: The expansion initialization starts, including the following steps: The new node is added to the existing cluster as an expansion node through the startup command; Determine whether the expansion node is initialized and started for the first time. If not, the expansion node is started normally without node expansion. If yes, proceed to the next step. Obtain the time series data that needs to be expanded in the cluster, and determine whether there is time series data that needs to be expanded. If so, according to the expansion rules, the expanded node starts normally without node expansion. If not, proceed to the next step; Determine whether there is a node in the current cluster that is undergoing node expansion. If yes, wait for a predetermined time and then determine whether there is a node in the current cluster that is undergoing node expansion. If no, expand the node according to the expansion rule.
3. The method for expanding the capacity of a distributed time series database according to claim 1, characterized in that: Metadata expansion includes the following steps: For time series data that needs to be expanded, obtain the master node where the time series data copy is located; Send a request through RPC to obtain the metadata stored in the remote node, and return the obtained metadata to the expansion node; The obtained metadata is created in the storage of the expansion node.
4. A distributed time series database expansion system, characterized in that: It includes expansion initialization startup module, metadata expansion module and time series data expansion module; The expansion initialization startup module is used to perform the following: the new node is added to the existing cluster as an expansion node through the startup command, and it is determined whether the expansion node is initialized and started for the first time. If so, the time series data that needs to be expanded in the cluster is obtained, and the node is expanded according to the expansion rules. The node expansion follows serial execution; The metadata expansion module is used to perform the following: for the time series data that needs to be expanded, obtain the master node corresponding to the time series data, obtain the metadata stored in the master node and return it to the expansion node, and create the metadata of the expansion node based on the returned metadata; The time series data expansion module is used to perform the following: based on the data distribution and node storage pressure in the current cluster, calculate the time series data copies that need to be migrated and obtain the calculation results; based on the calculation results, add the time series data copies that need to be migrated to the current expansion node, and when adding the time series data copies, back up a new copy from the time series data master copy; For the time series data copy that needs to be migrated, determine whether the time series data copy migrated to the current expanded node is the primary copy. If so, switch the role of the time series data copy, switch the time series data copy in the original node to the backup copy, and convert the time series data copy in the expanded node to the primary copy; after the role switch is completed, remove the time series data copy from the original node to restore the original number of time series data copies in the cluster.
5. The capacity expansion system for a distributed time series database according to claim 4, characterized in that: The expansion initialization startup module is used to perform the following operations: The new node is added to the existing cluster as an expansion node through the startup command; Determine whether the expansion node is initialized and started for the first time. If not, the expansion node is started normally without node expansion. If yes, proceed to the next step. Obtain the time series data that needs to be expanded in the cluster, and determine whether there is time series data that needs to be expanded. If so, according to the expansion rules, the expanded node starts normally without node expansion. If not, proceed to the next step; Determine whether there is a node in the current cluster that is undergoing node expansion. If yes, wait for a predetermined time and then determine whether there is a node in the current cluster that is undergoing node expansion. If no, expand the node according to the expansion rule.
6. The capacity expansion system for a distributed time series database according to claim 4, characterized in that: The metadata expansion module is used to perform the following: For time series data that needs to be expanded, obtain the master node where the time series data copy is located; Send a request through RPC to obtain the metadata stored in the remote node, and return the obtained metadata to the expansion node; The obtained metadata is created in the storage of the expansion node.
Citation Information
Patent Citations
Distributed database rapid capacity expansion device
CN111061737A
Database construction method and device applied to distributed scheduling system
CN114003580A