Time series data storage method, device and equipment, medium and computer program product

By predetermining the pre-split row key position and row key range of the data partition in the time series database, the problem of disk data input and output storms caused by data partition splitting is solved, transparent data partition splitting and cluster expansion are realized, and query performance and User experience on the business side.

CN118732955AActive Publication Date: 2024-10-01INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411206014.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-10-01
Estimated Expiration
2044-08-30

AI Technical Summary

Technical Problem

The disk data input and output storm problem caused by the splitting of data partitions in the time series database leads to blocked read and write request responses and reduced query performance.

Method used

By predetermining the pre-split row key position in the data partition, the current read and write row key range is divided, and when the data partition is split, the sub-data partition including the row key range is retained in the original storage node, and the migration does not include the row key range. The sub-data is partitioned to other storage nodes to avoid time series data relocation.

Benefits of technology

It achieves transparent data partition splitting and cluster expansion, avoids disk data input and output storms and read and write request response blocking, and improves query performance and business-side user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118732955A_ABST
    Figure CN118732955A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of storage, and particularly discloses a time sequence data storage method, device and equipment, a medium and a computer program product. For a data partition of a target database, a pre-split row key position is determined in advance according to a row key range, and a current read-write row key range is determined in the data partition by taking the pre-split row key position as a boundary; distributing row keys in the current read-write row key range when to-be-written time sequence data is written; when the data partition is split, the sub-data partitions including the current read-write row key range are reserved in the original storage node, and the sub-data partitions migrated to other storage nodes are determined in the row key range not including the current read-write row key range; therefore, only migration of the metadata is brought by splitting of the data partitions, but migration of the time series data is not included, and therefore disk data input and output storm and response blocking to read-write requests caused by migration of a large amount of time series data are avoided. And the situation that the query performance of the time series data under the storage nodes is reduced due to the low localization rate of the storage nodes is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of storage technology, and in particular to a method, device, equipment, medium and computer program product for storing time series data. Background Art

[0002] Time series data is a type of data recorded in chronological order. It is usually used to analyze and predict trends and patterns that change over time and has a wide range of applications in many fields. HBase is a distributed database that stores data in columns and manages metadata in the form of data partitions (Regions). Each data partition contains a certain range of row keys (Row Key). When storing time series data, HBase can evenly write massive time series data to different data partitions of different storage nodes through special row key design and tables. In HBase, when the time series data under a data partition reaches the capacity limit or when the cluster is expanded, the data partition will be split, such as splitting a data partition into two sub-data partitions. At the same time, based on the load balancing properties of HBase, the two split sub-data partitions will be distributed to different storage nodes. This process includes migrating the metadata of the sub-data partitions to the new storage nodes. In order to ensure the localization rate (that is, the node where the data partition is located and the time series data it manages should eventually be distributed on the same storage node), the time series data corresponding to the sub-data partition also needs to be migrated, which results in a large amount of disk data input and output (I / O), resulting in blocked responses to read and write requests. Before the localization rate of the new storage node reaches 100%, the query performance of the time series data under it will also be severely reduced.

[0003] How to solve the disk data input and output storm problem caused by data migration due to data partition splitting in a time series database is a technical problem that technical personnel in this field need to solve. Summary of the invention

[0004] The purpose of the present invention is to provide a time series data storage method, device, equipment, medium and computer program product for solving the disk data input and output storm problem caused by data migration due to data partition splitting in a time series database.

[0005] In order to solve the above technical problems, the present invention provides a time series data storage method, comprising: Obtaining a row key range corresponding to each data partition of the target database, and determining a pre-split row key position of the data partition within the row key range of the data partition; Determine the current read / write row key range in the data partition based on the pre-split row key position; When writing the time series data to be written into the data partition, a row key is allocated to the time series data to be written within the current read-write row key range; When the data partition splitting conditions are met, the data partition to be split is split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition to be migrated to other storage nodes is determined within the row key range that does not include the current read-write row key range.

[0006] On the one hand, determining a pre-split row key position of the data partition within a row key range of the data partition includes: Determine an upper limit on the number of the sub-data partitions that the data partition can be split into according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition; Determine the number of the sub-data partitions for actual pre-splitting of the data partition within a range not exceeding an upper limit of the number of the sub-data partitions; The pre-split row key position is determined within the row key range of the data partition according to the row key range of the data partition and the number of the sub-data partitions actually pre-split of the data partition.

[0007] On the other hand, according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition, determining the upper limit of the number of the sub-data partitions that the data partition can be split into includes: Determine the number of optional values ​​corresponding to the timing split flag bit according to the data size of the timing split flag bit configured in the row key of the data partition; The number of optional numerical values ​​corresponding to the timing split flag is the upper limit of the number of sub-data partitions that the data partition can be split into.

[0008] On the other hand, determining a pre-split row key position of the data partition within a row key range of the data partition includes: Determine the number of the sub-data partitions of the actual pre-splitting of the data partition within a range that is not less than the preset number of data partitions corresponding to the target database; The pre-split row key position is determined within the row key range of the data partition according to the row key range of the data partition and the number of the sub-data partitions actually pre-split of the data partition.

[0009] On the other hand, determining a pre-split row key position of the data partition within a row key range of the data partition includes: Determine an upper limit on the number of the sub-data partitions that the data partition can be split into according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition; Determine the number of the sub-data partitions of the actual pre-splitting of the data partition within a range that does not exceed the upper limit of the number of the sub-data partitions and is not less than the preset number of data partitions corresponding to the target database; The pre-split row key position is determined within the row key range of the data partition according to the row key range of the data partition and the number of the sub-data partitions actually pre-split of the data partition.

[0010] On the other hand, determining the current read / write row key range in the data partition with the pre-split row key position as the boundary includes: The row key range before the first pre-split row key position of the data partition is taken as the current read-write row key range.

[0011] On the other hand, determining the sub-data partition to be migrated to another storage node in a row key range that does not include the current read-write row key range includes: The row key ranges that do not include the current read-write row key range are all used as the sub-data partitions migrated to other storage nodes.

[0012] On the other hand, when writing the time series data to be written into the data partition, allocating a row key for the time series data to be written in the current read-write row key range includes: When writing the time series data to be written into the data partition, the current read-write row key range of the data partition is determined according to a mapping relationship table recording the correspondence between the data partition in the target database and the current read-write row key range, and a row key is allocated to the time series data to be written within the current read-write row key range.

[0013] On the other hand, the mapping relationship table includes a mapping relationship between a row key range written into each time series data in the data partition and a time series split flag bit; The time series data write row key range is the interval into which the data partition is divided according to the pre-split row key position, and the current read-write row key range is one of the time series data write row key ranges; the time series split flag is a newly added flag of the row key managed by the data partition, and the time series split flag of the row key in the data partition uniquely corresponds to the time series data write row key range in which it is located.

[0014] On the other hand, according to a mapping relationship table recording the corresponding relationship between the data partition and the current read / write row key range in the target database, determining the current read / write row key range of the data partition, and allocating a row key to the time series data to be written in the current read / write row key range, including: Query the current read / write row key range corresponding to the data partition and the timing split flag corresponding to the current read / write row key range according to the mapping relationship table; A row key is allocated to the time series data to be written in the current read-write row key range, and the time series split flag obtained by query is written into the allocated row key, so as to allocate a row key to the time series data to be written in the current read-write row key range.

[0015] On the other hand, when writing the time series data to be written into the data partition, allocating a row key for the time series data to be written in the current read-write row key range includes: When receiving the data writing task corresponding to the time series data to be written, calculating and obtaining the salt value corresponding to the time series data to be written; Determine that the data partition corresponding to the salt value is the target data partition for writing the time series data; A row key is allocated to the time series data to be written in the current read-write row key range of the target data partition, and the salt value is added before the allocated row key.

[0016] On the other hand, allocating a row key for the time series data to be written in the current read-write row key range includes: An unassigned row key is randomly selected in the current read-write row key range as the row key of the time series data to be written.

[0017] On the other hand, when writing the time series data to be written into the data partition, allocating a row key for the time series data to be written in the current read-write row key range includes: When receiving the data writing task corresponding to the time series data to be written, calculating and obtaining the salt value corresponding to the time series data to be written; Determine that the data partition corresponding to the salt value is the target data partition for writing the time series data; An unassigned row key is randomly selected in the current read-write row key range of the target data partition as the row key of the time series data to be written, and the salt value is added before the assigned row key.

[0018] On the other hand, calculating and obtaining the salt value corresponding to the time series data to be written includes: Calculate a hash code according to an array consisting of the indicator name of the time series data to be written and the tag key value of the time series data to be written; The hash code is modulo-calculated by the number of buckets corresponding to the target database to obtain the salt value corresponding to the time series data to be written.

[0019] On the other hand, the step of determining the number of buckets corresponding to the target database includes: The number of buckets is determined according to the load status of the cluster where the target database is located and the number of data partition service nodes in the cluster where the target database is located.

[0020] On the other hand, the data partition splitting condition includes at least one of: the amount of time series data corresponding to the data partition reaches the maximum data capacity corresponding to the data partition, and the cluster expansion of the target database triggers the data partition splitting.

[0021] In order to solve the above technical problems, the present invention further provides a time series data storage device, comprising: A data partition splitting and balancing module is used to obtain the row key range corresponding to each data partition of the target database, determine the pre-split row key position of the data partition within the row key range of the data partition; determine the current read-write row key range in the data partition with the pre-split row key position as the boundary; when the data partition splitting condition is met, split the data partition to be split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition to be migrated to other storage nodes is determined in the row key range that does not include the current read-write row key range; A mapping management module, used to manage a mapping relationship table recording the corresponding relationship between the data partition and the current read / write row key range; The read-write conversion module is used to query the mapping relationship table through the mapping management module to determine the current read-write row key range of the data partition when writing the time series data to be written into the data partition, and allocate a row key to the time series data to be written within the current read-write row key range.

[0022] In order to solve the above technical problems, the present invention further provides a time series data storage device, comprising: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the time series data storage method as described in any one of the above items are implemented.

[0023] In order to solve the above technical problems, the present invention also provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the time series data storage method as described in any one of the above items are implemented.

[0024] In order to solve the above technical problems, the present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the time series data storage method as described in any one of the above items.

[0025] The time series data storage method provided by the present invention has the beneficial effect of determining the pre-splitting row key position of the data partition of the target database in advance according to the row key range, and determining the current read-write row key range in the data partition with the pre-splitting row key position as the boundary, so that when the time series data to be written is written into the data partition, the row key is allocated to the time series data to be written in the current read-write row key range; and when the data partition splitting condition is met, the data partition to be split is split into multiple sub-data partitions according to the pre-splitting row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition not including the current read-write row key range is retained in the original storage node. The row key range determines the sub-data partitions that are migrated to other storage nodes, so that the sub-data partitions that need to be migrated to other storage nodes do not correspond to time series data, and will not cause the localization rate of other storage nodes to be migrated to decrease. Therefore, the splitting of data partitions only brings about the migration of metadata but not the migration of time series data. As a result, there will be no disk data input and output storms and response blockages to read and write requests caused by the migration of a large amount of time series data, and there will be no reduction in the query performance of the time series data under the storage node due to the low localization rate of the storage node. Transparent data partition splitting and cluster expansion are achieved, which improves the user experience on the business side.

[0026] The present invention also provides a time series data storage device, equipment, medium and computer program product, which have the above-mentioned beneficial effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, 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.

[0028] Figure 1 A flowchart of a time series data storage method provided by an embodiment of the present invention; Figure 2 A schematic diagram of data partition splitting provided by an embodiment of the present invention; Figure 3 An architectural diagram of a time series data storage device provided by an embodiment of the present invention; Figure 4 A schematic diagram of the structure of a time series data storage device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0029] The core of the present invention is to provide a time series data storage method, device, equipment, medium and computer program product for solving the disk data input and output storm problem caused by data migration due to data partition splitting in a time series database.

[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] HBase is a highly reliable, high-performance, column-oriented distributed storage system. The architecture of HBase includes components such as the master server (HMaster), the regional server (HRegionServer), and the coordination service (Zookeeper). HMaster is responsible for the management of data tables (Table) and data partitions (Region), HRegionServer is responsible for responding to user data input and output (I / O) requests, and Zookeeper is responsible for coordination services and failover mechanisms.

[0032] HBase is a column-oriented storage system. In HBase, a Table consists of rows and columns, and data is sorted by rows. Each row has a unique row key, which is the main way to access data.

[0033] In HBase, a data table has multiple data partitions, which are the basic units of data management. Data partitions are evenly distributed on all storage nodes in the cluster where the database is located to achieve load balancing of read and write requests. Each data partition maintains the start row key (startRowKey) and the end row key (endRowKey). If the row key of a piece of data is within the row key range maintained by a data partition, the data is managed and maintained by this data partition.

[0034] In the HBase cluster, a region server is usually deployed on each storage node, and each region server can manage one or more data partitions.

[0035] When storing time series data in HBase, it is stored continuously according to the actual time of the time series data. One implementation method is to format the actual time of the time series data as a timestamp in hours, that is, at which hour the time series data occurs. The specific time (offset) of the time series data within this hour is written as the column name. For example, the 1st second of this hour is the 1st column, and the 3600th second is the 3600th column. When the data time precision is milliseconds, it is from the 1st column to the 3600000th column. If only the continuous writing method is used, when there is a lot of time series data at a certain hour, the location where it is continuously stored will be accessed by a large number of reads and writes, causing overheating of a certain data partition. Therefore, in HBase, multiple data partitions are created in advance through pre-partitioning, and through a special row key design, the time series data is evenly distributed in different data partitions of different storage nodes on the basis of continuous storage in chronological order, and balanced distribution in different data partitions is achieved.

[0036] However, the data size supported by a single data partition has an upper limit (such as 10GB). As time series data is continuously written, the data in the data partition will inevitably split when the data reaches the upper limit. The single data partition will be split into two sub-data partitions, and then the two sub-data partitions will be distributed to storage nodes where different regional servers (RegionServers) are located according to the specified strategy, resulting in a decrease in the localization rate of the storage node to which the sub-data partition is migrated, and disk I / O storms caused by the relocation of underlying files between different storage nodes.

[0037] It should be noted that when the storage node where the data partition is located and the data it manages are distributed on the same storage node, it means that the locality rate of the data partition is 100%. The minimum unit of the locality rate indicator is the data partition, and the minimum value of the locality rate is 0 and the maximum value is 1.

[0038] In order to solve the disk I / O storm problem caused by data migration due to the splitting of data partitions in a time series database, an embodiment of the present invention provides a time series data storage solution, which divides the current read-write row key range in the data partition, and no longer uses the row key range corresponding to the entire data partition as the range for assigning row keys to the time series data, but only uses the current read-write row key range in the data partition as the range for assigning row keys to the time series data. When the data partition splitting condition is met, the sub-data partition including the current read-write row key range is retained in the original storage node where the data partition is located, and the sub-data partition migrated to other storage nodes is determined within the row key range that does not include the current read-write row key range. As a result, the splitting of the data partition will only trigger the migration of metadata, and will not trigger the migration of time series data. When the sub-data partition is just migrated to the new storage node, it will not cause the localization rate of the new storage node to decrease, and will not cause the problem of reduced query performance for querying time series data.

[0039] Based on the above architecture, the time series data storage method provided by the embodiment of the present invention is described below with reference to the accompanying drawings.

[0040] Figure 1 A flowchart of a time series data storage method provided by an embodiment of the present invention.

[0041] like Figure 1 As shown, the time series data storage method provided by the embodiment of the present invention includes: S101: Obtain a row key range corresponding to each data partition of the target database, and determine a pre-split row key position of the data partition within the row key range of the data partition; S102: Determine the current read / write row key range in the data partition with the pre-split row key position as the boundary; S103: when writing the time series data to be written into the data partition, assigning a row key to the time series data to be written in the current read-write row key range; S104: When the data partition splitting condition is met, the data partition to be split is split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partitions including the current read-write row key range are retained in the original storage node, and the sub-data partitions within the row key range that does not include the current read-write row key range are determined to be migrated to other storage nodes.

[0042] It should be noted that the type of the "target database" in each embodiment of the present invention is HBase, and the cluster on which it is based is a distributed storage system, including multiple storage nodes, each storage node is usually deployed with a region server (RegionServer), each region server is used to manage one or more data partitions (Region), and each data partition corresponds to a row key (Row Key).

[0043] The time series data storage method provided by the embodiment of the present invention can be applied to a management node in a distributed storage system, and can be implemented in software by modifying the management program of the target database.

[0044] When storing time series data in HBase, multiple data partitions are pre-deployed on multiple storage nodes to balance reads and writes, and the time series data is evenly distributed in different data partitions and different row key positions in the data partitions through row key design. As the time series data corresponding to the data partition reaches the upper capacity limit of the data partition, or the cluster capacity of the distributed storage system is expanded, the data partition is triggered to split, and the split process is automatically controlled by HBase. The time series data storage method provided in the embodiment of the present invention adds a mechanism for pre-determining the pre-split row key position of the data partition on the basis of the current HBase solution for storing time series data.

[0045] It should be noted that the pre-split row key position in the embodiment of the present invention is different from the current pre-splitting mechanism of HBase. The latter means that when a data table in HBase is just created, HBase will assign a data partition to the data table by default. However, this will cause all read and write requests to access the same data partition in a regional server, and the load balancing effect cannot be achieved. Other regional servers in the cluster may be in a relatively idle state. Therefore, through the pre-partitioning method, multiple data partitions are generated and configured when the data table is created.

[0046] Determining the pre-split row key position in the embodiment of the present invention is a further improvement on the current pre-partitioning mechanism of HBase, that is, it is considered in advance that data partitions may be split in the future due to the time series data capacity reaching the upper limit or the cluster expansion triggering data partition splitting, so it is determined from which row key position the data partition will be split when the data partition is split in the future. It can be understood that the current data partition has not been split.

[0047] On this basis, the row key range corresponding to the data partition is segmented according to the pre-split row key position, and one of them is selected as the current read-write row key range. That is, when the data partition has not been split, data is not read and written to the entire row key range corresponding to the data partition, but only to the current read-write row key range. Then, when the data partition splitting conditions are met, the sub-data partition including the current read-write row key range is retained in the original storage node where the data partition is located, and the sub-data partition that is migrated to other storage nodes is determined within the row key range that does not include the current read-write row key range. As a result, the splitting of the data partition will only trigger the migration of metadata, and will not trigger the relocation of time series data. When the sub-data partition is just migrated to the new storage node, it will not cause the localization rate of the new storage node to decrease, and will not cause the problem of reduced query performance for querying time series data.

[0048] In some optional implementations of the embodiments of the present invention, determining the current read-write row key range in the data partition with the pre-split row key position as the boundary in S102 may include: taking the row key range before the first pre-split row key position of the data partition as the current read-write row key range. That is, for each data partition, after the row keys are divided into multiple read-write row key ranges with the pre-split row key position as the boundary in ascending order, the first read-write row key range is taken as the current read-write row key range, and before the data partition is split, the reading and writing of the data partition are only for the current read-write row key range.

[0049] In some other optional implementations of the embodiments of the present invention, S102 determines the current read-write row key range in the data partition with the pre-split row key position as the boundary, and may also include: dividing the row key range of the data partition into multiple read-write row key ranges with the pre-split row key position as the boundary, and randomly selecting a read-write row key range as the current read-write row key range of the data partition.

[0050] For S103, when writing the time series data to be written into the data partition, assigning a row key to the time series data to be written in the current read-write row key range may include: when writing the time series data to be written into the data partition, according to a mapping relationship table recording the corresponding relationship between the data partition in the target database and the current read-write row key range, determining the current read-write row key range of the data partition, and assigning a row key to the time series data to be written in the current read-write row key range. As described in the above embodiment of the present invention, a mapping relationship table can be created and maintained to determine the actual accessible location, i.e., the current read-write row key range of each data partition, during the reading and writing process of the target database.

[0051] For S104, the data partition splitting condition includes at least one of: the amount of time series data corresponding to the data partition reaches the maximum data capacity corresponding to the data partition, and the cluster expansion of the target database triggers the data partition splitting. When the data partition splitting condition is met, the data partition to be split is split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partitions including the current read-write row key range are retained in the original storage node, and the sub-data partitions migrated to other storage nodes are determined in the row key range that does not include the current read-write row key range.

[0052] In some optional implementations of the embodiments of the present invention, determining the sub-data partitions to be migrated to other storage nodes in the row key range that does not include the current read-write row key range may include: taking the row key range that does not include the current read-write row key range as the sub-data partitions to be migrated to other storage nodes. That is, the sub-data partitions corresponding to the current read-write row key range are retained in the original storage node, and the row key range outside the current read-write row key range is divided into other sub-data partitions and migrated to other storage nodes.

[0053] When applying the time series data storage method provided by an embodiment of the present invention, if the data partition splitting condition is that the number of time series data corresponding to the data partition reaches the maximum data capacity corresponding to the data partition, then after the data partition splitting is completed, the sub-data partition retained in the original storage node is the time series data capacity that reaches the maximum data capacity, and no new data will be written, and only read data requests will be received.

[0054] When the data partition splitting condition is that the cluster expansion of the target database triggers the data partition splitting, after the data partition splitting is completed, if the sub-data partition retained in the original storage node does not reach the maximum data capacity corresponding to the original data partition, new time series data can continue to be written.

[0055] The time series data storage method provided by the embodiment of the present invention determines the pre-splitting row key position of the data partition of the target database according to the row key range in advance, and determines the current read-write row key range in the data partition with the pre-splitting row key position as the boundary, so that when the time series data to be written is written into the data partition, the row key is allocated to the time series data to be written in the current read-write row key range; and when the data partition splitting condition is met, the data partition to be split is split into multiple sub-data partitions according to the pre-splitting row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition including the row key range not including the current read-write row key range is retained in the original storage node. The scope determines the sub-data partitions to be migrated to other storage nodes, so that the sub-data partitions that need to be migrated to other storage nodes do not correspond to time series data, and will not cause the problem of reduced localization rate of other storage nodes to which they are migrated. Therefore, the splitting of data partitions only brings about the migration of metadata but does not include the migration of time series data. As a result, there will be no disk data input and output storms and response blockage to read and write requests caused by the migration of a large amount of time series data, and there will be no reduction in the query performance of the time series data under the storage node due to the low localization rate of the storage node. Transparent data partition splitting and cluster expansion are achieved, which improves the user experience on the business side.

[0056] Based on the above embodiment, the embodiment of the present invention further introduces a method for determining a pre-split row key position.

[0057] In some optional implementations of the embodiments of the present invention, determining the pre-split row key position of the data partition within the row key range of the data partition in S101 may include: determining the upper limit of the number of sub-data partitions that the data partition can be split into based on the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition; determining the number of actual pre-split sub-data partitions of the data partition within a range that does not exceed the upper limit of the number of sub-data partitions; determining the pre-split row key position within the row key range of the data partition based on the row key range of the data partition and the number of actual pre-split sub-data partitions of the data partition.

[0058] That is to say, first determine the minimum row key splitting granularity of the data partition, that is, the size of the minimum allowed read-write row key range or the maximum number of sub-data partitions that a single data partition is allowed to be split into, thereby determining the upper limit of the number of sub-data partitions, and select the actual number of pre-split sub-data partitions of the data partition without exceeding the upper limit of the number of sub-data partitions, so as to divide the row key range of the data partition into multiple read-write row key ranges.

[0059] In some optional implementations of the embodiments of the present invention, determining the upper limit of the number of sub-data partitions that a data partition can be split into based on the size of the row key range of the data partition and the minimum row key split granularity of the data partition can include: determining the number of optional numerical values ​​corresponding to the timing split flag bit configured in the row key of the data partition based on the data size of the timing split flag bit; and taking the number of optional numerical values ​​corresponding to the timing split flag bit as the upper limit of the number of sub-data partitions that the data partition can be split into.

[0060] In an embodiment of the present invention, a time series split flag can be added to the row key to indicate the relationship between the current data partition and the read-write row key range and the pre-split row key position. The time series split flag indicates the correspondence between the row key and the read-write row key range after the data partition is split. At the same time, according to the time series split flag, the time series data within a certain time range is assigned to the row key within the current read-write row key range, which facilitates the data partition to specify the pre-split row key position and complete the data partition split without causing data migration problems. As described in the above embodiment of the present invention, the mapping relationship can be maintained by a mapping relationship table, which records the correspondence between the data partition and the current read-write row key range.

[0061] For example, a byte of data (8 bits) can be used to represent the timing split flag. The timing split flag has a total of An optional value, indicating that a single data partition can trigger a maximum of 255 split operations.

[0062] In some other optional implementations of the embodiments of the present invention, determining the pre-split row key position of the data partition within the row key range of the data partition in S101 may also include: determining the number of actual pre-split sub-data partitions of the data partition within a range that is not less than the preset number of data partitions corresponding to the target database; determining the pre-split row key position within the row key range of the data partition according to the row key range of the data partition and the number of actual pre-split sub-data partitions of the data partition. In actual applications, some HBases may pre-determine the number of appropriate data partitions due to operation and maintenance experience or user needs, so that the data partitions are split to continuously approach this number and eventually remain at this number during the operation of the target database. Therefore, the preset number of data partitions corresponding to the target database can be used as the lower limit of the number of sub-data partitions that the data partition can be split, and a value greater than the lower limit of the number of sub-data partitions can be selected as the number of actual pre-split sub-data partitions of the data partition, and the row key range of the data partition can be evenly divided into multiple read-write row key ranges.

[0063] Combining the above-mentioned method for determining the lower limit of the number of sub-data partitions that can be split from a data partition and the upper limit of the number of sub-data partitions that can be split from a data partition, in other optional implementations of the embodiments of the present invention, determining the pre-split row key position of the data partition within the row key range of the data partition in S101 also includes: determining the upper limit of the number of sub-data partitions that can be split from the data partition according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition; determining the actual number of pre-split sub-data partitions of the data partition within a range that does not exceed the upper limit of the number of sub-data partitions and is not less than the preset number of data partitions corresponding to the target database; determining the pre-split row key position within the row key range of the data partition according to the row key range of the data partition and the actual number of pre-split sub-data partitions of the data partition.

[0064] The method for determining the lower limit of the number of sub-data partitions that a data partition can be split into and the method for determining the upper limit of the number of sub-data partitions that a data partition can be split into can refer to the above description. In the interval between the lower limit of the number of sub-data partitions and the upper limit of the number of sub-data partitions, the number of sub-data partitions actually pre-split for the data partition is selected, and the row key range of the data partition is evenly divided into multiple read-write row key ranges.

[0065] On the basis of the above-mentioned embodiments, the embodiments of the present invention further introduce the data reading and writing method in the time series data storage method using the new data partition splitting method.

[0066] According to the records of the above embodiments of the present invention, when writing the time series data to be written into the data partition in S103, a row key is allocated to the time series data to be written in the current read-write row key range, which may include: when writing the time series data to be written into the data partition, according to a mapping relationship table recording the correspondence between the data partition in the target database and the current read-write row key range, the current read-write row key range of the data partition is determined, and a row key is allocated to the time series data to be written in the current read-write row key range.

[0067] That is, a mapping relationship table can be created and maintained to determine the actually accessible location, that is, the current read and write row key range of each data partition, during the reading and writing process of the target database.

[0068] In some optional implementations of the embodiments of the present invention, the mapping relationship table may include a mapping relationship between each time series data write row key range and a time series split flag in a data partition; the time series data write row key range is an interval that divides the data partition according to the pre-split row key position, and the current read-write row key range is one of the time series data write row key ranges; the time series split flag is a newly added flag of the row key managed by the data partition, and the time series split flag of the row key in the data partition uniquely corresponds to the time series data write row key range in which it is located.

[0069] As described in the above-mentioned embodiments of the present invention, a time series split flag can be added to the row key to indicate the relationship between the data partition at the current moment and the read-write row key range and the pre-split row key position. The time series split flag indicates the correspondence between the row key and the read-write row key range after the data partition is split. At the same time, according to the time series split flag, the time series data within a certain time range is assigned a row key within the current read-write row key range, which facilitates the data partition to specify the pre-split row key position and complete the data partition splitting without causing the problem of data migration.

[0070] On this basis, according to the mapping relationship table that records the correspondence between the data partition and the current read-write row key range in the target database, the current read-write row key range of the data partition is determined, and row keys are allocated to the time series data to be written in the current read-write row key range, which can include: querying the current read-write row key range corresponding to the data partition and the time series split flag corresponding to the current read-write row key range according to the mapping relationship table; allocating row keys to the time series data to be written in the current read-write row key range, and writing the time series split flag obtained by the query in the allocated row keys, so as to allocate row keys to the time series data to be written in the current read-write row key range.

[0071] Based on the above embodiments, the embodiments of the present invention introduce a method for balancing reading and writing in a time series data storage method using a new data partition splitting method.

[0072] In the time series data storage method provided in the embodiment of the present invention, in order to avoid the centralized storage of a large number of time series data with similar time, a balanced storage method needs to be designed. In the embodiment of the present invention, a balanced storage method for a time series data scenario in HBase can be referred to, and continuous time series data can be divided into different data partitions by "adding salt" before the row key.

[0073] In some optional implementations of the embodiments of the present invention, in S103, when writing the time series data to be written into the data partition, a row key is allocated to the time series data to be written in the current read-write row key range, which may include: when receiving a write data task corresponding to the time series data to be written, calculating the salt value corresponding to the time series data to be written; determining that the data partition corresponding to the salt value is the target data partition for the time series data to be written; allocating a row key to the time series data to be written in the current read-write row key range of the target data partition, and adding the salt value before the allocated row key.

[0074] Among them, salt is a concept used to optimize storage and query. It refers to a random prefix added to the row key of the HBase data table. The purpose of this is to break up the data and prevent data skew, that is, to avoid a large amount of data being concentrated in a few data partitions, thereby improving the system's write and query performance and achieving load balancing. When the salting function is enabled, each combination of a metric and a tag will be assigned to a different "bucket" according to the configuration. Each bucket corresponds to a salt value, which will be added to the front of the row key.

[0075] In the embodiment of the present invention, a bucket may correspond to one or more data partitions, or a bucket may correspond to all data partitions under a regional server. By adding a salt value to the row key of the time series data to be written, the time series data is allocated to different "buckets", that is, balanced distribution in different data partitions is achieved.

[0076] To further realize balanced distribution of time series data within a single data partition, in some optional implementations of the embodiments of the present invention, in S103, allocating row keys for the time series data to be written in the current read-write row key range may include: randomly selecting unallocated row keys in the current read-write row key range as the row keys for the time series data to be written. By designing a random algorithm, row keys are randomly and non-repeatedly taken out from the current read-write row key range of the data partition as the row keys for the time series data to be written, thereby realizing balanced distribution of time series data within a single data partition.

[0077] Based on this, in the time series data storage method provided by an embodiment of the present invention, in S101, when writing the time series data to be written into the data partition, a row key is allocated to the time series data to be written in the current read-write row key range, and it can also include: when receiving a write data task corresponding to the time series data to be written, calculating the salt value corresponding to the time series data to be written; determining that the data partition corresponding to the salt value is the target data partition for the time series data to be written; randomly selecting an unassigned row key in the current read-write row key range of the target data partition as the row key of the time series data to be written, and adding the salt value before the assigned row key.

[0078] In some optional implementations of the embodiments of the present invention, calculating the salt value corresponding to the time series data to be written may include: calculating a hash code according to an array consisting of a metric name (metric) of the time series data to be written and a tag key value (tagk, tagv) of the time series data to be written; performing a modulo calculation on the hash code with respect to the number of buckets corresponding to the target database to obtain the salt value corresponding to the time series data to be written.

[0079] In some optional implementations of the embodiments of the present invention, the step of determining the number of buckets corresponding to the target database may include: determining the number of buckets according to the load status of the cluster where the target database is located and the number of data partition service nodes in the cluster where the target database is located. In practical applications, the default number of buckets for the target database may be 20. In actual business, the number of buckets may be adjusted according to the number of data partition service nodes in the cluster, or according to the load status of the cluster.

[0080] Based on the above embodiments, an embodiment of the present invention provides another method for storing time series data in practical applications.

[0081] Figure 2 A schematic diagram of data partition splitting provided in an embodiment of the present invention.

[0082] In the embodiment of the present invention, the time series data scenario managed by the open source time series database OpenTSDB plug-in can be referred to, and its native row key composition is as follows: [salt]<metric_uid> <timestamp> <tagk1> <tagv1> [... <tagkn> <tagvn>]; For example:

[0083] Among them, the salt value (salt) occupies a byte position, which represents the addition of salt to the row key. Take the number of buckets 20 as an example (tsd.storage.salt.buckets, the default is 20, which is determined by the number of regional servers in actual business). According to the metric name (metric_uid) + the bit (byte) array composed of all [tagK+tagV]uid, the hash code value is calculated, and the salt value bit is obtained by modulo the number of buckets. Among them, the metric (metric) represents the metric name in the time series data. Each metric represents a specific data point that needs to be monitored or recorded, such as temperature, system CPU usage, network traffic, etc. tagK is the abbreviation of Tag Key, which means the key of the tag, and is an element used to classify and identify data points in time series data. tagV is the abbreviation of Tag Value, which means the value of the tag. Together with tagK, it constitutes the tag in the time series data, which is used to provide additional dimension information about the metric. tagV is the value part of tagK, which is used to specifically describe the attributes or classification of the metric.

[0084] Metric, tagk, tagv map specific indicators to unique identifiers (UID) through the mapping relationship maintained in the table tsdb-uid to reduce the length of the row key. In OpenTSDB, UID is used to uniquely identify each metric, tagK, and tagV to optimize storage and query performance. The mapping is bidirectional, and the corresponding UID can be found based on the tagk, and the corresponding tagk can be found based on the UID.

[0085] time is the time corresponding to the time series data. The actual time of the time series data is formatted as a timestamp in hours, that is, at which hour the time series data occurs. The specific time (offset) of the time series data within this hour is written as the column name. For example, the first second of this hour is the first column, and the 3600th second is the 3600th column. When the data time precision is milliseconds, it is from the first column to the 3600000th column.

[0086] This special row key design adds salt by calculating the hash code of the salt value bit, and evenly distributes all time series data read and write requests to all storage nodes in the cluster.

[0087] For example, the offset of the first second at 11 o'clock is 000111. If salting is used to evenly distribute the time series data, a random number (i.e., salt value) between 1 and 20 is generated, taking the number of buckets in the cluster as 20, and the random number and the managed row key range are combined to randomly distribute the time series data to different data partitions. If salting is not performed, the starting position of the row key is the same, which means that the time series data at 11 o'clock will be concentrated in one data partition and become hot data.

[0088] However, there is an upper limit to the data size supported by a single data partition (the default is 10GB). As time series data is continuously generated, the data in the data partition will inevitably split when the data reaches the upper limit. The single parent data partition will be split into two child data partitions, and then the two child data partitions will be distributed to the storage nodes where the servers in different regions are located according to the specified strategy, resulting in problems such as reduced localization rate and disk I / O storms caused by the relocation of underlying files on different nodes.

[0089] Therefore, in order to solve this problem, the time series data storage method provided in the embodiment of the present invention improves the original row key design. The improved row key can be expressed as follows: [salt][time_split]<metric_uid> <timestamp> <tagk1> <tagv1> [... <tagkn> <tagvn>]; Among them, time_split is the time series split flag introduced in the above embodiment of the present invention, which indicates the relationship between the data partition and the read-write row key range and the pre-split row key position, and can occupy one byte (8 bits). The time_split bit indicates the one-to-one correspondence between the row key and the read-write row key range after the data partition is split. At the same time, according to this bit, the time series data within a certain time range is written to the specified segment in the data partition, which is convenient for the data partition to specify the pre-split row key position to complete the data partition split while ensuring that no data migration problems will occur. It should be noted that for each read-write row key range of the data partition, there is only one current read-write row key range at each moment, so it can be considered that different read-write row key ranges correspond to time series data of different time ranges (time range), so in Figure 2 In the example, the key ranges of each read and write row are tr1, tr2, tr3, tr4, ..., trN.

[0090] Design a mapping relationship table (tsdb-timerange) to record the specific correspondence between the read and write row key ranges and row keys. This mapping relationship table is not originally available in HBase and is a newly added mapping relationship maintenance table. The specific design can be as follows Figure 2 As shown, the left side is a mapping relationship table that records the information of each data partition in the target database. It is expanded to record multiple read-write row key ranges divided by each data partition according to the pre-split row key position. Assume that at the current moment, the first read-write row key range (read-write row key range 1, tr1) in data partition 2 is the current read-write row key range, storing time series data d1, d2, d3, etc., and the remaining read-write row key ranges do not correspond to time series data. When data partition 2 meets the data partition splitting condition, the data partition splitting is triggered, and the sub-data partition where the read-write row key range 1 (tr1) is located is data partition 21, and the sub-data partitions where the remaining read-write row key ranges of data partition 2 are located are migrated to other storage nodes. That is, Figure 2 Data partition 22 in the migration. Since data partition 22 does not correspond to time series data before migration, it will not trigger data relocation or disk I / O storm, and will not cause a decrease in the localization rate of the storage node to which it is migrated. In the new storage node, the first read-write row key range (read-write row key range 2, tr2) of data partition 22 becomes the current read-write row key range of data partition 22 at the current moment, storing time series data d4, d5, d6, etc. The remaining read-write row key ranges do not correspond to time series data. When data partition 22 meets the data partition splitting condition, the data partition splitting is triggered, and the sub-data partition where the read-write row key range 2 (tr1) is located is data partition 221, which is the sub-data partition retained in the original storage node, and the sub-data partitions where the remaining read-write row key ranges of data partition 22 are located are migrated to other storage nodes, that is, Figure 2 Since data partition 222 does not correspond to time series data before migration, it will not cause data migration and disk I / O storm, and will not cause the localization rate of the storage node to which it is migrated to decrease. And so on.

[0091] As described in the above embodiment of the present invention, the number of sub-data partitions that a data partition can be split into can be determined according to the data size of the timing split flag. In the embodiment of the present invention, the timing split flag can be selected to occupy 1 byte, that is, An optional value, indicating that a single data partition can trigger a maximum of 256 split operations.

[0092] In the embodiment of the present invention, the principle that data partition splitting does not lead to data migration is that in the read-write row key range 1, in the row keys of the time series data d1, d2, d3 and other data, the 8 bits of the time series split flag are all 0, that is, all are written into the read-write row key range 1 of the data partition 2. In actual use, the time series data of the read-write row key range tr1, tr2, tr3, tr4, ..., trN are all managed by the same data partition. Among them, assuming that the salt bit of data partition 2 is 0, the row key range included in the read-write row key range 1 is 00~01, and the row key range included in tr1-trN is 01~0*. When data partition 2 is split, the read and write row key range is *~now, and all the written time series data are in tr1. When the data partition split operation is triggered, the split point of data partition 2 is 01, and two sub-data partitions are generated, namely data partition 21 and data partition 22. Data partition 21 is responsible for all data under tr1 and is retained in the storage node where the original regional server is located. Tr2, tr3, etc. under data partition 22 have no data and can be randomly allocated to other regional servers (when the data partition split caused by expansion is allocated to the expanded storage node), thereby realizing data partition splitting without causing data migration and reducing the localization rate.

[0093] In combination with the data partition splitting and balancing module 301, the mapping management module 302 and the read-write conversion module 303 introduced in the following embodiment of the present invention, the data partition splitting and balancing module 301 is designed to implement the fixed-point splitting of the data partition in the time series data storage method provided in the embodiment of the present invention and the data partition balancing operation during expansion. Through a special row key design and a fixed-point splitting scheme, the row key is matched with the read-write row key range to avoid problems such as a decrease in localization rate and data relocation when the data partition is split. The mapping management module 302 is used to maintain the mapping relationship between the read-write row key range and the time series split flag (time_split) in the row key through a mapping relationship table (tsdb-timerange) for use by the read-write conversion module 303 and the data partition splitting and balancing module 301. Due to the high frequency of writing of time series data, the mapping relationship table can be set as a table of the resident memory type, and the business read and write requests are blocked due to hot spots when placing requests for the table. The read-write conversion module 303 is responsible for reading or writing time series data. It obtains the value of the corresponding time series split flag through the timestamp of the time series data itself, converts it into the corresponding row key range for inserting row keys or querying, and completes the time series data read and write business request.

[0094] Therefore, the time series data storage method provided by the embodiment of the present invention designs row keys according to the characteristics of the time series data scenario, corresponds the row keys to the read and write row key range, and based on the special design of the row keys and the correspondence between the data files and the time range, combined with the fixed-point splitting of the data partition, after the data partition splits, the data localization rate does not decrease, and the data partition balance does not produce the effect of data migration. When the time series data of the data partition reaches the upper limit or the cluster is expanded, transparent data partition splitting and cluster load balancing are provided to improve the user experience on the business side.

[0095] It should be noted that in the embodiments of the time series data storage method of the present invention, some of the steps or features can be ignored or not executed. The hardware or software functional modules divided for the convenience of description are not the only implementation form of the time series data storage method provided in the embodiments of the present invention.

[0096] The above describes in detail various embodiments corresponding to the time series data storage method. On this basis, the present invention also discloses a time series data storage device, a time series data storage equipment, a non-volatile storage medium and a computer program product corresponding to the above method.

[0097] Figure 3 An architectural diagram of a time series data storage device provided in an embodiment of the present invention.

[0098] like Figure 3 As shown, the time series data storage device provided by the embodiment of the present invention includes: The data partition splitting and balancing module 301 is used to obtain the row key range corresponding to each data partition of the target database, determine the pre-split row key position of the data partition within the row key range of the data partition; determine the current read-write row key range in the data partition with the pre-split row key position as the boundary; when the data partition splitting condition is met, the data partition to be split is split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition to be migrated to other storage nodes is determined in the row key range that does not include the current read-write row key range; A mapping management module 302, used to manage a mapping relationship table recording the corresponding relationship between data partitions and the current read / write row key range; The read-write conversion module 303 is used to query the mapping relationship table through the mapping management module to determine the current read-write row key range of the data partition when writing the time series data to be written into the data partition, and allocate row keys to the time series data to be written in the current read-write row key range.

[0099] like Figure 3 As shown, in the embodiment of the present invention, the data partition splitting and balancing module 301 is used for the fixed-point splitting of data partitions and the data partition balancing operation during expansion. Through a special row key design and a fixed-point splitting scheme, the row key is matched with the read-write row key range to avoid problems such as a decrease in localization rate and data relocation when the data partition is split.

[0100] The mapping management module 302 is used to maintain the mapping relationship table between the read-write row key range, row key and data partition. Each read-write row key range can contain a certain row key range and a certain number of data partitions, and manage the data writing and query within the range.

[0101] The read-write conversion module 303 is used to process the read-write request according to the mapping relationship table and send the request to the corresponding data partition. The read-write conversion module 303 can convert the write and query conditions in the write request and query request, and balance the read-write request load to all storage nodes in the cluster through the corresponding relationship between the read-write row key range and the row key maintained by the mapping management module 302.

[0102] like Figure 3 As shown in the figure, RS1, RS2, RS3, ... RS M are storage nodes in the cluster where the target database is located, where RSM is an example of an expanded storage node. Assume that in the initial stage, there are 9 data partitions in the target database, namely, data partition 1, data partition 2, data partition 3, data partition 4, data partition 5, data partition 6, data partition 7, data partition 8, and data partition 9. When the cluster expansion triggers the data partition splitting, assuming that the expanded storage node RS M is used as the expanded storage node of storage node 1 (RS1), the data partitions 1, data partition 2, and data partition 3 distributed on storage node 1 are split, so that data partition 1 is split into data partition 11 and data partition 12, data partition 2 is split into data partition 21 and data partition 22, and data partition 3 is split into data partition 31 and data partition 32, and the split sub-data partitions (data partition 11, data partition 21, data partition 31) are retained in storage node 1 (RS1), and the split sub-data partitions (data partition 12, data partition 22, data partition 32) are migrated to the expanded storage node RS M. By applying the time series data storage solution provided in the embodiment of the present invention, it is ensured that the sub-data partition remaining in the storage node 1 (RS1) is a sub-data partition including the current read-write row key range, and the sub-data partition migrated to the expanded storage node RS M is a sub-data partition not including the current read-write row key range.

[0103] It should be noted that in each implementation of the timing data storage device provided in the embodiment of the present invention, the division of units is only a logical functional division, and other division methods can be used. The connection method between different units can be electrical, mechanical or other connection methods. The separated units can be located in the same physical location or distributed on multiple network nodes. Each unit can be implemented in the form of hardware or in the form of a software functional unit. That is, part or all of the units provided in the embodiment of the present invention can be selected according to actual needs and the corresponding connection method or integration method can be adopted to achieve the purpose of the embodiment of the present invention.

[0104] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0105] The time series data storage device provided by the embodiment of the present invention determines the pre-splitting row key position of the data partition of the target database according to the row key range in advance, and determines the current read-write row key range in the data partition with the pre-splitting row key position as the boundary, so that when the time series data to be written is written into the data partition, the row key is allocated to the time series data to be written in the current read-write row key range; and when the data partition splitting condition is met, the data partition to be split is split into multiple sub-data partitions according to the pre-splitting row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition including the row key range not including the current read-write row key range is retained in the original storage node. The scope determines the sub-data partitions to be migrated to other storage nodes, so that the sub-data partitions that need to be migrated to other storage nodes do not correspond to time series data, and will not cause the problem of reduced localization rate of other storage nodes to which they are migrated. Therefore, the splitting of data partitions only brings about the migration of metadata but does not include the migration of time series data. As a result, there will be no disk data input and output storms and response blockage to read and write requests caused by the migration of a large amount of time series data, and there will be no reduction in the query performance of the time series data under the storage node due to the low localization rate of the storage node. Transparent data partition splitting and cluster expansion are achieved, which improves the user experience on the business side.

[0106] Figure 4 A schematic diagram of the structure of a time series data storage device provided by an embodiment of the present invention.

[0107] like Figure 4 As shown, the time series data storage device provided in an embodiment of the present invention includes: a memory 410, used to store a computer program 411; a processor 420, used to execute the computer program 411, and when the computer program 411 is executed by the processor 420, the steps of the time series data storage method provided in any of the above embodiments are implemented.

[0108] Among them, the processor 420 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc. The processor 420 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 420 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 420 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 420 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0109] The memory 410 may include one or more non-volatile storage media, which may be non-transitory. The memory 410 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 410 is at least used to store the following computer program 411, wherein the computer program 411, after being loaded and executed by the processor 420, can implement the relevant steps in the time series data storage method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 410 may also include an operating system 412 and data 413, etc., and the storage method may be short-term storage or permanent storage. Among them, the operating system 412 may be Windows or other types of operating systems. Data 413 may include, but is not limited to, the data involved in the above method.

[0110] In some embodiments, the time series data storage device may further include a display screen 430 , a power supply 440 , a communication interface 450 , an input / output interface 460 , a sensor 470 , and a communication bus 480 .

[0111] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the time-series data storage device, and may include more or less components than those shown in the figure.

[0112] The time series data storage device provided in an embodiment of the present invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the steps of the time series data storage method provided in the above embodiment, and the effect is the same as above.

[0113] An embodiment of the present invention provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the time series data storage method provided in any one of the above embodiments can be implemented.

[0114] The non-volatile storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0115] For the introduction of the non-volatile storage medium provided in the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the time series data storage method provided in the embodiment of the present invention, and the present invention will not elaborate on it here.

[0116] An embodiment of the present invention provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the time series data storage method provided in any one of the above embodiments.

[0117] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the time series data storage method provided by the embodiment of the present invention, and the present invention will not elaborate on it here.

[0118] The above is a detailed introduction to the time series data storage method, device, equipment, medium and computer program product provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can refer to each other. For the devices, equipment, non-volatile storage media and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can refer to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present invention.

[0119] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.< / tagvn> < / tagkn> < / tagv1> < / tagk1> < / timestamp> < / tagvn> < / tagkn> < / tagv1> < / tagk1> < / timestamp>

Claims

1. A method for storing time series data, characterized in that: include: Obtaining a row key range corresponding to each data partition of the target database, and determining a pre-split row key position of the data partition within the row key range of the data partition; Determine the current read-write row key range in the data partition based on the pre-split row key position; When writing the time series data to be written into the data partition, a row key is allocated to the time series data to be written within the current read-write row key range; When the data partition splitting conditions are met, the data partition to be split is split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition to be migrated to other storage nodes is determined within the row key range that does not include the current read-write row key range.

2. The method for storing time series data according to claim 1, characterized in that: Determining a pre-split row key position of the data partition within a row key range of the data partition includes: Determine an upper limit on the number of the sub-data partitions that the data partition can be split into according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition; Determine the number of the sub-data partitions for actual pre-splitting of the data partition within a range not exceeding an upper limit of the number of the sub-data partitions; The pre-split row key position is determined within the row key range of the data partition according to the row key range of the data partition and the number of the sub-data partitions actually pre-split of the data partition.

3. The method for storing time series data according to claim 2, characterized in that: Determining an upper limit on the number of the sub-data partitions that the data partition can be split into according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition includes: Determine the number of optional values ​​corresponding to the timing split flag bit according to the data size of the timing split flag bit configured in the row key of the data partition; The number of optional numerical values ​​corresponding to the timing split flag is the upper limit of the number of sub-data partitions that the data partition can be split into.

4. The method for storing time series data according to claim 1, characterized in that: Determining a pre-split row key position of the data partition within a row key range of the data partition includes: Determine the number of the sub-data partitions of the actual pre-splitting of the data partition within a range that is not less than the preset number of data partitions corresponding to the target database; The pre-split row key position is determined within the row key range of the data partition according to the row key range of the data partition and the number of the sub-data partitions actually pre-split of the data partition.

5. The method for storing time series data according to claim 1, characterized in that: Determining a pre-split row key position of the data partition within a row key range of the data partition includes: Determine an upper limit on the number of the sub-data partitions that the data partition can be split into according to the size of the row key range of the data partition and the minimum row key splitting granularity of the data partition; Determine the number of the sub-data partitions of the actual pre-splitting of the data partition within a range that does not exceed the upper limit of the number of the sub-data partitions and is not less than the preset number of data partitions corresponding to the target database; The pre-split row key position is determined within the row key range of the data partition according to the row key range of the data partition and the number of the sub-data partitions actually pre-split of the data partition.

6. The method for storing time series data according to claim 1, characterized in that: Determining the current read / write row key range in the data partition with the pre-split row key position as the boundary includes: The row key range before the first pre-split row key position of the data partition is taken as the current read-write row key range.

7. The time series data storage method according to claim 1, characterized in that: Determining the sub-data partition to be migrated to another storage node in a row key range that does not include the current read-write row key range includes: The row key ranges that do not include the current read-write row key range are all used as the sub-data partitions migrated to other storage nodes.

8. The time series data storage method according to claim 1, characterized in that: When writing the time series data to be written into the data partition, allocating a row key for the time series data to be written in the current read-write row key range includes: When writing the time series data to be written into the data partition, the current read-write row key range of the data partition is determined according to a mapping relationship table recording the correspondence between the data partition in the target database and the current read-write row key range, and a row key is allocated to the time series data to be written within the current read-write row key range.

9. The method for storing time series data according to claim 8, characterized in that: The mapping relationship table includes a mapping relationship between a row key range written into each time series data in the data partition and a time series split flag bit; The time series data write row key range is the interval into which the data partition is divided according to the pre-split row key position, and the current read-write row key range is one of the time series data write row key ranges; the time series split flag is a newly added flag of the row key managed by the data partition, and the time series split flag of the row key in the data partition uniquely corresponds to the time series data write row key range in which it is located.

10. The method for storing time series data according to claim 9, characterized in that: Determining the current read / write row key range of the data partition according to a mapping relationship table recording the corresponding relationship between the data partition in the target database and the current read / write row key range, and allocating a row key for the time series data to be written in the current read / write row key range, including: Query the current read / write row key range corresponding to the data partition and the timing split flag corresponding to the current read / write row key range according to the mapping relationship table; A row key is allocated to the time series data to be written in the current read-write row key range, and the time series split flag obtained by query is written into the allocated row key, so as to allocate a row key to the time series data to be written in the current read-write row key range.

11. The time series data storage method according to claim 1, characterized in that: When writing the time series data to be written into the data partition, allocating a row key for the time series data to be written in the current read-write row key range includes: When receiving the data writing task corresponding to the time series data to be written, calculating and obtaining the salt value corresponding to the time series data to be written; Determine that the data partition corresponding to the salt value is the target data partition for writing the time series data; A row key is allocated to the time series data to be written in the current read-write row key range of the target data partition, and the salt value is added before the allocated row key.

12. The method for storing time series data according to claim 1, characterized in that: Allocating a row key for the time series data to be written in the current read-write row key range includes: An unassigned row key is randomly selected in the current read-write row key range as the row key of the time series data to be written.

13. The method for storing time series data according to claim 1, characterized in that: When writing the time series data to be written into the data partition, allocating a row key for the time series data to be written in the current read-write row key range includes: When receiving the data writing task corresponding to the time series data to be written, calculating and obtaining the salt value corresponding to the time series data to be written; Determine that the data partition corresponding to the salt value is the target data partition for writing the time series data; An unassigned row key is randomly selected in the current read-write row key range of the target data partition as the row key of the time series data to be written, and the salt value is added before the assigned row key.

14. The time series data storage method according to claim 11 or 13, characterized in that: Calculating the salt value corresponding to the time series data to be written includes: Calculate a hash code according to an array consisting of the indicator name of the time series data to be written and the tag key value of the time series data to be written; The hash code is modulo-calculated by the number of buckets corresponding to the target database to obtain the salt value corresponding to the time series data to be written.

15. The time series data storage method according to claim 14, characterized in that: The step of determining the number of buckets corresponding to the target database includes: The number of buckets is determined according to the load status of the cluster where the target database is located and the number of data partition service nodes in the cluster where the target database is located.

16. The method for storing time series data according to claim 1, characterized in that: The data partition splitting condition includes at least one of: the amount of time series data corresponding to the data partition reaches the maximum data capacity corresponding to the data partition, and the cluster expansion of the target database triggers the data partition splitting.

17. A time series data storage device, characterized in that: include: A data partition splitting and balancing module is used to obtain the row key range corresponding to each data partition of the target database, determine the pre-split row key position of the data partition within the row key range of the data partition; determine the current read-write row key range in the data partition with the pre-split row key position as the boundary; when the data partition splitting condition is met, split the data partition to be split into multiple sub-data partitions according to the pre-split row key position of the data partition to be split, so that the sub-data partition including the current read-write row key range is retained in the original storage node, and the sub-data partition to be migrated to other storage nodes is determined in the row key range that does not include the current read-write row key range; A mapping management module, used to manage a mapping relationship table recording the corresponding relationship between the data partition and the current read / write row key range; The read-write conversion module is used to query the mapping relationship table through the mapping management module to determine the current read-write row key range of the data partition when writing the time series data to be written into the data partition, and allocate a row key to the time series data to be written within the current read-write row key range.

18. A time series data storage device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the time series data storage method as described in any one of claims 1 to 16 are implemented.

19. A non-volatile storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the time series data storage method according to any one of claims 1 to 16 are implemented.

20. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the time series data storage method according to any one of claims 1 to 16 are implemented.

Citation Information

Patent Citations

  • HBase-based intelligent power grid acquisition and monitoring data storage system and storage method

    CN110807032A

  • Data storage method and device

    CN115480710A

  • Time sequence data storage management method and system based on time partition index

    CN117633105A

  • Time sequence database data partition distribution method and system

    CN118427226A