WO2017143957A1 - 一种数据重分布的方法及装置 - Google Patents

一种数据重分布的方法及装置 Download PDF

Info

Publication number
WO2017143957A1
WO2017143957A1 PCT/CN2017/074121 CN2017074121W WO2017143957A1 WO 2017143957 A1 WO2017143957 A1 WO 2017143957A1 CN 2017074121 W CN2017074121 W CN 2017074121W WO 2017143957 A1 WO2017143957 A1 WO 2017143957A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
storage node
unit
migrated
value
Prior art date
Application number
PCT/CN2017/074121
Other languages
English (en)
French (fr)
Inventor
左超
刘辉军
何雄辉
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2017143957A1 publication Critical patent/WO2017143957A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the present application relates to the field of data storage technologies, and in particular, to a method and an apparatus for data redistribution.
  • database clusters are mainly used to store massive amounts of data.
  • the so-called database cluster is to use a plurality of database servers to form a virtual single database logical image, providing transparent data services to clients like a single database server system.
  • a database server in a database cluster can be called a storage node.
  • the database cluster has multiple storage nodes and one data management node.
  • the data management node can also be combined with the storage node.
  • the data blocks are usually distributed according to a certain algorithm. On each storage node, commonly used algorithms include a hash algorithm, a round robin algorithm, and a random algorithm.
  • the data management node stores the data block identifiers of all data blocks in all storage nodes and their corresponding addresses.
  • database clusters need to be expanded at any time.
  • you need to redistribute the original storage data to make full use of the newly added storage nodes.
  • the process of data redistribution needs to be recalculated according to the latest number of storage nodes by a certain algorithm, and some data will be migrated to the newly added storage nodes.
  • the embodiment of the present application provides a method and an apparatus for data redistribution, which are used to shorten the time of service interruption in the process of data redistribution.
  • a method for data redistribution includes: providing a service to an external storage node of a data to be migrated and a target storage node of the data to be migrated when determining that data redistribution is required Set to not provide external service; in the state that the current storage node is not available for external service, based on the usage heat of the data to be migrated recorded during the period when the current storage node provides the service externally, The first set of data in the migration data that uses a heat greater than a preset threshold is migrated to the target storage node; the usage heat is used to characterize the number of times the data to be migrated is used; storing the current storage node and the target The state of the node is switched back to the externally available service to provide external services.
  • the first set of data may be referred to as hotspot data
  • the preset threshold is a threshold value for distinguishing hotspot data and non-hotspot data in the data to be migrated according to an empirical value.
  • the method before performing the data redistribution, the method further includes: when the current storage node provides a service to the external storage node, Data storage model Each unit below records a usage heat; wherein, when any unit is established, an initial usage heat is recorded for the arbitrary unit, and any one of the units is updated whenever the unit is used once. The unit uses the heat.
  • the data storage model includes any one of a data table, a data page, and a data record;
  • the unit is a data table, a data page or a data record.
  • the method further includes: when the current storage node provides a service to the external storage node, the data for the current storage node
  • the usage heat of all units under the storage model is set to N levels, N ⁇ 2, and N is a positive integer; the highest value of the usage heat of all the units after the current storage node is last updated using the heat is set as the a value of a highest level among the N levels; based on the value of the highest level, setting values of (N-1) levels other than the highest level among the N levels according to a decrement rule; Updating the usage heat corresponding to one unit, comparing the updated usage heat with the highest level value, and updating the highest level value to the said when the updated usage heat is greater than the highest level value Updated usage heat.
  • the values of the (N-1) levels are sequentially updated according to the updated highest level value; or, the value of the highest level after the current update is further determined to be the highest before the current update. Whether the difference between the values of the levels is greater than the set difference threshold, and when it is determined that the difference between the value of the highest level after the current update and the value of the highest level before the current update is greater than the set difference threshold, The values of the (N-1) levels are sequentially updated.
  • the preset threshold is a value of an nth rank of the N ranks, 1 ⁇ n ⁇ N, n is a positive integer; the migrating the first group of data in the data to be migrated with the heat greater than the preset threshold to the target storage node, specifically: traversing the data to be migrated under the data storage model Each unit of the unit; wherein, for each selected unit, the usage heat of the currently selected unit is compared with the value of the nth level; if the currently selected unit has a usage heat greater than the nth The values of the ranks then migrate the currently selected unit to the target storage node.
  • the preset threshold is a threshold value for distinguishing hotspot data and non-hotspot data in the data to be migrated according to an empirical value.
  • the hotspot data accounts for about 20% of all data. So, when applying the method provided in the present application, when the value of the selected nth level can be implemented such that the first group of data is close to the hotspot data of the conventional meaning in the database application, the time taken to migrate the hotspot data is less than The time taken to migrate all data saves time spent on data migration.
  • the status of the current storage node and the target storage node are determined by After the non-external service is switched to the externally available service, the method further includes: in the background service of the current storage node and the target storage node, using the second set of data in the data to be migrated that is not greater than a preset threshold Migrate to the target storage node.
  • the second group of data may also be referred to as non-hotspot data. Since most of the data access requests received within a period of time after the storage node is restored for use are access requests for hotspot data, the storage node is set to be externally available. After the service, continue to migrate non-hotspot data in the background, which can effectively reduce the impact of the migration data on the normal service of the database.
  • the method further includes: when migrating the second group of data, when receiving the data access request, Locating to the target storage node according to the first routing manner; the first routing manner is a routing manner after performing the data redistribution; If the access data related to the data access request exists in the target storage node, the access data stored in the target storage node is operated; if the target storage node does not exist in the target storage node The access data is located, and the current storage node is located according to the second routing manner, and the access data stored in the current storage node is operated; the second routing manner is performed after the data is redistributed. Routing method.
  • the above method can reduce the probability of the access failure after receiving the access request.
  • a device for data redistribution having the function of implementing any one of the first to sixth possible implementations of the first aspect and the first aspect described above .
  • the functions may be implemented by hardware or by corresponding software implemented by hardware.
  • the hardware or software includes one or more modules corresponding to the functions described above.
  • an apparatus for data redistribution comprising a memory and a processor, wherein the memory is for storing a set of programs, the processor is configured to invoke the program stored by the memory to perform the first aspect as described above And the method of any one of the first to sixth possible implementations of the first aspect.
  • a computer storage medium for storing computer software instructions for use in the data redistribution apparatus of the second aspect or the third aspect, comprising a program designed to perform the above aspects.
  • the solution provided by the present application can shorten the time of service interruption in the process of data redistribution and improve the system performance of the database server cluster.
  • FIG. 1 is a system architecture diagram of data redistribution in an embodiment of the present application.
  • FIG. 2 is a flowchart of a method for data redistribution in an embodiment of the present application
  • FIG. 3 is a schematic diagram of data redistribution in an application scenario according to an embodiment of the present application.
  • FIG. 4 is a structural diagram of a device for redistributing data in an embodiment of the present application.
  • FIG. 5 is a second structural diagram of a device for redistributing data in an embodiment of the present application.
  • Any storage system in this embodiment of the present application is preferably applicable to a distributed storage system, such as a database cluster.
  • a distributed storage system has multiple storage nodes and one data management node, and the data management node may also be combined with the storage node.
  • one storage node may be a database server.
  • the embodiment of the present application is applied to a database cluster as an example.
  • a storage node may be conceptually equivalent to a database server.
  • the embodiment of the present application provides a data redistribution method, when the storage node provides the service period, the usage of the statistical data is hot.
  • the external service is suspended, that is, the service is temporarily interrupted, and the hot data on the database server is first migrated. After the hot data migration is completed, the database server is restored. External services, continue to migrate non-hotspot data in the background.
  • replacing all data with the migration part data reduces the time for migrating data to a certain extent, shortens the time of service interruption, and because the access rate of hotspot data is far greater during a period of time after data redistribution
  • the probability of accessing non-hotspot data therefore, can reduce the impact of migration data on the normal service of the database.
  • the execution body that executes the following data re-segment method may be the current storage node of the data to be migrated, or may be the data management node in the data redistribution system.
  • the current storage node of the data to be migrated and the target storage node of the data to be migrated are all set to be externally provideable services, that is, set to be unavailable. use.
  • the current storage node is a storage node where the data to be migrated is located.
  • a storage node has two working states, which can provide external services and cannot provide external services.
  • the externally available services can be understood as the data on the storage node is readable and writable.
  • the externally unavailable service can be understood as unreadable and unwritable. , or read only.
  • a new storage node that is, a database server
  • Some data stored on the storage nodes in the original database cluster may be partially migrated to the new storage node to fully utilize.
  • the storage capacity of the new storage node, the process of data migration is the process of data redistribution.
  • a database cluster deletes a storage node, it also involves the process of data redistribution.
  • the affected storage node and the affected data can be obtained.
  • the affected storage node needs to be temporarily suspended to provide external services (that is, set to be unavailable for external service) to avoid the data migration process. There are problems such as data access errors.
  • the data to be migrated is The first set of data having a heat greater than a preset threshold is migrated to the target storage node.
  • the usage heat is used to characterize the number of times the data to be migrated is used, and the used cases include: adding data, deleting data, modifying data, querying data, and the like.
  • the preset threshold is a threshold value for distinguishing hotspot data and non-hotspot data in the data to be migrated according to an empirical value. Generally, the hotspot data accounts for about 20% of the entire data to be migrated. Therefore, the preset threshold can be set according to the experience value, and can be continuously updated and optimized during use.
  • section 203 after the first set of data is migrated, the state of the current storage node and the target storage node is switched back from the non-outgoing service to provide external service. And, in the background, the second group of data in the data to be migrated that uses the heat not greater than the preset threshold is migrated to the target storage node.
  • the data in the database can be stored in a multi-layered logical data storage model.
  • the data storage model can at least include three logical concepts: data tables, data pages, and data records.
  • the data stored in one storage node can be divided into multiple data tables, each of which contains multiple data pages, each of which contains multiple data records.
  • a unit under the data storage model can be a data table, a data page, or a data record.
  • the storage is recorded.
  • the usage heat of the data of the storage node and the usage heat of the data for the storage node are set.
  • a usage heat is recorded for each unit of the storage node's data storage model, wherein an initial usage is recorded for any one of the units when any unit is established. Heat, when any one of the units is used once, the usage heat corresponding to any one of the units is updated.
  • the database cluster includes multiple storage nodes, and during the period in which any one of the storage nodes provides the service, the corresponding data is recorded for each unit in the data storage model of any storage node. Use the heat condition.
  • the recording mode is the same as that of the current storage node. The present application is only described by taking the current storage node as an example.
  • the current storage node includes m data tables, which are assumed to be represented by T1, T2, ..., Tm, and corresponding to each data table when the storage node provides a service period to the outside. Record a usage heat.
  • the initial value of the usage heat of the record is 0 or 1;
  • the implementation process of using the heat record can be, but is not limited to, adding a use heat (ie hits) field in the header of each data table, and implementing the heat value record through the hits field.
  • the recording of the usage heat of the data table in the current storage node at the first time is as shown in Table 1.
  • the usage heat of the data table T1 is 10000
  • the usage heat of the data table T2 is 9800
  • the data sheet Tm has a heat of use of 1600.
  • the data storage model is the same as the data table for the use of data pages or data records. The repetitions are not repeated here.
  • the data usage heat corresponding to the unit maintenance in each data storage model may be selected. Currently, one or more of the data may be selected.
  • the usage heat corresponding to each unit is updated, and the updated usage heat is compared with the highest level value, and when the updated usage heat is greater than the highest level value, the highest level value is updated.
  • the usage heat for the update is updated.
  • the values of the (N-1) levels are sequentially updated according to the updated highest level value; or, the value of the highest level after the current update is further determined to be the highest before the current update. Whether the difference between the values of the levels is greater than the set difference threshold, and when it is determined that the difference between the value of the highest level after the current update and the value of the highest level before the current update is greater than the set difference threshold, The values of the (N-1) levels are sequentially updated.
  • the recording of the usage heat of the data table in the current storage node is as shown in Table 1.
  • the usage heat of the data table T1 is The highest value of the usage heat of all the data tables in the current storage node is 10000.
  • the value of the level Lh is such that the values of L10 to L1 exhibit a regular decreasing pattern, or other regular patterns are present, where h is 1-9 and h is a positive integer.
  • the second part when it is determined that the data needs to be migrated, the state of the current storage node and the target storage node is switched from the externally available service to the non-external service, and the usage heat of the data to be migrated on the current storage node is greater than a preset threshold.
  • the first set of data is migrated to the target storage node, and then the normal use of the current storage node and the target storage node is restored, and the second set of data other than the first set of data in the data to be migrated on the current storage node is continuously migrated in the background.
  • the current storage node and the target storage node are the storage nodes affected by the data redistribution.
  • the affected storage node may be one or multiple.
  • the embodiment of the present application is affected when the data is redistributed.
  • the storage node is an example of a current storage node and a target storage node.
  • the methods of multiple affected storage nodes are the same.
  • This part is the core part of the embodiment of the present application.
  • the main idea is to migrate hotspot data first, and then migrate non-hotspot data in the background.
  • the ratio of hotspot data to non-hotspot data in a storage node is about 2:8. Therefore, when the storage node is unavailable, only the hotspot data is migrated, which greatly shortens the unavailable time of the storage node, thereby reducing the time of service interruption and improving the performance of the system.
  • the manner of distinguishing the hotspot data and the non-hotspot data may be performed by using the foregoing storage node provided in the present application.
  • the data usage statistic calculated during the service period and the level of the data usage heat setting are judged, and the specific judgment manner is as follows.
  • Each selected unit compares the usage heat of the currently selected unit with the value of the nth level
  • the usage heat of the currently selected unit is greater than the value of the nth level, then the currently selected unit is migrated to the target storage node;
  • the preset threshold is a value of the nth rank of the N ranks, 1 ⁇ n ⁇ N, and n is a positive integer.
  • the strategy of comparing and re-migrating may be selected, that is, the usage heat of each unit is first compared with the value of the nth level, and after performing comparison of all units, the usage heat is filtered out to be greater than the nth
  • the units of the values of the ranks are migrated; it is also possible to select the one-by-one migration strategy one by one, that is, each unit is compared, and when the used heat of the compared unit is greater than the value of the nth rank, the unit is moved to the The target storage node.
  • the storage model is taken as an example of the data table, and the preset threshold of the migration is first determined.
  • the value of the eighth level of the 10 levels of the first moment is set to a preset threshold, that is, a preset threshold. It is 8000.
  • the selection of preset thresholds can be continually updated and optimized based on experience.
  • the usage heat of the obtained data table T2 is 9800, and determining that the usage heat of the data table T2 is greater than the preset threshold 8000, the data table T2 is migrated to the target storage node;
  • the usage heat of the acquisition data table T3 is 3400, and the usage heat of the determination data table T3 is less than the preset threshold 8000, then skipping the data table T3 and continuing to traverse the data table T4.
  • the target storage node when the data access request is received, the target storage node is located according to the first routing manner; the first routing manner is a routing manner after data redistribution;
  • the access data stored in the target storage node is operated;
  • the second routing manner is a routing manner before data redistribution.
  • the foregoing routing method is a method for determining a path for locating the access data corresponding to the data access request to the storage node, and may adopt any routing method in the prior art, which is not limited in this application.
  • the reason why the present application is designed in this way is that, after the hotspot data migration is completed, the storage node is set to provide external services, and most of the data access requests received later are access hotspot data, and therefore, firstly, according to the data redistribution
  • the new routing method is routed to the target storage node, and the probability of being able to access the hotspot data is very large. If the access data does not exist in the target storage node, it is routed to the original storage node according to the old route before the data redistribution. There are two cases after that. If the access data is on the original storage node, the access data is operated; if the access data is not on the original storage node, the access fails. As a result, the chances of an access failure will be very small.
  • the data is distributed to the storage nodes by using a consistent hash algorithm.
  • the consistency hash algorithm is the same as the prior art, and is not described in detail in this embodiment.
  • the small circle on the ring represents a storage node.
  • the data stored in the storage node B includes a key value mapped to the arc between the storage node A and the storage node B.
  • Regional data is mapped to the arc between the storage node A and the storage node B.
  • step 1 when the data needs to be operated, the hash value is used to calculate the key value
  • the key value is mapped to the first storage node in the clockwise direction, that is, on the storage node B;
  • the value of the heat is used plus one.
  • the value of the usage heat of the corresponding data table is incremented by one.
  • the usage heat value of the corresponding data table after performing the addition 1 calculation is compared with the highest level value of the data table on the storage node B. When the value is greater than the highest level, the highest level value is calculated according to the execution plus 1.
  • the subsequent data table is updated with the usage heat value, and the other level values are sequentially updated.
  • step 3 the storage node H is added to the distribution of the storage nodes in FIG. 3a, and is specifically added between the storage node A and the storage node B, and data redistribution is surely performed.
  • the data storage is affected by the storage node H and the storage node B.
  • the affected data range is the data to be migrated
  • the data to be migrated is the storage node A and the storage node H.
  • the state of the storage node H and the storage node B is set to be externally provideable services.
  • the hotspot data in the data to be migrated is migrated to the storage node H.
  • the states of the storage node H and the storage node B are set to be externally available services.
  • step 7 the background continues to migrate non-hotspot data to storage node H.
  • the embodiment of the present application further provides a device 400 for data redistribution, including: a first management unit 401, a recording unit 402, a migration unit 403, and a second management unit 404. among them:
  • the first management unit 401 is configured to: when the data redistribution needs to be performed, set the state of the current storage node of the data to be migrated and the target storage node of the data to be migrated to be externally provideable services;
  • the recording unit 402 is configured to record the usage heat of the data to be migrated when the current storage node provides a service to the external storage node;
  • the migrating unit 403 is configured to migrate, according to the usage heat of the data to be migrated recorded by the recording unit 402, the first group of data in the data to be migrated with a heat greater than a preset threshold to the target storage node;
  • the heat is used to characterize the number of times the data to be migrated is used;
  • a second management unit 404 configured to: after the migration unit 403 migrates the first group of data in the data to be migrated that uses the heat greater than a preset threshold to the target storage node, the current storage node and the The state of the target storage node is switched back to the externally available service to provide external services.
  • the recording unit 402 is specifically configured to:
  • the data storage model includes any one of a data table, a data page, and a data record; the one unit is a data table, a data page, or a data record.
  • the data redistribution device 400 further includes:
  • the setting unit 405 is configured to set N levels, N ⁇ 2, and N are positive integers for the usage heat of all units under the data model of the current storage node when the current storage node provides external service;
  • the usage heat corresponding to each unit is updated, and the updated usage heat is compared with the highest level value, and when the updated usage heat is greater than the highest level value, the highest level value is updated.
  • the heat of use for the update
  • the values of the (N-1) levels are sequentially updated according to the updated highest level value; or, the value of the highest level after the current update is further determined to be the highest before the current update. Whether the difference between the values of the levels is greater than the set difference threshold, and when it is determined that the difference between the value of the highest level after the current update and the value of the highest level before the current update is greater than the set difference threshold, The values of the (N-1) levels are sequentially updated.
  • the migration unit 403 is specifically configured to:
  • each selected unit Traversing each unit of data to be migrated under the data storage model, each selected unit, comparing the usage heat of the currently selected unit with the value of the nth level, if the current selection The unit's usage heat is greater than the value of the nth level, then the currently selected unit is migrated to the target storage node;
  • the preset threshold is a value of the nth rank of the N ranks, 1 ⁇ n ⁇ N, and n is a positive integer.
  • the migration unit 403 is further configured to:
  • the second set of data in the data to be migrated that uses heat not greater than a preset threshold is migrated to the target storage node.
  • the data redistribution device 400 further includes:
  • the routing unit 406 is configured to: when the migration unit 403 migrates the second group of data, when receiving the data access request, locate the target storage node according to the first routing manner; the first routing manner Routing method for performing the data redistribution; or
  • the second routing mode is used to perform the routing mode before the data redistribution.
  • a data processing unit 407 configured to: after the routing unit 406 locates the target storage node according to the first routing manner, if the access data related to the data access request exists in the target storage node, The access data stored in the target storage node is operated;
  • the routing unit locates the current storage node according to the second routing manner, the current storage node The access data stored in the operation operates.
  • the embodiment of the present application further provides a device 500 for redistributing terminal data, which is used to perform the data redistribution method provided by the foregoing embodiment of the present application, where the data is redistributed.
  • Apparatus 500 includes a memory 501 and a processor 502.
  • the memory 501 is configured to store a set of programs; the processor 502 is configured to invoke a program stored in the memory 501, so that the apparatus 500 for redistributing data can perform the embodiment of the present application.
  • the method of data redistribution provided above.
  • the data redistribution device 500 further includes a bus 503.
  • the transceiver 504, the memory 501, the processor 502 and the transceiver 504 are all connected to the bus 503.
  • the processor 502 can be a central processing unit (English: central processing unit, abbreviated: CPU), a network processor (English: network processor, abbreviated: NP) or a combination of a CPU and an NP.
  • CPU central processing unit
  • NP network processor
  • Processor 502 can also further include a hardware chip.
  • the hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (abbreviated as PLD), or a combination thereof.
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the above PLD can be a complex programmable logic device (English: complex programmable logic device, abbreviation: CPLD), field-programmable gate array (English: field-programmable gate array, abbreviation: FPGA), general array logic (English: generic array Logic, abbreviation: GAL) or any combination thereof.
  • the memory 501 may include a volatile memory (English: volatile memory), such as a random access memory (English: random-access memory, abbreviation: RAM); the memory 501 may also include a non-volatile memory (English: non-volatile memory) ), for example, flash memory (English: flash memory), hard disk (English: hard disk drive, abbreviated: HDD) or solid state drive (English: solid-state drive, abbreviation: SSD); the memory 501 may also include the above types of memory The combination.
  • a volatile memory English: volatile memory
  • RAM random access memory
  • non-volatile memory English: non-volatile memory
  • flash memory English: flash memory
  • hard disk English: hard disk drive, abbreviated: HDD
  • SSD solid state drive
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据重分布的方法及装置,涉及数据存储技术领域,该方法为:在对外提供服务期间时,统计数据的使用热度,在确定需要进行数据重分布时,暂停数据库服务器的对外服务,使业务暂时中断(201),将数据库服务器上的热点数据先进行迁移(202),在热点数据迁移完毕后,恢复数据库服务器的对外服务,在后台继续迁移非热点数据(203)。这样,大大缩小了数据重分布占用的时间,缩短了因数据重分布而业务中断的时间。

Description

一种数据重分布的方法及装置
本申请要求在2016年02月26日提交中国专利局、申请号为201610109478.7、发明名称为“一种数据重分布的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据存储技术领域,特别涉及一种数据重分布的方法及装置。
背景技术
随着大数据时代的到来,对于海量数据的存储处理越来越重要。目前,主要采用数据库集群来存储海量数据。所谓数据库集群,就是利用多台数据库服务器构成一个虚拟单一数据库逻辑映像,像单数据库服务器系统一样向客户端提供透明的数据服务。
数据库集群中的一台数据库服务器可以称为一个存储节点,数据库集群中有多个存储节点和一个数据管理节点,数据管理节点也可以和存储节点合设,通常按照一定的算法将数据块分散存储在各个存储节点上,常用的算法有哈希算法、轮转算法和随机算法等,在数据管理节点中存储所有存储节点中所有数据块的数据块标识及其对应的地址。
为应对业务弹性扩展的需求,数据库集群需要随时扩容。扩容时需要对原有的存储数据进行重分布,以充分利用新增的存储节点。数据重分布的过程需要按照最新的存储节点数量,采用一定的算法重新计算,部分数据会被迁移到新增的存储节点上。
目前的扩容技术大多是停机扩容,也就是在扩容时中断数据库集群的服务,使得业务中断。然而数据重分布的过程,大量数据的迁移需要花费很长时间,这样,造成了业务中断的时间较长。
发明内容
本申请实施例提供一种数据重分布的方法及装置,用以缩短数据重分布过程中业务中断的时间。
本申请实施例提供的具体技术方案如下:
第一方面,提供一种数据重分布的方法,包括:在确定需要进行数据重分布时,将待迁移数据的当前存储节点和所述待迁移数据的目标存储节点的状态均由可对外提供服务设置为不可对外提供服务;在所述当前存储节点为不可对外提供服务的状态下,基于在所述当前存储节点对外提供服务期间时所记录的所述待迁移数据的使用热度,将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点;所述使用热度用于表征所述待迁移数据被使用的次数;将所述当前存储节点和所述目标存储节点的状态由所述不可对外提供服务切换回可对外提供服务。
所述第一组数据可以称为热点数据,所述预设阈值为根据经验值设置的区分所述待迁移数据中热点数据和非热点数据的临界值。这样通过在存储节点停止服务时先迁移热点数据,一旦迁移完热点数据就将存储节点恢复服务,大大缩小了因数据重分布而影响业务中断的时间,有效提升了数据库集群的系统性能。
结合第一方面,在第一方面的第一种可能的实现方式中,在进行所述数据重分布之前,还包括:在所述当前存储节点对外提供服务期间时,对所述当前存储节点的数据存储模型 下的每一个单位分别记录一个使用热度;其中,在任意一个单位建立时,针对所述任意一个单位记录一个初始的使用热度,每当所述任意一个单位被使用一次时,更新所述任意一个单位对应的使用热度。
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述数据存储模型包括数据表、数据页、数据记录中的任意一种;所述一个单位为一张数据表、一张数据页或一条数据记录。
结合第一方面的第一种可能的实现方式,在第一方面的第三种可能的实现方式中,还包括:在所述当前存储节点对外提供服务期间时,针对所述当前存储节点的数据存储模型下的所有单位的使用热度设置N个等级,N≥2,N为正整数;将所述当前存储节点最后一次更新使用热度后所有所述单位的使用热度中的最高值,设置为所述N个等级中的最高等级的值;基于所述最高等级的值,按递减规则设置所述N个等级中除所述最高等级之外的(N-1)个等级的值;其中,每更新一个单位对应的使用热度,将更新的使用热度与所述最高等级的值相比较,在所述更新的使用热度大于所述最高等级的值时,将所述最高等级的值更新为所述更新的使用热度。
较佳的,进一步按照更新后的最高等级的值,将所述(N-1)个等级的值依次进行更新;或者,进一步判断本次更新后的最高等级的值与本次更新前的最高等级的值之间的差值是否大于设置的差值阈值,在判定本次更新后的最高等级的值与本次更新前的最高等级的值之间的差值大于设置的差值阈值时,将所述(N-1)个等级的值依次进行更新。
结合第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,所述预设阈值为所述N个等级中第n个等级的值,1≤n≤N,n为正整数;所述将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点,具体包括:遍历在所述数据存储模型下存储待迁移数据的每一个单位;其中,每选定一个单位,将当前选定的单位的使用热度与所述第n个等级的值进行比较;若所述当前选定的单位的使用热度大于所述第n个等级的值,则将所述当前选定的单位迁移到所述目标存储节点。
如第一方面所述,所述预设阈值为根据经验值设置的区分所述待迁移数据中热点数据和非热点数据的临界值,一般在数据库应用中,热点数据大概占所有数据的20%左右,因此,应用本申请中提供的方法,当选取的第n个等级的值可以实现使得上述第一组数据接近数据库应用中常规意义的热点数据时,就可以实现迁移热点数据占用的时间小于迁移所有数据占用的时间,从而节省了数据迁移所占用的时间。
结合第一方面和第一方面的第一种至第四种可能实现的方式,在第一方面的第五种可能的实现方式中,将所述当前存储节点和所述目标存储节点的状态由不可对外服务切换为可对外提供服务之后,还包括:在所述当前存储节点和所述目标存储节点的后台服务中,将所述待迁移数据中使用热度不大于预设阈值的第二组数据迁移到所述目标存储节点。
所述第二组数据也可以称为非热点数据,由于在存储节点恢复使用后的一段时间内接收到的数据访问请求大多数为热点数据的访问请求,因此,将存储节点设置为可对外提供服务之后,在后台继续迁移非热点数据,可以有效减小因迁移数据对数据库的正常服务带来的影响。
结合第一方面的第五种可能的实现方式,在第一方面的第六种可能的实现方式中,还包括:在迁移所述第二组数据的过程中,在接收到数据访问请求时,按照第一路由方式定位到所述目标存储节点;所述第一路由方式为进行所述数据重分布之后的路由方式;若所 述目标存储节点中存在所述数据访问请求涉及的访问数据,则对所述目标存储节点中存储的所述访问数据进行操作;若所述目标存储节点中不存在所述数据访问请求涉及的所述访问数据,则,按照第二路由方式定位到所述当前存储节点,对所述当前存储节点中存储的所述访问数据进行操作;所述第二路由方式为进行所述数据重分布之后的路由方式。
如上所述,由于在存储节点恢复使用后的一段时间内接收到的数据访问请求大多数为热点数据的访问请求,因此,采用上述方法,可以减小在接收到访问请求后访问失败的几率。
第二方面,提供一种数据重分布的装置,该数据重分布的装置具有实现上述第一方面和第一方面的第一种至第六种可能的实现方式中的任一种方法设计的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。
第三方面,提供一种数据重分布的装置,包括存储器和处理器,其中,所述存储器用于存储一组程序,所述处理器用于调用所述存储器存储的程序以执行如上述第一方面和第一方面的第一种至第六种可能的实现方式中的任一种所述的方法。
第四方面,提供了一种计算机存储介质,用于储存为上述第二方面或第三方面所述的数据重分布装置所用的计算机软件指令,其包含用于执行上述方面所设计的程序。
本申请提供的方案,能够缩短在数据重分布过程中业务中断的时间,提高数据库服务器集群的系统性能。
附图说明
图1为本申请实施例中数据重分布的系统架构图;
图2为本申请实施例中数据重分布的方法流程图;
图3a和图3b为本申请实施例中一种应用场景下数据重分布的示意图;
图4为本申请实施例中数据重分布的装置结构图之一;
图5为本申请实施例中数据重分布的装置结构图之二。
具体实施方式
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
本申请实施例任意存储系统,较佳的可以应用于分布式存储系统,例如数据库集群。参阅图1所示,分布式存储系统中有多个存储节点和一个数据管理节点,数据管理节点也可以和存储节点合设,例如一个存储节点可以是一个数据库服务器。本申请实施例以应用于数据库集群为例进行介绍,以下叙述中,一个存储节点在概念上可以等同于一个数据库服务器。
为了缩短在数据重分布过程中业务中断的时间,提高数据库服务器集群的系统性能,本申请实施例提供了一种数据重分布的方法,在存储节点对外提供服务期间时,统计数据的使用热度,在确定需要进行数据重分布时,暂停对外提供服务,也就是使业务暂时中断,将数据库服务器上的热点数据先进行迁移,在热点数据迁移完毕后,恢复数据库服务器的 对外服务,在后台继续迁移非热点数据。本申请中,用迁移部分数据替换迁移全部数据,在一定程度上减少了迁移数据的时间,缩短了业务中断的时间,又因为在数据重分布以后的一段时间内,热点数据的访问几率远远大于非热点数据的访问几率,因此,可以减小因迁移数据对数据库的正常服务带来的影响。
以下将结合附图对本申请优选的实施例进行详细介绍。
参阅图2所示,本申请实施例中,数据重分布的具体流程如下。执行以下数据重分步方法的执行主体可以是待迁移数据的当前存储节点,也可以是数据重分布系统中的数据管理节点。
在201部分,在确定需要进行数据重分布时,将待迁移数据的当前存储节点和所述待迁移数据的目标存储节点的状态均由可对外提供服务设置为不可对外提供服务,即设置为不可用。
其中,所述当前存储节点为所述待迁移数据所在的存储节点。存储节点有两种工作状态,可对外提供服务和不可对外提供服务,其中,可对外提供服务可以理解为存储节点上的数据可读且可写,不可对外提供服务可以理解为不可读且不可写,或者只读。
数据库集群在进行扩容时,会在原数据库集群中添加新的存储节点(即数据库服务器),在原数据库集群中的存储节点上存储的数据可能会有一部分被迁移到新的存储节点上,以充分利用新的存储节点的存储能力,这种数据迁移的过程也就是数据重分布的过程。另外,数据库集群在删除存储节点时,同样也会涉及数据重分布的过程。
确定需要进行数据重分布时,可以获得受影响的存储节点和受影响的数据,需要先将受影响的存储节点暂停对外提供服务(也就是设置为不可对外提供服务),以避免在数据迁移过程中出现数据访问错误等问题。
在202部分,在所述当前存储节点为不可对外提供服务的状态下,基于在所述当前存储节点可对外提供服务期间所记录的所述待迁移数据的使用热度,将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点。
其中,所述使用热度用于表征所述待迁移数据被使用的次数,被使用的情况包括:增加数据、删除数据、修改数据、查询数据等。
所述预设阈值为根据经验值设置的区分所述待迁移数据中热点数据和非热点数据的临界值。一般来说,热点数据占整个待迁移数据的20%左右,因此,所述预设阈值可根据经验值进行设定,并可在使用过程中不断更新优化。
在203部分,在迁移完所述第一组数据后,将所述当前存储节点和所述目标存储节点的状态由所述不可对外提供服务切换回可对外提供服务。并且,在后台继续将所述待迁移数据中使用热度不大于预设阈值的第二组数据迁移到所述目标存储节点。
实际应用中,为了方便对数据进行管理和操作,数据库中的数据可以以多层逻辑上的数据存储模型进行存储,例如,数据存储模型至少可以包括数据表、数据页和数据记录三个逻辑概念。一个存储节点中存储的数据可以分为多个数据表,每一张数据表中包含多个数据页,每一张数据页中包含多条数据记录。数据存储模型下的一个单位可以为一张数据表、一张数据页或者一条数据记录。
下面将结合上述201部分~203部分,具体介绍本申请实施例中的数据重分布的实现方式。
第一部分,在数据迁移之前,在上述当前存储节点的对外提供服务期间时,记录该存 储节点的数据的使用热度,以及针对该存储节点的数据的使用热度设置等级。
其一,记录上述当前存储节点的数据的使用热度的具体方式如下所述。
在上述当前存储节点对外提供服务期间时,对该存储节点的数据存储模型下的每一个单位分别记录一个使用热度,其中,在任意一个单位建立时,针对所述任意一个单位记录一个初始的使用热度,每当所述任意一个单位被使用一次时,将所述任意一个单位对应的使用热度进行更新。
其中,本申请实施例中,数据库集群中包含多个存储节点,在任意一个存储节点对外提供服务期间的过程中,对任意一个存储节点数据存储模型下的每一个单位分别记录其对应的数据的使用热度情况。记录方式与上述当前存储节点中的记录方式相同,本申请仅以上述当前存储节点为例进行介绍。
以数据存储模型为数据表为例,上述当前存储节点中包含m张数据表,假设用T1、T2、……、Tm表示,在该存储节点对外提供服务期间时,为每一张数据表对应的记录一个使用热度。
其中,在m张数据表中的任意一张数据表(例如T1)初始创建时,记录使用热度的初始值为0或者1;
当每针对数据表T1执行一次操作(例如增加、删除、改动、查询等操作),在现有的使用热度的值的基础上增加1。
其中,使用热度的记录的实现过程,可以但不限于采用在每一个数据表的表头增加一个使用热度(即hits)字段,通过hits字段来实现热度值的记录。
例如,在第一时刻针对上述当前存储节点中数据表的使用热度的记录情况如表1所示,数据表T1的使用热度为10000,数据表T2的使用热度为9800,数据表T3的使用热度为3400,……,数据表Tm的使用热度为1600。
表1
数据表 使用热度
T1 10000
T2 9800
T3 3400
…… ……
Tm 1600
数据存储模型为数据页或数据记录的使用热度的记录原理与数据表相同,重复之处不再赘述。本申请实施例中,可以选择为每一种数据存储模型下的单位维护对应的数据使用热度,当前,也可以选择其中一个或多个。
其二,针对上述当前存储节点的数据的使用热度设置等级的具体方式如下所述。
在上述当前存储节点对外提供服务期间时,针对该存储节点的数据存储模型下的所有单位的使用热度设置N个等级,N≥2,N为正整数;例如,N=10。
将记录的该存储节点的数据存储模型下的所有单位的使用热度中的最高值,设置为所述N个等级中的最高等级的值;
基于所述最高等级的值,按递减规则设置所述N个等级中除所述最高等级之外的(N-1)个等级的值;
其中,每更新一个单位对应的使用热度,将更新的使用热度与所述最高等级的值相比较,在所述更新的使用热度大于所述最高等级的值时,将所述最高等级的值更新为所述更新的使用热度。
较佳的,进一步按照更新后的最高等级的值,将所述(N-1)个等级的值依次进行更新;或者,进一步判断本次更新后的最高等级的值与本次更新前的最高等级的值之间的差值是否大于设置的差值阈值,在判定本次更新后的最高等级的值与本次更新前的最高等级的值之间的差值大于设置的差值阈值时,将所述(N-1)个等级的值依次进行更新。
例如,仍以数据存储模型为数据表为例,在上述第一时刻,上述当前存储节点中数据表的使用热度的记录情况如表1所示,由表1可知,数据表T1的使用热度为上述当前存储节点中所有数据表的使用热度中的最高值,为10000,则如表2所示,将N=10个等级中的最高等级(例如L10)设置为10000,则按照递减规则依次设置等级Lh的值,使得L10~L1的值呈现规律的递减模式,或者呈现其他有规律的模式,其中h为1-9,h为正整数。
Lh的值的设置方式可以采用但不限于Lh=h*N/10+N%10,其中,%为取余运算。例如,采取这种设置方式,则L9=9*10000/10+10000%10=9000;依次地,L8=8000;L7=7000;……;L1=1000。
表2
L1 L2 L3 L4 L5 L6 L7 L8 L9 L10
1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
假设在第二时刻,数据表T1的使用热度更新为10001,则如表3所示,将10001与最高等级的值10000进行比较,显然,将最高等级L10的值更新为10001,依次将L9~L1的值更新为9001、8001、……、1001。
表3
L1 L2 L3 L4 L5 L6 L7 L8 L9 L10
1001 2001 3001 4001 5001 6001 7001 8001 9001 10001
第二部分、确定需要迁移数据时,将当前存储节点和目标存储节点的状态由可对外提供服务切换回不可对外提供服务后,将当前存储节点上的待迁移数据中使用热度大于预设阈值的第一组数据迁移到目标存储节点,然后恢复当前存储节点和目标存储节点的正常使用,并后台继续迁移当前存储节点上的待迁移数据中除第一组数据之外的第二组数据。
其中,当前存储节点和目标存储节点为数据重分布受影响的存储节点,当然,受影响的存储节点可以是一个,也可以是多个,本申请实施例以在数据重分布时,受影响的存储节点为一个当前存储节点和一个目标存储节点为例介绍的,当然多个受影响存储节点的方法是相同的。
这部分是本申请实施例中的核心部分,主要思想是先迁移热点数据,再后台迁移非热点数据,由于一般情况下,一个存储节点中的热点数据与非热点数据的比例大概为2:8,因此,在存储节点不可用时,只迁移热点数据,会大大缩短存储节点的不可用时间,也就减少了业务中断的时间,提升了系统的性能。
所述热点数据和非热点数据的辨别方式可以利用本申请上述提供的在存储节点对外 提供服务期间时统计的数据使用热度,以及对数据的使用热度设置的等级来判断,具体地判断方式如下所述。
在确定当前存储节点中有数据需要迁移到目标存储节点时,遍历待迁移数据在存储模型下的每一个单位;其中,
每选定一个单位,将当前选定的单位的使用热度与所述第n个等级的值进行比较;
若所述当前选定的单位的使用热度大于所述第n个等级的值,则将所述当前选定的单位迁移到所述目标存储节点;
其中,所述预设阈值为所述N个等级中第n个等级的值,1≤n≤N,n为正整数。
其中,可以选择先比较再迁移的策略,即先将每一个单位的使用热度与所述第n个等级的值进行比较,在执行完所有单位的比较之后,筛选出使用热度大于所述第n个等级的值的单位进行迁移;也可以选择逐个比较逐个迁移的策略,即每比较一个单位,在所比较的单位的使用热度大于所述第n个等级的值时,将这个单位迁移到所述目标存储节点。
具体地,仍以存储模型为数据表为例,首先确定迁移的预设阈值,例如,将上述第一时刻的10个等级中第8个等级的值设置为预设阈值,也就是预设阈值为8000。预设阈值的选择可以根据经验不断的更新优化。
遍历待迁移数据中的每一张数据表,每选定一张数据表,获取选定的这张数据表的使用热度,并将这张数据表的使用热度与预设阈值进行比较,若大于预设阈值,则将这张数据表迁移到目标存储节点,若小于,则继续遍历下一张数据表,直到遍历所有数据表,就可以将待迁移数据中使用热度大于预设阈值的所有数据表迁移完毕。然后,在后台继续迁移未迁移的第二组数据。
例如,遍历到数据表T2,获取数据表T2的使用热度为9800,判断数据表T2的使用热度大于预设阈值8000,则将数据表T2迁移到目标存储节点;
遍历到数据表T3,获取数据表T3的使用热度为3400,判断数据表T3的使用热度小于预设阈值8000,则略过数据表T3,继续遍历数据表T4。
其中,在迁移所述第二组数据的过程中,在接收到数据访问请求时,按照第一路由方式定位到目标存储节点;所述第一路由方式为进行数据重分布之后的路由方式;
若目标存储节点中存在该数据访问请求涉及的访问数据,则对目标存储节点中存储的该访问数据进行操作;
若目标存储节点中不存在该数据访问请求涉及的访问数据,则,
按照第二路由方式定位到上述当前存储节点,对上述当前存储节点中存储的该访问数据进行操作;所述第二路由方式为进行数据重分布之前的路由方式。
其中,上述路由方式为确定将数据访问请求对应的访问数据定位到存储节点的路径的方法,可以采取现有技术中的任意一种路由方式,本申请不作限制。
本申请之所以这样设计,是因为,在热点数据迁移完毕,将存储节点设置为可对外提供服务,在之后接收到的数据访问请求大部分是访问热点数据,因此,首先按照数据重分布之后的新路由方式路由到目标存储节点,能够访问到热点数据的几率非常大。若目标存储节点中不存在访问数据,则再按照数据重分布之前的旧路由方式路由到原来的存储节点。之后还会存在两种情况,若访问数据在原来的存储节点上,则对访问数据进行操作;若访问数据不在原来的存储节点上,则访问失败。如此以来,访问失败的几率将会非常小。
下面结合具体的应用场景,对本申请实施例作进一步详细的说明。
假设本申请实施例中,采用一致性哈希算法将数据分散在各个存储节点,一致性哈希算法与现有技术相同,本申请实施例中不再赘述。
如图3a所示,圆环上的小圆圈代表存储节点,按照现有的一致性哈希算法,存储节点B中存储的数据包括key值映射到存储节点A和存储节点B之间的弧形区域的数据。
具体地,第1步,需要对数据进行操作时,对数据采用哈希函数计算出key值;
第2步,将key值映射到顺时针方向的第一个存储节点上,也就是存储节点B上;
那么,在存储节点B上相应的数据存储模型的单位上,将使用热度的值加1。例如,将对应的数据表的使用热度的值加1。接着,将执行加1计算之后的对应的数据表的使用热度值与存储节点B上数据表的最高等级的值进行比较,在大于最高等级的值时,将最高等级的值按照执行加1计算之后的对应的数据表的使用热度值进行更新,并依次更新其他等级的值。
如图3b所示,第3步,在图3a中存储节点的分布基础上加入了存储节点H,具体加在了存储节点A和存储节点B之间,那么必定会进行数据重分布。按照现有的一致性哈希的算法,数据重分布受影响的存储节点为存储节点H和存储节点B,受影响的数据范围为待迁移数据,待迁移数据为存储节点A和存储节点H之间的弧形区域。
第4步,在存储节点H加入之后,将存储节点H和存储节点B的状态由可对外提供服务设置为不可对外提供服务。
第5步,将待迁移数据中的热点数据迁移至存储节点H。
具体迁移方法与上述实施例中叙述的一致,重复之处不再赘述。
第6步,将存储节点H和存储节点B的状态由不可对外提供服务设置为可对外提供服务。
第7步,后台继续迁移非热点数据至存储节点H。
基于同一发明构思,如图4所示,本申请实施例还提供了一种数据重分布的装置400,包括:第一管理单元401,记录单元402,迁移单元403和第二管理单元404。其中:
第一管理单元401,用于在确定需要进行数据重分布时,将待迁移数据的当前存储节点和所述待迁移数据的目标存储节点的状态均由可对外提供服务设置为不可对外提供服务;
记录单元402,用于在所述当前存储节点对外提供服务期间时记录所述待迁移数据的使用热度;
迁移单元403,用于基于记录单元402记录的所述待迁移数据的使用热度,将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点;所述使用热度用于表征所述待迁移数据被使用的次数;
第二管理单元404,用于在所述迁移单元403将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点之后,将所述当前存储节点和所述目标存储节点的状态由所述不可对外提供服务切换回可对外提供服务。
可选的,所述记录单元402具体用于:
在所述当前存储节点对外提供服务期间时,对所述当前存储节点的数据存储模型下的每一个单位分别记录一个使用热度;
其中,在任意一个单位建立时,针对所述任意一个单位记录一个初始的使用热度,每当所述任意一个单位被使用一次时,更新所述任意一个单位对应的使用热度。
可选的,所述数据存储模型包括数据表、数据页、数据记录中的任意一种;所述一个单位为一张数据表、一张数据页或一条数据记录。
可选的,数据重分布的装置400还包括:
设置单元405,用于在所述当前存储节点对外提供服务期间时,针对所述当前存储节点的数据模型下的所有单位的使用热度设置N个等级,N≥2,N为正整数;以及,
将所述当前存储节点最后一次更新使用热度后所有所述单位的使用热度中的最高值,设置为所述N个等级中的最高等级的值;以及,
基于所述最高等级的值,按递减规则设置所述N个等级中除所述最高等级之外的(N-1)个等级的值;
其中,每更新一个单位对应的使用热度,将更新的使用热度与所述最高等级的值相比较,在所述更新的使用热度大于所述最高等级的值时,将所述最高等级的值更新为所述更新的使用热度;
较佳的,进一步按照更新后的最高等级的值,将所述(N-1)个等级的值依次进行更新;或者,进一步判断本次更新后的最高等级的值与本次更新前的最高等级的值之间的差值是否大于设置的差值阈值,在判定本次更新后的最高等级的值与本次更新前的最高等级的值之间的差值大于设置的差值阈值时,将所述(N-1)个等级的值依次进行更新。
可选的,所述迁移单元403具体用于:
遍历在所述数据存储模型下存储待迁移数据的每一个单位,每选定一个单位,将当前选定的单位的使用热度与所述第n个等级的值进行比较,若所述当前选定的单位的使用热度大于所述第n个等级的值,则将所述当前选定的单位迁移到所述目标存储节点;
其中,所述预设阈值为所述N个等级中第n个等级的值,1≤n≤N,n为正整数。
可选的,所述迁移单元403还用于:
在所述当前存储节点和所述目标存储节点的后台服务中,将所述待迁移数据中使用热度不大于预设阈值的第二组数据迁移到所述目标存储节点。
可选的,数据重分布的装置400还包括:
路由单元406,用于在所述迁移单元403迁移所述第二组数据的过程中,在接收到数据访问请求时,按照第一路由方式定位到所述目标存储节点;所述第一路由方式为进行所述数据重分布之后的路由方式;或者,
按照第二路由方式定位到所述当前存储节点,所述第二路由方式为进行所述数据重分布之前的路由方式。
数据处理单元407,用于在所述路由单元406按照所述第一路由方式定位到所述目标存储节点之后,若所述目标存储节点中存在所述数据访问请求涉及的访问数据,则对所述目标存储节点中存储的所述访问数据进行操作;
若所述目标存储节点中不存在所述数据访问请求涉及的所述访问数据,则,在所述路由单元按照所述第二路由方式定位到所述当前存储节点之后,对所述当前存储节点中存储的所述访问数据进行操作。
基于同一发明构思,如图5所示,本申请实施例还提供了一种终端数据重分布的装置500,用于执行本申请实施例上述提供的数据重分布的方法,所述数据重分布的装置500包括存储器501和处理器502。其中,存储器501,用于存储一组程序;所述处理器502用于调用存储器501存储的程序,使得所述数据重分布的装置500可以执行本申请实施例 上述提供的数据重分布的方法。
较佳的,数据重分布的装置500还包括总线503,收发器504,存储器501、处理器502和收发器504均与总线503连接,
处理器502可以是中央处理器(英文:central processing unit,缩写:CPU),网络处理器(英文:network processor,缩写:NP)或者CPU和NP的组合。
处理器502还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(英文:application-specific integrated circuit,缩写:ASIC),可编程逻辑器件(英文:programmable logic device,缩写:PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(英文:complex programmable logic device,缩写:CPLD),现场可编程逻辑门阵列(英文:field-programmable gate array,缩写:FPGA),通用阵列逻辑(英文:generic array logic,缩写:GAL)或其任意组合。
存储器501可以包括易失性存储器(英文:volatile memory),例如随机存取存储器(英文:random-access memory,缩写:RAM);存储器501也可以包括非易失性存储器(英文:non-volatile memory),例如快闪存储器(英文:flash memory),硬盘(英文:hard disk drive,缩写:HDD)或固态硬盘(英文:solid-state drive,缩写:SSD);存储器501还可以包括上述种类的存储器的组合。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。
显然,本领域的技术人员可以对本申请实施例进行各种改动和变型而不脱离本申请实 施例的精神和范围。这样,倘若本申请实施例的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (14)

  1. 一种数据重分布的方法,其特征在于,包括:
    在确定需要进行数据重分布时,将待迁移数据的当前存储节点和所述待迁移数据的目标存储节点的状态均由可对外提供服务设置为不可对外提供服务;
    在所述当前存储节点为不可对外提供服务的状态下,基于在所述当前存储节点对外提供服务期间所记录的所述待迁移数据的使用热度,将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点,所述使用热度用于表征所述待迁移数据被使用的次数;
    将所述当前存储节点和所述目标存储节点的状态由所述不可对外提供服务切换回可对外提供服务。
  2. 如权利要求1所述的方法,其特征在于,在进行所述数据重分布之前,还包括:
    在所述当前存储节点对外提供服务期间,对所述当前存储节点的数据存储模型下的每一个单位分别记录一个使用热度;
    其中,在任意一个单位建立时,针对所述任意一个单位记录一个初始的使用热度,每当所述任意一个单位被使用一次时,更新所述任意一个单位对应的使用热度。
  3. 如权利要求2所述的方法,其特征在于,所述数据存储模型包括数据表、数据页、数据记录中的任意一种;所述一个单位为一张数据表、一张数据页或一条数据记录。
  4. 如权利要求2所述的方法,其特征在于,还包括:
    在所述当前存储节点对外提供服务期间,针对所述当前存储节点的数据存储模型下的所有单位的使用热度设置N个等级,N≥2,N为正整数;
    将所述当前存储节点最后一次更新使用热度后所有所述单位的使用热度中的最高值,设置为所述N个等级中的最高等级的值;
    基于所述最高等级的值,按递减规则设置所述N个等级中除所述最高等级之外的(N-1)个等级的值;
    其中,每更新一个单位对应的使用热度,将更新的使用热度与所述最高等级的值相比较,在所述更新的使用热度大于所述最高等级的值时,将所述最高等级的值更新为所述更新的使用热度。
  5. 如权利要求4所述的方法,其特征在于,所述预设阈值为所述N个等级中第n个等级的值,1≤n≤N,n为正整数;
    所述将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点,具体包括:
    遍历在所述数据存储模型下存储待迁移数据的每一个单位;其中,
    每选定一个单位,将当前选定的单位的使用热度与所述第n个等级的值进行比较;
    若所述当前选定的单位的使用热度大于所述第n个等级的值,则将所述当前选定的单位迁移到所述目标存储节点。
  6. 如权利要求1-5任一项所述的方法,其特征在于,将所述当前存储节点和所述目标存储节点的状态由不可对外提供服务切换回可对外提供服务之后,还包括:
    在所述当前存储节点和所述目标存储节点的后台服务中,将所述待迁移数据中使用热度不大于预设阈值的第二组数据迁移到所述目标存储节点。
  7. 如权利要求6所述的方法,其特征在于,还包括:
    在迁移所述第二组数据的过程中,在接收到数据访问请求时,按照第一路由方式定位到所述目标存储节点;所述第一路由方式为进行所述数据重分布之后的路由方式;
    若所述目标存储节点中存在所述数据访问请求涉及的访问数据,则对所述目标存储节点中存储的所述访问数据进行操作;
    若所述目标存储节点中不存在所述数据访问请求涉及的所述访问数据,则,
    按照第二路由方式定位到所述当前存储节点,对所述当前存储节点中存储的所述访问数据进行操作;所述第二路由方式为进行所述数据重分布之后的路由方式。
  8. 一种数据重分布的装置,其特征在于,包括:
    第一管理单元,用于在确定需要进行数据重分布时,将待迁移数据的当前存储节点和所述待迁移数据的目标存储节点的状态均由可对外提供服务设置为不可对外提供服务;
    记录单元,用于在所述当前存储节点对外提供服务期间记录所述待迁移数据的使用热度;
    迁移单元,用于在所述当前存储节点为不可对外提供服务的状态下,基于记录单元记录的所述待迁移数据的使用热度,将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点;所述使用热度用于表征所述待迁移数据被使用的次数;
    第二管理单元,用于在所述迁移单元将所述待迁移数据中使用热度大于预设阈值的第一组数据迁移到所述目标存储节点之后,将所述当前存储节点和所述目标存储节点的状态由所述不可对外提供服务切换回可对外提供服务。
  9. 如权利要求8所述的装置,其特征在于,所述记录单元具体用于:
    在所述当前存储节点对外提供服务期间时,对所述当前存储节点的数据存储模型下的每一个单位分别记录一个使用热度;
    其中,在任意一个单位建立时,针对所述任意一个单位记录一个初始的使用热度,每当所述任意一个单位被使用一次时,更新所述任意一个单位对应的使用热度。
  10. 如权利要求9所述的装置,其特征在于,还包括:
    设置单元,用于在所述当前存储节点对外提供服务期间时,针对所述当前存储节点的数据模型下的所有单位的使用热度设置N个等级,N≥2,N为正整数;以及,
    将所述当前存储节点最后一次更新使用热度后所有所述单位的使用热度中的最高值,设置为所述N个等级中的最高等级的值;以及,
    基于所述最高等级的值,按递减规则设置所述N个等级中除所述最高等级之外的(N-1)个等级的值;
    其中,每更新一个单位对应的使用热度,将更新的使用热度与所述最高等级的值相比较,在所述更新的使用热度大于所述最高等级的值时,将所述最高等级的值更新为所述更新的使用热度。
  11. 如权利要求10所述的装置,其特征在于,所述迁移单元具体用于:
    遍历在所述数据存储模型下存储待迁移数据的每一个单位,每选定一个单位,将当前选定的单位的使用热度与所述第n个等级的值进行比较,若所述当前选定的单位的使用热度大于所述第n个等级的值,则将所述当前选定的单位迁移到所述目标存储节点;
    其中,所述预设阈值为所述N个等级中第n个等级的值,1≤n≤N,n为正整数。
  12. 如权利要求8-11任一项所述的装置,其特征在于,所述迁移单元还用于:
    在所述当前存储节点和所述目标存储节点的后台服务中,将所述待迁移数据中使用热度不大于预设阈值的第二组数据迁移到所述目标存储节点。
  13. 如权利要求12所述的装置,其特征在于,还包括:
    路由单元,用于在所述迁移单元迁移所述第二组数据的过程中,在接收到数据访问请求时,按照第一路由方式定位到所述目标存储节点;所述第一路由方式为进行所述数据重分布之后的路由方式;或者,
    按照第二路由方式定位到所述当前存储节点,所述第二路由方式为进行所述数据重分布之前的路由方式;
    数据处理单元,用于在所述路由单元按照所述第一路由方式定位到所述目标存储节点之后,若所述目标存储节点中存在所述数据访问请求涉及的访问数据,则对所述目标存储节点中存储的所述访问数据进行操作;
    若所述目标存储节点中不存在所述数据访问请求涉及的所述访问数据,则,在所述路由单元按照所述第二路由方式定位到所述当前存储节点之后,对所述当前存储节点中存储的所述访问数据进行操作。
  14. 一种数据重分布的装置,其特征在于,包括处理器和存储器,其中,所述存储器中存储一组程序,所述处理器用于调用所述存储器中存储的程序,使得所述数据重分布的装置执行如权利要求1-7任一项所述的方法。
PCT/CN2017/074121 2016-02-26 2017-02-20 一种数据重分布的方法及装置 WO2017143957A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610109478.7A CN107133228A (zh) 2016-02-26 2016-02-26 一种数据重分布的方法及装置
CN201610109478.7 2016-02-26

Publications (1)

Publication Number Publication Date
WO2017143957A1 true WO2017143957A1 (zh) 2017-08-31

Family

ID=59685809

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/074121 WO2017143957A1 (zh) 2016-02-26 2017-02-20 一种数据重分布的方法及装置

Country Status (2)

Country Link
CN (1) CN107133228A (zh)
WO (1) WO2017143957A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111881210A (zh) * 2020-06-29 2020-11-03 平安国际智慧城市科技股份有限公司 数据同步方法、装置、内网服务器及介质
CN112597231A (zh) * 2020-12-28 2021-04-02 中国农业银行股份有限公司 一种数据处理方法和装置
CN112835887A (zh) * 2019-11-25 2021-05-25 航天信息股份有限公司 数据库管理方法、装置、计算设备和存储介质
CN112988046A (zh) * 2019-12-17 2021-06-18 爱思开海力士有限公司 存储系统、其存储装置及其操作方法
CN117149915A (zh) * 2023-10-31 2023-12-01 湖南三湘银行股份有限公司 用于云端数据库迁移到开源数据库的方法

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704212B (zh) * 2017-10-31 2019-09-06 新华三信息技术有限公司 一种数据处理方法及装置
CN110275873A (zh) * 2019-06-28 2019-09-24 重庆紫光华山智安科技有限公司 文件存储方法、装置、存储管理设备及存储介质
CN112583864B (zh) * 2019-09-27 2023-04-28 中国移动通信集团广东有限公司 一种数据迁移方法及装置
CN113687798A (zh) * 2021-10-26 2021-11-23 苏州浪潮智能科技有限公司 一种控制数据重构的方法、装置、设备及可读介质

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100131728A1 (en) * 2008-11-21 2010-05-27 Fujitsu Limited Computer-readable recording medium storing data migration program, data migration method, and data migration apparatus
CN102055650A (zh) * 2009-10-29 2011-05-11 华为技术有限公司 负载均衡方法及系统和管理服务器
CN102122303A (zh) * 2011-03-15 2011-07-13 浪潮(北京)电子信息产业有限公司 一种进行数据迁移的方法及服务系统及服务器设备
CN102855299A (zh) * 2012-08-16 2013-01-02 上海引跑信息科技有限公司 不中断服务条件下,分布式数据库迭代迁移的方法
CN103164167A (zh) * 2011-12-15 2013-06-19 深圳市腾讯计算机系统有限公司 一种数据迁移方法及装置
CN103530290A (zh) * 2012-07-03 2014-01-22 深圳市腾讯计算机系统有限公司 数据库间的数据迁移方法和系统
CN104573119A (zh) * 2015-02-05 2015-04-29 重庆大学 云计算中面向节能的Hadoop分布式文件系统存储策略
CN104598495A (zh) * 2013-10-31 2015-05-06 南京中兴新软件有限责任公司 基于分布式文件系统的分级存储方法及系统

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4693540B2 (ja) * 2005-08-04 2011-06-01 富士通株式会社 データベース再構成装置、およびデータベース再構成プログラム
US8560792B2 (en) * 2010-12-16 2013-10-15 International Business Machines Corporation Synchronous extent migration protocol for paired storage
CN102902628B (zh) * 2012-09-18 2016-06-01 记忆科技(深圳)有限公司 一种基于闪存实现的冷热数据自动分离方法、系统及闪存
CN103914458A (zh) * 2012-12-29 2014-07-09 中国移动通信集团河北有限公司 一种海量数据迁移的方法及装置
CN104881443B (zh) * 2015-05-14 2018-11-27 新浪网技术(中国)有限公司 一种在数据库间迁移数据的方法和系统

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100131728A1 (en) * 2008-11-21 2010-05-27 Fujitsu Limited Computer-readable recording medium storing data migration program, data migration method, and data migration apparatus
CN102055650A (zh) * 2009-10-29 2011-05-11 华为技术有限公司 负载均衡方法及系统和管理服务器
CN102122303A (zh) * 2011-03-15 2011-07-13 浪潮(北京)电子信息产业有限公司 一种进行数据迁移的方法及服务系统及服务器设备
CN103164167A (zh) * 2011-12-15 2013-06-19 深圳市腾讯计算机系统有限公司 一种数据迁移方法及装置
CN103530290A (zh) * 2012-07-03 2014-01-22 深圳市腾讯计算机系统有限公司 数据库间的数据迁移方法和系统
CN102855299A (zh) * 2012-08-16 2013-01-02 上海引跑信息科技有限公司 不中断服务条件下,分布式数据库迭代迁移的方法
CN104598495A (zh) * 2013-10-31 2015-05-06 南京中兴新软件有限责任公司 基于分布式文件系统的分级存储方法及系统
CN104573119A (zh) * 2015-02-05 2015-04-29 重庆大学 云计算中面向节能的Hadoop分布式文件系统存储策略

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112835887A (zh) * 2019-11-25 2021-05-25 航天信息股份有限公司 数据库管理方法、装置、计算设备和存储介质
CN112988046A (zh) * 2019-12-17 2021-06-18 爱思开海力士有限公司 存储系统、其存储装置及其操作方法
CN111881210A (zh) * 2020-06-29 2020-11-03 平安国际智慧城市科技股份有限公司 数据同步方法、装置、内网服务器及介质
CN111881210B (zh) * 2020-06-29 2022-08-26 平安国际智慧城市科技股份有限公司 数据同步方法、装置、内网服务器及介质
CN112597231A (zh) * 2020-12-28 2021-04-02 中国农业银行股份有限公司 一种数据处理方法和装置
CN117149915A (zh) * 2023-10-31 2023-12-01 湖南三湘银行股份有限公司 用于云端数据库迁移到开源数据库的方法
CN117149915B (zh) * 2023-10-31 2024-03-29 湖南三湘银行股份有限公司 用于云端数据库迁移到开源数据库的方法

Also Published As

Publication number Publication date
CN107133228A (zh) 2017-09-05

Similar Documents

Publication Publication Date Title
WO2017143957A1 (zh) 一种数据重分布的方法及装置
CN108810041B (zh) 一种分布式缓存系统的数据写入及扩容方法、装置
CN108132949B (zh) 数据库集群中数据迁移的方法及装置
US20180293018A1 (en) Policy-based hierarchical data protection in distributed storage
CN103354923B (zh) 一种数据重建方法、装置和系统
CN109597567B (zh) 一种数据处理方法和装置
US9053166B2 (en) Dynamically varying the number of database replicas
CN104580439B (zh) 一种云存储系统中使数据均匀分布的方法
US10628050B2 (en) Data processing method and apparatus
US10789113B2 (en) Data storage system durability using hardware failure risk indicators
CN112799841B (zh) 一种数据对象存储管理的方法和装置
CN108540315A (zh) 分布式存储系统、方法和装置
US11442827B2 (en) Policy-based hierarchical data protection in distributed storage
CN103631894A (zh) 一种基于hdfs的动态副本管理方法
CN107391033B (zh) 数据迁移方法及装置、计算设备、计算机存储介质
CN104702691B (zh) 分布式负载均衡方法和装置
CN111475483A (zh) 数据库迁移方法、装置及计算设备
WO2020133963A1 (zh) 基于区块链的数据存储方法、相关设备及存储介质
CN106534308A (zh) 一种分布式存储系统中解决数据块访问热点的方法及装置
CN111488987B (zh) 一种深度学习大模型训练的方法、系统、设备及介质
CN106973091B (zh) 分布式内存数据重分布方法及系统、主控服务器
CN107920101A (zh) 一种文件访问方法、装置、系统及电子设备
CN106547477A (zh) 用于在线地减少缓存设备的方法和装置
JP7398567B2 (ja) 動的適応型パーティション分割
CN115826876B (zh) 数据写入方法、系统、存储硬盘、电子设备及存储介质

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17755786

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17755786

Country of ref document: EP

Kind code of ref document: A1