A method and device for data migration

By using a time-based data partitioning and processing mechanism, the problem of low efficiency in large-scale data migration is solved, achieving efficient and complete data migration and archiving while avoiding high memory consumption.

CN113760861BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110041286.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-13
Publication Date
2024-10-18
Estimated Expiration
2041-01-13

AI Technical Summary

Technical Problem

During large-scale data migration, existing technologies such as reindex migration are slow and prone to failure, while Spark migration requires high memory configuration, resulting in low efficiency and wasted resources.

Method used

By acquiring the time information of the data, the data is divided and an index based on the time information is created. Incremental and stock data processing mechanisms are used to migrate the data to the storage table of the new index and archive it according to the time information.

Benefits of technology

It improves the efficiency of large-scale data migration and querying, ensures data integrity, reduces memory usage, and optimizes the data maintenance and archiving process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113760861B_ABST
    Figure CN113760861B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for data migration, and relates to the field of computer technology. A specific implementation of the method includes: obtaining time information of data; dividing the data according to the acquired time information of the data, and creating an index of the data based on the time information; and migrating the data to the created data storage table of the index by processing the incremental data and the stock data in the divided data. Therefore, the implementation of the present invention can solve the problem of migration efficiency of excessive data, and can highly guarantee the integrity of the data without relying on high memory configuration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for data migration. Background Art

[0002] When the amount of data is too large and the number of shards initially created by the search engine ES index is insufficient, the data storage speed is slow or the query efficiency is low, so it is necessary to increase the number of shards or reconstruct the mapping data structure. Usually, you can use reindex or use the engine spark to migrate data.

[0003] There are at least the following problems in the prior art: for migration of large amounts of data, such as T-level data, the reindex migration speed becomes very slow, and once the migration fails, it is difficult to locate the cause of the failure; and using spark to migrate data requires a higher memory space, thereby placing higher requirements on the memory configuration of the machine. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method and device for data migration, which can solve the problem of migration efficiency of excessive data and can highly guarantee data integrity without relying on high memory configuration.

[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for data migration is provided, comprising:

[0006] Get the time information of the data;

[0007] Dividing the data according to the acquired time information of the data, and creating an index of the data based on the time information;

[0008] By processing the incremental data and the stock data in the divided data, the data is migrated to the created data storage table of the index.

[0009] Preferably, the incremental data is stored in a storage space of a message queue, and the incremental data is migrated from the storage space of the message queue to the created data storage table of the index.

[0010] Preferably, before migrating the incremental data to the created data storage table of the index, the incremental data is also inserted into the data storage table of the original index.

[0011] Preferably, according to a predetermined data migration rule, the stock data is migrated from the data storage table of the original index to the data storage table of the created index.

[0012] Preferably, the predetermined data migration rule includes a data migration time point and a data migration step, and

[0013] Based on the data migration time point and the data migration step, a migration range of the stock data is set to perform migration of the stock data.

[0014] Preferably, the data migration step is set according to the amount of the stock data.

[0015] Preferably, after migrating the data to the created data storage table of the index, the method further includes: based on the time information, storing the data in a predetermined database to archive the data.

[0016] Preferably, the time information includes the data generation time.

[0017] Based on the time information, the data whose generation time is earlier than the predetermined time is stored in the predetermined database.

[0018] According to another aspect of an embodiment of the present invention, there is provided a device for data migration, including:

[0019] An acquisition unit, the acquisition unit acquires time information of the data;

[0020] a creating unit, the creating unit dividing the data according to the acquired time information of the data, and creating an index of the data based on the time information; and

[0021] The migration unit processes the incremental data and the stock data in the divided data, and migrates the data to the created data storage table of the index.

[0022] According to another aspect of an embodiment of the present invention, there is provided an electronic device for data migration, characterized in that it includes:

[0023] one or more processors; and

[0024] a storage device for storing one or more programs,

[0025] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0026] According to another aspect of an embodiment of the present invention, there is provided a computer-readable medium having a computer program stored thereon, wherein the program implements the method as described above when executed by a processor.

[0027] An embodiment of the above invention has the following advantages or beneficial effects: it can dynamically complete data migration, improve the efficiency of migration of large amounts of data and data query efficiency, ensure data integrity, does not require higher memory space, and optimizes data maintenance and archiving, making data archiving more convenient.

[0028] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0030] Figure 1 is a schematic diagram of the main process of the data migration method according to an embodiment of the present invention;

[0031] Figure 2 A specific process example of a method for data migration according to an embodiment of the present invention is shown;

[0032] Figure 3 is a flow chart of the steps of creating a dynamic index according to an embodiment of the present invention;

[0033] Figure 4 is a flow chart of data migration steps according to an embodiment of the present invention;

[0034] Figure 5 is a specific flow chart of data double writing of incremental data according to an embodiment of the present invention;

[0035] Figure 6 is a flowchart of migration of stock data according to an embodiment of the present invention;

[0036] Figure 7 is a schematic diagram of a process of data arbitration in data migration according to an embodiment of the present invention;

[0037] Figure 8 is a schematic diagram of a specific example of data archiving according to an embodiment of the present invention;

[0038] Fig. 9 is a specific operation flow chart of data archiving according to an embodiment of the present invention;

[0039] Fig.10 is a schematic diagram of main modules of a data migration device according to an embodiment of the present invention;

[0040] Fig.11 is an exemplary system architecture diagram to which embodiments of the present invention may be applied; and

[0041] Fig.12It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0042] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0043] Figure 1 is a schematic diagram of the main process of the method for data migration according to an embodiment of the present invention; Figure 1 As shown, the method for data migration includes: step S101, obtaining time information of data; step S102, dividing the data according to the obtained time information of the data, and creating an index of the data based on the time information; step S103, migrating the data to the data storage table of the created index by processing the incremental data and the stock data in the divided data.

[0044] Preferably, in step S103, the incremental data is stored in the storage space of the message queue, and the incremental data is migrated from the storage space of the message queue to the created data storage table of the index.

[0045] Preferably, before migrating the incremental data to the created data storage table of the index, the incremental data is also inserted into the data storage table of the original index.

[0046] Preferably, in step S103, the stock data is migrated from the data storage table of the original index to the data storage table of the created index according to a predetermined data migration rule.

[0047] Preferably, the predetermined data migration rule includes a data migration time point and a data migration step, and based on the data migration time point and the data migration step, a migration range of the stock data is set to perform migration of the stock data.

[0048] Preferably, the data migration step is set according to the amount of the stock data.

[0049] Preferably, after migrating the data to the created data storage table of the index, the method further includes: based on the time information, storing the data in a predetermined database to archive the data.

[0050] Preferably, the time information includes data generation time. Based on the time information, the data whose generation time is earlier than a predetermined time is stored in a predetermined database to archive the data.

[0051] The data migration method according to the embodiment of the present invention can dynamically complete data migration, improve the migration efficiency of large amounts of data and data query efficiency, ensure data integrity, do not require high memory space, and optimize data maintenance and archiving, making data archiving more convenient.

[0052] The following references Figure 2-9 A specific example of the data migration method according to an embodiment of the present invention is described.

[0053] Figure 2 A specific process example of the data migration method according to an embodiment of the present invention is shown.

[0054] When business data is related to time factors, horizontal splitting can be performed, such as dynamic indexing of ES, sharding of libraries and tables of relational database management system MySQL, etc.

[0055] like Figure 2 As shown, the specific steps include: a time information acquisition step S1 of business data, a dynamic index creation step S2, a data migration step S3 and a data archiving step S4.

[0056] The dynamic index creation step S2 is a prerequisite for data migration and archiving. For example, according to the business scenario (for example, the type of business data) and the increment of business data, the business data is split according to the acquired time information, and multiple indexes are created. For example, the business data is order data, and the order data can be split by month according to the time of order placement. Figure 3 A flowchart showing the steps of creating a dynamic index.

[0057] Indexes created after the index creation date can be configured using ES templates, such as generating indexes based on months; indexes created before the index creation date can be created manually or through the API.

[0058] In addition, when creating a dynamic index, you can also modify the logic of the business query. With the modified query logic, when using a dynamic index, you can perform cross-table queries supported by the underlying API.

[0059] The data migration step S3 includes, for example, migration of incremental data and migration of stock data. Figure 4 A flow chart showing the steps of data migration is shown.

[0060] Incremental data is migrated through double writing, for example. After the new data is inserted into the old ES index, the json format data is put into the message queue MQ. The newly created dynamic index pulls data from the message queue MQ and inserts the pulled data into the corresponding data storage table according to the time splitting rule (time routing rule). The specific process of double writing of incremental data is as follows: Figure 5 By inserting incremental data into the old index, the normal use of the original index and data table can be guaranteed.

[0061] The existing data is pulled through work tasks based on scroll queries, and the data is then poured into the created dynamic index. The rules for pulling data (data migration rules) can be configured according to the hardware configuration and the processing power of the ES cluster. For example, the amount of data pulled each time is less than 50,000 (data migration step). In addition, the new ES cluster can also pull and consume data in a queue manner (for example, message queue MQ).

[0062] Figure 6 The specific migration process of stock data is shown. Figure 6 As shown, the data migration task is started through the work transmitter (work transmitter). Get the starting time point (checkpoint time point) of data pulling and the dynamic pulling step (the time range of data pulling). Before executing the work task, two values ​​need to be initialized in the redis cache, namely, the checkpoint pulling time point and the dynamic pulling step. Then, the data is checked for non-emptiness. When the data is judged to be empty, an exception is output. When the data is judged to be non-empty, data is pulled from the old ES based on the scroll query. Then, data arbitration is performed. If it passes, MQ is sent in batches. If it fails, recursive verification is performed. Finally, redis updates the checkpoint and dynamic pulling step.

[0063] The following references Figure 7 The process of data arbitration in data migration is further explained.

[0064] like Figure 7As shown, first, according to the checkpoint and the dynamic pull step, the data range to be pulled and the time point for the next data pull are calculated. Then, the total number of data items is queried. Then, the data pull range is arbitrated to determine whether the data pull range meets the conditions. The dynamic pull step of data can be set according to the amount of data by setting the data pull threshold and the maximum pull value, thereby setting the data pull range. For example, the data pull threshold and the maximum pull value are set. When the data amount is less than the set threshold, the step length is lengthened, such as multiplying the step length by 2; when the data amount is greater than the threshold and less than the maximum value, the step length remains unchanged; when the data amount is greater than the maximum value, the step length is shortened, such as dividing the step length by 3. If the data pull range meets the predetermined conditions, data is pulled; otherwise, the data pull range is reset.

[0065] according to Figure 2 The specific process example of data migration also includes a data archiving step S4. When the amount of data is too large, cold data can be archived. For example, data generated earlier than a specific time is stored in a specific database. The following is an example. According to business requirements, only data from the past two years, such as 2020 and 2019, is needed. Then, data from two years ago, such as 2018, can be poured into a non-relational database NOSQL, such as an Hbase database (such as Figure 8 Moreover, such data archiving processing will not affect, for example, the hot data of the past two years, because the cold data and the hot data are stored separately.

[0066] Fig. 9 The specific operation flow chart of data archiving is shown. Data archiving has a similar process to data migration. First, start the work scheduling task; then pull the archived data from the archive index; then, send the archived data in batches to MQ; finally, insert it into NOSQL through the application layer.

[0067] According to the above specific example of the data migration method of the present invention, data migration can be completed dynamically, the efficiency of migration of large amounts of data and data query efficiency can be improved, the integrity of the data can be ensured, a higher memory space is not required, and data maintenance and archiving are optimized, making data archiving more convenient.

[0068] Fig.10 Schematic diagram of main modules of a data migration device according to an embodiment of the present invention. Fig.10As shown, the data migration device 200 includes: an acquisition unit 201, which acquires the time information of the data; a creation unit 202, which divides the data according to the acquired time information of the data, and creates an index of the data based on the time information; a migration unit 203, which migrates the data to the data storage table of the created index by processing the incremental data and the stock data in the divided data.

[0069] Preferably, the migration unit 203 stores the incremental data into the storage space of the message queue, and migrates the incremental data from the storage space of the message queue to the created data storage table of the index.

[0070] Preferably, before migrating the incremental data to the created data storage table of the index, the migration unit 203 also inserts the incremental data into the data storage table of the original index.

[0071] Preferably, the migration unit 203 migrates the stock data from the data storage table of the original index to the data storage table of the created index according to a predetermined data migration rule.

[0072] Preferably, the predetermined data migration rule includes a data migration time point and a data migration step, and based on the data migration time point and the data migration step, a migration range of the stock data is set to perform migration of the stock data.

[0073] Preferably, the data migration step is set according to the amount of the stock data.

[0074] Preferably, the data migration device according to the embodiment of the present invention further includes: an archiving unit, which stores the data into a predetermined database based on the time information to archive the data.

[0075] Preferably, the time information includes data generation time. Based on the time information, the data whose generation time is earlier than a predetermined time is stored in a predetermined database to archive the data.

[0076] The data migration device according to the embodiment of the present invention can dynamically complete data migration, improve the efficiency of migration of large amounts of data and data query efficiency, ensure data integrity, do not require high memory space, and optimize data maintenance and archiving, making data archiving more convenient.

[0077] Fig.11 An exemplary system architecture 600 is shown to which the method for data migration or the apparatus for data migration according to the embodiment of the present invention can be applied.

[0078] like Fig.11As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0079] Users can use terminal devices 601, 602, and 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0080] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0081] The server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0082] It should be noted that the data migration method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the data migration device is generally set in the server 605 .

[0083] It should be understood that Fig.11 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0084] Reference below Fig.12 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Fig.12 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0085] like Fig.12As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0086] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0087] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0088] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0089] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0090] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an acquisition unit, a creation unit, and a migration unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the acquisition unit may also be described as a "unit for acquiring time information of data".

[0091] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining time information of data; dividing the data according to the obtained time information of the data, and creating an index of the data based on the time information; and migrating the data to the created data storage table of the index by processing the incremental data and stock data in the divided data.

[0092] According to the technical solution of the embodiment of the present invention, data migration can be completed dynamically, the efficiency of migration of large amounts of data and data query efficiency can be improved, the integrity of data can be ensured, a higher memory space does not need to be occupied, and data maintenance and archiving are optimized, making data archiving more convenient.

[0093] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for data migration, characterized in that: include: Get the time information of the data; Dividing the data according to the acquired time information of the data, and creating an index of the data based on the time information; By processing the incremental data and the stock data in the divided data, the data is migrated to the created data storage table of the index; specifically including: storing the incremental data in the storage space of the message queue, and migrating the incremental data from the storage space of the message queue to the created data storage table of the index; According to a predetermined data migration rule, the stock data is migrated from the data storage table of the original index to the data storage table of the created index, wherein the predetermined data migration rule includes a data migration time point and a data migration step.

2. The method for data migration according to claim 1, characterized in that: Before migrating the incremental data to the created data storage table of the index, the incremental data is also inserted into the data storage table of the original index.

3. The method for data migration according to claim 1, characterized in that: Based on the data migration time point and the data migration step, a migration range of the stock data is set to perform migration of the stock data.

4. The method for data migration according to claim 3, characterized in that: The data migration step is set according to the amount of the stock data.

5. The method for data migration according to any one of claims 1 to 4, characterized in that: After migrating the data to the created data storage table of the index, the method further includes: based on the time information, storing the data in a predetermined database to archive the data.

6. The method for data migration according to claim 5, characterized in that: The time information includes the data generation time, Based on the time information, the data whose generation time is earlier than the predetermined time is stored in the predetermined database.

7. A data migration device, characterized in that: include: An acquisition unit, the acquisition unit acquires time information of the data; a creating unit, wherein the creating unit divides the data according to the acquired time information of the data, and creates an index of the data based on the time information; and A migration unit, which processes the incremental data and the stock data in the divided data, and migrates the data to the created data storage table of the index; Specifically used for storing the incremental data into the storage space of the message queue, and migrating the incremental data from the storage space of the message queue to the created data storage table of the index; According to a predetermined data migration rule, the stock data is migrated from the data storage table of the original index to the data storage table of the created index, wherein the predetermined data migration rule includes a data migration time point and a data migration step.

8. An electronic device for data migration, characterized in that: include: one or more processors; as well as a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Data storage method and device, apparatus and storage medium

    CN110196851A

  • Data migration method, device and equipment and storage medium

    CN110321339A