CN114860690A - Data migration method, device, equipment and storage medium - Google Patents
Data migration method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN114860690A CN114860690A CN202210512455.6A CN202210512455A CN114860690A CN 114860690 A CN114860690 A CN 114860690A CN 202210512455 A CN202210512455 A CN 202210512455A CN 114860690 A CN114860690 A CN 114860690A
- Authority
- CN
- China
- Prior art keywords
- data
- migrated
- migration
- data set
- data migration
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/214—Database migration support
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/215—Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
- G06F9/5038—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5021—Priority
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Quality & Reliability (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明涉及数据处理领域,揭露一种数据迁移方法,包括:获取数据源表中的待迁移数据集及数据迁移目标表;将待迁移数据集进行数据编排,得到编排待迁移数据集;将编排待迁移数据集进行切分操作,得到切分待迁移数据集;将多个数据迁移任务按照预设的优先级进行排序,并根据排序后的数据迁移任务将切分待迁移数据集迁移至数据迁移目标表中。本发明还涉及一种区块链技术,待迁移数据集可存储在区块链节点中。本发明还提出一种数据迁移装置、设备以及介质。本发明可以提高数据迁移效率。
The invention relates to the field of data processing, and discloses a data migration method, comprising: obtaining a data set to be migrated and a data migration target table in a data source table; arranging the data set to be migrated to obtain a data set to be migrated; Divide the data set to be migrated to obtain the divided data set to be migrated; sort the multiple data migration tasks according to the preset priority, and migrate the divided data set to be migrated to the data set according to the sorted data migration tasks in the migration target table. The invention also relates to a blockchain technology, and the data set to be migrated can be stored in the blockchain node. The present invention also provides a data migration device, equipment and medium. The present invention can improve data migration efficiency.
Description
技术领域technical field
本发明涉及数据处理领域,尤其涉及一种数据迁移方法、装置、设备及存储介质。The present invention relates to the field of data processing, and in particular, to a data migration method, apparatus, device and storage medium.
背景技术Background technique
数据迁移是指将数据从源数据库迁移到目标数据库的过程。在传统数据迁移过程中,通常是通过数据迁移工具实现数据迁移,由于数据迁移工具主要是通过操作日志进行简单的数据同步,使得数据迁移过程中的数据完整性不能保证,且当数据迁移工具出现异常时,数据迁移过程会被中断,需要重新启动,导致数据迁移效率较低。Data migration refers to the process of migrating data from a source database to a target database. In the traditional data migration process, data migration is usually realized through data migration tools. Because data migration tools mainly perform simple data synchronization through operation logs, the data integrity during the data migration process cannot be guaranteed, and when data migration tools appear When an exception occurs, the data migration process will be interrupted and needs to be restarted, resulting in low data migration efficiency.
发明内容SUMMARY OF THE INVENTION
本发明提供一种数据迁移方法、装置、设备及存储介质,其主要目的是提高数据迁移效率。The present invention provides a data migration method, device, equipment and storage medium, the main purpose of which is to improve data migration efficiency.
为实现上述目的,本发明提供了一种数据迁移方法,包括:To achieve the above purpose, the present invention provides a data migration method, comprising:
获取数据源表中的待迁移数据集及数据迁移目标表;Obtain the data set to be migrated and the data migration target table in the data source table;
将所述待迁移数据集进行数据编排,得到编排待迁移数据集;Perform data arrangement on the data set to be migrated to obtain a data set to be migrated;
将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集;performing a segmentation operation on the data set to be migrated, to obtain a segmented data set to be migrated;
创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中。Create multiple data migration tasks for dividing the data set to be migrated, sort the multiple data migration tasks according to preset priorities to obtain sorted data migration tasks, and transfer the data migration tasks according to the sorted data migration tasks The data set to be migrated is divided and migrated to the data migration target table.
可选地,所述将所述待迁移数据集进行数据编排,得到编排待迁移数据集,包括:Optionally, performing data orchestration on the data set to be migrated to obtain the data set to be migrated by orchestration includes:
获取所述待迁移数据集的数据类型;obtaining the data type of the data set to be migrated;
根据所述数据类型,识别所述待迁移数据集的数据结构;Identifying the data structure of the data set to be migrated according to the data type;
根据预设的编排规则将所述数据结构进行编排,得到所述编排待迁移数据集。The data structure is arranged according to a preset arrangement rule to obtain the arranged data set to be migrated.
可选地,所述将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,包括:Optionally, performing a segmentation operation on the orchestration to-be-migrated data set to obtain the segmentation to-be-migrated data set, including:
将所述数据源库进行分库操作,得到多个数据源分库;Performing a sub-database operation on the data source database to obtain a plurality of data source sub-databases;
在多个所述数据源分库中进行分表操作,得到多个数据源分表;Perform a table splitting operation in a plurality of the data source sub-databases to obtain a plurality of data source sub-tables;
根据多个所述数据源分表将所述编排待迁移数据集进行切分,得到所述切分待迁移数据集。Divide the data set to be migrated according to the plurality of data source sub-tables to obtain the divided data set to be migrated.
可选地,所述创建所述切分待迁移数据集的多个数据迁移任务,包括:Optionally, the creating multiple data migration tasks for dividing the data set to be migrated includes:
获取所述切分待迁移数据集的切分编号及切分地址;obtaining the segment number and segment address of the segmented data set to be migrated;
将所述切分待迁移数据集与对应的所述切分编号及所述切分地址分别进行关联,得到所述切分待迁移数据集的多个数据迁移任务。Associating the segmented data set to be migrated with the corresponding segmented number and segmented address, respectively, to obtain a plurality of data migration tasks for segmenting the to-be-migrated data set.
可选地,所述根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,包括:Optionally, migrating the segmented data set to be migrated to the data migration target table according to the sorting data migration task includes:
执行所述排序数据迁移任务,利用预设的插件读取所述排序数据迁移任务的执行参数;Execute the sorting data migration task, and use a preset plug-in to read the execution parameters of the sorting data migration task;
将所述执行参数与预设的负荷系数进行对比;comparing the execution parameter with a preset load factor;
当所述执行参数未超过所述负荷系数阈值时,利用预设的数据迁移工具将所述切分待迁移数据集通过预设的迁移线程加载至所述数据迁移目标表中;When the execution parameter does not exceed the load coefficient threshold, use a preset data migration tool to load the segmented data set to be migrated into the data migration target table through a preset migration thread;
当所述执行参数超过所述负荷系数阈值时,新增多个迁移线程,利用所述数据迁移工具依次将所述切分待迁移数据集通过多个所述迁移线程加载至所述数据迁移目标表中。When the execution parameter exceeds the load coefficient threshold, multiple migration threads are added, and the data migration tool is used to sequentially load the split data set to be migrated to the data migration target through the multiple migration threads in the table.
可选地,所述根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中之后,所述方法还包括:Optionally, after migrating the segmented data set to be migrated to the data migration target table according to the sorting data migration task, the method further includes:
根据预设的全量规则核对所述切分待迁移数据集与所述数据迁移目标表中的全量迁移数据集的一致性,当所述切分待迁移数据集与所述全量迁移数据集不一致时,记录所述切分待迁移数据集的迁移异常点,根据所述迁移异常点,重新执行切分待迁移数据集的数据迁移;Check the consistency of the split data set to be migrated and the full migration data set in the data migration target table according to the preset full volume rule. When the split to be migrated data set is inconsistent with the full migration data set , recording the migration abnormal point of the divided data set to be migrated, and re-executes the data migration of dividing the data set to be migrated according to the migration abnormal point;
根据预设的增量规则核对所述切分待迁移数据集与所述数据迁移目标表中的增量迁移数据集的一致性,当所述切分待迁移数据集与所述增量迁移数据集不一致时,记录所述切分待迁移数据集的迁移异常点,根据所述迁移异常点,重新执行切分待迁移数据集的数据迁移。Check the consistency between the split data set to be migrated and the incremental migration data set in the data migration target table according to the preset incremental rule, when the split data set to be migrated and the incremental migration data When the sets are inconsistent, record the migration abnormal point of the divided data set to be migrated, and re-execute the data migration of dividing the data set to be migrated according to the migration abnormal point.
可选地,所述获取数据源表中的待迁移数据集及数据迁移目标表之后,所述方法还包括:Optionally, after obtaining the data set to be migrated and the data migration target table in the data source table, the method further includes:
对所述待迁移数据集进行去重操作,并检测去重后的所述待迁移数据集中是否存在数据缺失值;Perform a deduplication operation on the data set to be migrated, and detect whether there are missing data values in the data set to be migrated after deduplication;
若不存在数据缺失值,则得到去重后的所述待迁移数据集;If there is no data missing value, obtain the data set to be migrated after deduplication;
若存在数据缺失值,则对所述数据缺失值进行填充,得到填充后的待迁移数据集。If there is a missing data value, the missing data value is filled to obtain a filled data set to be migrated.
为了解决上述问题,本发明还提供一种数据迁移装置,所述装置包括:In order to solve the above problems, the present invention also provides a data migration device, the device includes:
数据获取模块,用于获取数据源表中的待迁移数据集及数据迁移目标表;The data acquisition module is used to acquire the data set to be migrated and the data migration target table in the data source table;
数据编排模块,用于将所述待迁移数据集进行数据编排,得到编排待迁移数据集;a data arrangement module, configured to perform data arrangement on the data set to be migrated to obtain a data set to be arranged to be migrated;
数据切分模块,用于将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集;a data segmentation module, configured to perform a segmentation operation on the orchestrated data set to be migrated to obtain a segmented data set to be migrated;
数据迁移模块,用于创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中。A data migration module, configured to create a plurality of data migration tasks for dividing the data set to be migrated, sort the plurality of data migration tasks according to a preset priority, obtain a sorted data migration task, and sort the data migration tasks according to the sorting The data migration task migrates the divided data set to be migrated into the data migration target table.
为了解决上述问题,本发明还提供一种电子设备,所述电子设备包括:In order to solve the above problems, the present invention also provides an electronic device, the electronic device includes:
存储器,存储至少一个计算机程序;及a memory that stores at least one computer program; and
处理器,执行所述存储器中存储的计算机程序以实现上述所述的数据迁移方法。The processor executes the computer program stored in the memory to implement the data migration method described above.
为了解决上述问题,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一个计算机程序,所述至少一个计算机程序被电子设备中的处理器执行以实现上述所述的数据迁移方法。In order to solve the above problems, the present invention also provides a computer-readable storage medium, where at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is executed by a processor in an electronic device to realize the above-mentioned The data migration method described above.
本发明实施例中,首先通过将所述待迁移数据集进行数据编排,得到编排待迁移数据集,可以避免由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,导致后续待迁移数据集进行迁移时出现异常;其次,将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,可以避免因大量数据一次性迁移过程中出现的异常场景导致整体数据迁移失败的后果,便于在数据迁移过程出现异常时,通过识别切分待迁移数据集中的异常待迁移数据集,只需重新进行异常待迁移数据集的数据迁移修复,保证数据迁移过程中的数据完整性;最后根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,可以实现数据迁移任务的智能调度,提高数据迁移效率。因此本发明实施例提出的数据迁移方法、装置、设备及存储介质可以提高数据迁移效率。In the embodiment of the present invention, the data set to be migrated is obtained by first performing data arrangement on the data set to be migrated, which can avoid subsequent migration due to inconsistency between the data structure in the data source table and the data structure of the data migration target table. An exception occurs when the data set is migrated; secondly, the data set to be migrated is divided into the data set to be divided, which can avoid the failure of the overall data migration due to abnormal scenarios that occur during the one-time migration of a large amount of data. The result is that when an exception occurs in the data migration process, by identifying and dividing the abnormal data set to be migrated in the data set to be migrated, it is only necessary to perform data migration and repair of the abnormal data set to be migrated again to ensure data integrity during the data migration process. Finally, according to the sorted data migration task, the segmented data set to be migrated is migrated to the data migration target table, which can realize intelligent scheduling of data migration tasks and improve data migration efficiency. Therefore, the data migration method, apparatus, device, and storage medium provided by the embodiments of the present invention can improve data migration efficiency.
附图说明Description of drawings
图1为本发明一实施例提供的数据迁移方法的流程示意图;FIG. 1 is a schematic flowchart of a data migration method according to an embodiment of the present invention;
图2为本发明一实施例提供的数据迁移方法中一个步骤的详细流程示意图;2 is a detailed flowchart of a step in a data migration method provided by an embodiment of the present invention;
图3为本发明一实施例提供的数据迁移方法中一个步骤的详细流程示意图;3 is a detailed flowchart of a step in a data migration method provided by an embodiment of the present invention;
图4为本发明一实施例提供的数据迁移装置的模块示意图;FIG. 4 is a schematic block diagram of a data migration apparatus according to an embodiment of the present invention;
图5为本发明一实施例提供的实现数据迁移方法的电子设备的内部结构示意图;5 is a schematic diagram of an internal structure of an electronic device implementing a data migration method according to an embodiment of the present invention;
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.
本发明实施例提供一种数据迁移方法。所述数据迁移方法的执行主体包括但不限于服务端、终端等能够被配置为执行本申请实施例提供的该方法的电子设备中的至少一种。换言之,所述数据迁移方法可以由安装在终端设备或服务端设备的软件或硬件来执行,所述软件可以是区块链平台。所述服务端包括但不限于:单台服务器、服务器集群、云端服务器或云端服务器集群等。Embodiments of the present invention provide a data migration method. The execution body of the data migration method includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided by the embodiments of the present application, such as a server and a terminal. In other words, the data migration method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
参照图1所示的本发明一实施例提供的数据迁移方法的流程示意图,在本发明实施例中,所述数据迁移方法包括以下步骤S1-S4:Referring to the schematic flowchart of the data migration method provided by an embodiment of the present invention shown in FIG. 1, in the embodiment of the present invention, the data migration method includes the following steps S1-S4:
S1、获取数据源表中的待迁移数据集及数据迁移目标表。S1. Obtain the data set to be migrated and the data migration target table in the data source table.
本发明实施例中,所述待迁移数据集是指需要从数据源表迁移至数据迁移目标表的数据,比如将Oracle数据库中的数据迁移至Tidb数据库中;所述数据源表是指存储待迁移数据集的数据表;所述数据迁移目标表是指存储待迁移数据集迁移后的数据集的数据集。In the embodiment of the present invention, the data set to be migrated refers to the data that needs to be migrated from the data source table to the data migration target table, for example, the data in the Oracle database is migrated to the Tidb database; the data source table refers to the storage to be The data table of the data set to be migrated; the data migration target table refers to the data set that stores the migrated data set of the data set to be migrated.
本发明一可选实施例中,由于所述待迁移数据集中存在许多无用数据,于是,本发明实施例通过对所述待迁移数据进行数据清洗,得到标准数据集,可以筛选出所述待迁移数据集中的无用数据,提高数据迁移的效率。In an optional embodiment of the present invention, since there are a lot of useless data in the data set to be migrated, the embodiment of the present invention performs data cleaning on the data to be migrated to obtain a standard data set, and can filter out the data to be migrated Useless data in the data set improves the efficiency of data migration.
详细地,所述获取数据源表中的待迁移数据集及数据迁移目标表之后,所述方法还包括:In detail, after obtaining the data set to be migrated and the data migration target table in the data source table, the method further includes:
对所述待迁移数据集进行去重操作,并检测去重后的所述待迁移数据集中是否存在数据缺失值;若不存在数据缺失值,则得到去重后的所述待迁移数据集;若存在数据缺失值,则对所述数据缺失值进行填充,得到填充后的待迁移数据集。Perform a deduplication operation on the data set to be migrated, and detect whether there are missing data values in the data set to be migrated after deduplication; if there is no missing data value, obtain the data set to be migrated after deduplication; If there is a missing data value, the missing data value is filled to obtain a filled data set to be migrated.
本发明一实施例中,利用下述方法对所述待迁移数据集进行去重操作:In an embodiment of the present invention, the following method is used to perform a deduplication operation on the data set to be migrated:
其中,d表示待迁移数据集中任意两个数据的距离值,w1j和w2j表示待迁移数据集中任意两个数据,当所述距离值小于预设的距离值时,删除其中任意一个数据,若所述距离值不小于预设的距离值时,则同时保留两个数据。较佳地,所述预设的距离值可以为0.1。Among them, d represents the distance value of any two data in the data set to be migrated, w 1j and w 2j represent any two data in the data set to be migrated, when the distance value is less than the preset distance value, delete any one of the data, If the distance value is not less than the preset distance value, two pieces of data are kept at the same time. Preferably, the preset distance value may be 0.1.
S2、将所述待迁移数据集进行数据编排,得到编排待迁移数据集。S2. Perform data arrangement on the data set to be migrated to obtain a data set to be migrated.
本发明实施例中,所述数据编排的主要作用是由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,为了适应数据迁移目标表的数据结构进行的数据编排。In the embodiment of the present invention, the main function of the data arrangement is that since the data structure in the data source table is inconsistent with the data structure of the data migration target table, the data arrangement is performed in order to adapt to the data structure of the data migration target table.
本发明实施例通过将所述待迁移数据集进行数据编排,得到编排待迁移数据集,可以避免由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,导致后续待迁移数据集进行迁移时出现异常,以提高后续数据迁移效率。In the embodiment of the present invention, by performing data arrangement on the data set to be migrated to obtain the data set to be arranged to be migrated, it is possible to avoid the subsequent data set to be migrated due to the inconsistency between the data structure in the data source table and the data structure of the data migration target table. An exception occurs during migration to improve the efficiency of subsequent data migration.
作为本发明的一个实施例,参考图2所示,所述将所述待迁移数据集进行数据编排,得到编排待迁移数据集,包括以下步骤S21-S23:As an embodiment of the present invention, referring to FIG. 2 , performing data arrangement on the data set to be migrated to obtain the data set to be arranged to be migrated includes the following steps S21-S23:
S21、获取所述待迁移数据集的数据类型;S21, obtaining the data type of the data set to be migrated;
S22、根据所述数据类型,识别所述待迁移数据集的数据结构;S22, identifying the data structure of the data set to be migrated according to the data type;
S23、根据预设的编排规则将所述数据结构进行编排,得到所述编排待迁移数据集。S23. Arrange the data structure according to a preset arrangement rule to obtain the arranged data set to be migrated.
其中,所述数据类型主要用于表征待迁移数据集信息的数据;所述数据结构是指待迁移数据集之间存在一种或多种关系的数据元素的集合,比如客户投保数据中,客户与不同保险品类的投保关系。The data type is mainly used to represent the data of the data set information to be migrated; the data structure refers to a collection of data elements with one or more relationships between the data sets to be migrated, for example, in the customer insurance data, the customer Insurance relationship with different types of insurance.
本发明一实施例中,所述编排规则可以根据实际场景自定义,比如,保险领域中,数据源表中的待迁移数据集将所有客户的投保情况表,则编排规则可以为根据客户类别进行编排,当识别到客户类型为个体客户则编排至个体表,识别到客户类型为团体客户则编排至团体表。In an embodiment of the present invention, the arrangement rules can be customized according to actual scenarios. For example, in the insurance field, the data set to be migrated in the data source table lists the insurance application status of all customers, and the arrangement rules can be based on customer categories. Arrangement, when it is identified that the customer type is an individual customer, it is arranged to the individual table, and the customer type is recognized to be a group customer, it is arranged to the group table.
S3、将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集。S3. Perform a segmentation operation on the orchestrated data set to be migrated to obtain a segmented data set to be migrated.
将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集。A segmentation operation is performed on the data set to be migrated, and the segmented data set to be migrated is obtained.
本发明实施例中,所述切分待迁移数据集是指对所述编排待迁移数据集进行分库、分表后的数据。In the embodiment of the present invention, the dividing the data set to be migrated refers to the data after the data set to be migrated is divided into databases and tables.
本发明实施例通过将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,可以避免因大量数据一次性迁移过程中出现的异常场景导致整体数据迁移失败的后果,便于在数据迁移过程出现异常时,通过识别切分待迁移数据集中的异常待迁移数据集,只需重新进行异常待迁移数据集的数据迁移修复,并保证数据迁移过程中的数据完整性。In the embodiment of the present invention, the data set to be migrated is obtained by dividing the data set to be migrated, which can avoid the consequence of the failure of the overall data migration caused by the abnormal scenario that occurs during the one-time migration of a large amount of data, and is convenient for When an abnormality occurs in the data migration process, by identifying and dividing the abnormal data set to be migrated in the data set to be migrated, it is only necessary to perform data migration and repair of the abnormal data set to be migrated again, and ensure the data integrity during the data migration process.
作为本发明的一个实施例,参考图3所示,所述将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,包括以下步骤S31-S33:As an embodiment of the present invention, referring to FIG. 3 , performing a segmentation operation on the data set to be migrated for orchestration to obtain a segmented data set to be migrated includes the following steps S31-S33:
S31、将所述数据源库进行分库操作,得到多个数据源分库;S31, performing a sub-database operation on the data source database to obtain a plurality of data source sub-databases;
S32、在多个所述数据源分库中进行分表操作,得到多个数据源分表;S32, performing a table splitting operation in a plurality of the data source sub-databases to obtain a plurality of data source sub-tables;
S33、根据多个所述数据源分表将所述编排待迁移数据集进行切分,得到所述切分待迁移数据集。S33: Divide the data set to be migrated according to the plurality of data source sub-tables to obtain the divided data set to be migrated.
其中,由于数据源库的性能限制,导致数据源库的数据库容量不能过大,需要对数据源库进行分库操作,得到多个数据源分库,比如,数据源库为A,则多个数据源分库可以为A1、A2、A3及A4等;将数据源分库进行分表操作是为了防止数据表存储的记录数据较多,避免数据迁移的异常中断,还可以在该分表数据出现异常情况时,不会影响其他分表数据的迁移,比如,数据源分库数量为六个,且每个分库中都存储十个分表,则数据源分表总共为六十个,根据所述数据源分表将待迁移数据集进行切分,可以六十个切分待迁移数据集。Among them, due to the performance limitations of the data source database, the database capacity of the data source database cannot be too large, and the data source database needs to be sub-database operation to obtain multiple data source sub-databases, for example, if the data source database is A, then multiple The data source sub-database can be A1, A2, A3, A4, etc.; the data source sub-database is divided into tables to prevent the data table from storing more record data and avoid abnormal interruption of data migration. When an exception occurs, it will not affect the migration of other sub-table data. For example, if the number of data source sub-databases is six, and each sub-database stores ten sub-tables, the total number of data source sub-tables is 60. The data set to be migrated is segmented according to the data source segment table, and sixty data sets to be migrated can be segmented.
S4、创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中。S4. Create a plurality of data migration tasks for dividing the data set to be migrated, sort the plurality of data migration tasks according to a preset priority to obtain a sorted data migration task, and arrange the data migration tasks according to the sorted data migration task. The divided data set to be migrated is migrated to the data migration target table.
本发明实施例中,所述数据迁移任务是指切分待迁移数据集迁移至数据迁移目标表中的任务。比如,切分待迁移数据集为保险公司的所有客户投保信息,则数据迁移任务为普通客户车险投保信息、普通客户重疾险投保信息、VIP客户重疾险投保信息及VIP客户车险投保信息等数据迁移任务。In the embodiment of the present invention, the data migration task refers to the task of dividing the data set to be migrated and migrating to the data migration target table. For example, if the data set to be migrated is divided into the insurance information of all customers of an insurance company, the data migration task is the insurance information of ordinary customers, critical illness insurance, VIP customers, and VIP customers. Data migration tasks.
本发明实施例中,所述预设的优先级是指用户根据需求进行多个数据迁移任务的自定义优先级排序,比如,第一级可以为VIP客户车险投保信息、第二级可以为VIP客户重疾险投保信息、第三级可以为普通客户重疾险投保信息、第四级可以为普通客户车险投保信息。In the embodiment of the present invention, the preset priority refers to the user-defined priority ordering of multiple data migration tasks according to requirements. For example, the first level may be the auto insurance application information of VIP customers, and the second level may be VIP customers. Customer critical illness insurance insurance information, third-level critical illness insurance insurance information for ordinary customers, and fourth-level auto insurance insurance information for ordinary customers.
本发明实施例通过创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,可以实现数据迁移任务的智能调度,提高数据迁移效率。In the embodiment of the present invention, by creating a plurality of data migration tasks for dividing the data set to be migrated, and sorting the plurality of data migration tasks according to a preset priority, a sorted data migration task is obtained, and according to the sorting data The migration task migrates the divided data set to be migrated to the data migration target table, which can realize intelligent scheduling of data migration tasks and improve data migration efficiency.
详细地,所述创建所述切分待迁移数据集的多个数据迁移任务,包括:Specifically, the creating multiple data migration tasks for dividing the data set to be migrated includes:
获取所述切分待迁移数据集的切分编号及切分地址;将所述切分待迁移数据集与对应的所述切分编号及所述切分地址分别进行关联,得到所述切分待迁移数据集的多个数据迁移任务。Obtain the segment number and segment address of the segmented data set to be migrated; associate the segmented data set to be migrated with the corresponding segment number and segment address, respectively, to obtain the segment Multiple data migration tasks for the dataset to be migrated.
进一步地,所述根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,包括:Further, migrating the segmented data set to be migrated to the data migration target table according to the sorting data migration task includes:
执行所述排序数据迁移任务,利用预设的插件读取所述排序数据迁移任务的执行参数;将所述执行参数与预设的负荷系数进行对比;当所述执行参数未超过所述负荷系数阈值时,利用预设的数据迁移工具将所述切分待迁移数据集通过预设的迁移线程加载至所述数据迁移目标表中;当所述执行参数超过所述负荷系数阈值时,新增多个迁移线程,利用所述数据迁移工具依次将所述切分待迁移数据集通过多个所述迁移线程加载至所述数据迁移目标表中。Execute the sorting data migration task, and use a preset plug-in to read the execution parameters of the sorting data migration task; compare the execution parameters with the preset load factor; when the execution parameter does not exceed the load factor When the threshold is set, use a preset data migration tool to load the segmented data set to be migrated into the data migration target table through a preset migration thread; when the execution parameter exceeds the load factor threshold, add a new Multiple migration threads, using the data migration tool to sequentially load the segmented data set to be migrated into the data migration target table through the multiple migration threads.
其中,所述执行参数是指所述排序数据迁移任务在执行过程中数据迁移目标表所处的目标数据库的资源消耗参数,比如,数据库连接数、tps、qps、CPU、内存等数据库的运行负荷系数;所述预设的负荷系数阈值为80%。The execution parameter refers to the resource consumption parameter of the target database where the data migration target table is located during the execution of the sorting data migration task, for example, the operating load of the database such as the number of database connections, tps, qps, CPU, memory, etc. coefficient; the preset load coefficient threshold is 80%.
本发明一实施例中,所述排序数据迁移任务是通过迁移线程执行的,通过目标数据库的资源消耗可以通过不同的线程执行任务,实现任务执行的智能调度,并提高数据迁移的迁移效率。In an embodiment of the present invention, the sorting data migration task is performed by a migration thread, and the task can be performed by different threads through resource consumption of the target database, so as to realize intelligent scheduling of task execution and improve the migration efficiency of data migration.
较佳的,所述数据迁移工具可以为KETTLE工具。Preferably, the data migration tool may be a KETTLE tool.
本发明另一实施例中,所述根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中之后,所述方法还包括:In another embodiment of the present invention, after migrating the segmented data set to be migrated to the data migration target table according to the sorted data migration task, the method further includes:
根据预设的全量规则核对所述切分待迁移数据集与所述数据迁移目标表中的全量迁移数据集的一致性,当所述切分待迁移数据集与所述全量迁移数据集不一致时,记录所述切分待迁移数据集的迁移异常点,根据所述迁移异常点,重新执行切分待迁移数据集的数据迁移;根据预设的增量规则核对所述切分待迁移数据集与所述数据迁移目标表中的增量迁移数据集的一致性,当所述切分待迁移数据集与所述增量迁移数据集不一致时,记录所述切分待迁移数据集的迁移异常点,根据所述迁移异常点,重新执行切分待迁移数据集的数据迁移。Check the consistency of the split data set to be migrated and the full migration data set in the data migration target table according to the preset full volume rule. When the split to be migrated data set is inconsistent with the full migration data set , record the migration abnormal point of the divided data set to be migrated, re-execute the data migration of the divided data set to be migrated according to the migration abnormal point; check the divided data set to be migrated according to the preset increment rule Consistency with the incremental migration data set in the data migration target table, when the split data set to be migrated is inconsistent with the incremental migration data set, record the migration exception of the split data set to be migrated point, re-execute the data migration of dividing the data set to be migrated according to the migration abnormal point.
其中,所述全量规则主要作用是识别源数据表在指定时间内的存储的切分待迁移数据集在迁移至数据目标表中的全量迁移数据集是否同步,且数据源表的变化会实时反应至数据迁移目标表,最终数据源表的切分迁移数据集与全量迁移数据集一致;所述增量规则主要作用是在不停产的情况下实现的数据迁移的同步。The main function of the full-scale rule is to identify whether the full-scale migration data set stored in the source data table within a specified period of time is synchronized with the full-scale migration data set migrated to the data target table, and changes in the data source table will be reflected in real time. To the data migration target table, the split migration data set of the final data source table is consistent with the full migration data set; the main function of the incremental rule is to realize the synchronization of data migration without production interruption.
比如,2022年2月2日前数据源表的数据迁移都看作全量数据迁移,2022年2月2日后数据源表的数据迁移都看作增量数据迁移。For example, data migration of data source tables before February 2, 2022 is regarded as full data migration, and data migration of data source tables after February 2, 2022 is regarded as incremental data migration.
本发明实施例中,首先通过将所述待迁移数据集进行数据编排,得到编排待迁移数据集,可以避免由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,导致后续待迁移数据集进行迁移时出现异常;其次,将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,可以避免因大量数据一次性迁移过程中出现的异常场景导致整体数据迁移失败的后果,便于在数据迁移过程出现异常时,通过识别切分待迁移数据集中的异常待迁移数据集,只需重新进行异常待迁移数据集的数据迁移修复,保证数据迁移过程中的数据完整性;最后根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,可以实现数据迁移任务的智能调度,提高数据迁移效率。因此本发明实施例提出的数据迁移方法可以提高数据迁移效率。In the embodiment of the present invention, the data set to be migrated is obtained by first performing data arrangement on the data set to be migrated, which can avoid subsequent migration due to inconsistency between the data structure in the data source table and the data structure of the data migration target table. An exception occurs when the data set is migrated; secondly, the data set to be migrated is divided into the data set to be divided, which can avoid the failure of the overall data migration due to abnormal scenarios that occur during the one-time migration of a large amount of data. The result is that when an exception occurs in the data migration process, by identifying and dividing the abnormal data set to be migrated in the data set to be migrated, it is only necessary to perform data migration and repair of the abnormal data set to be migrated again to ensure data integrity during the data migration process. Finally, according to the sorted data migration task, the segmented data set to be migrated is migrated to the data migration target table, which can realize intelligent scheduling of data migration tasks and improve data migration efficiency. Therefore, the data migration method proposed in the embodiments of the present invention can improve the data migration efficiency.
本发明所述数据迁移装置100可以安装于电子设备中。根据实现的功能,所述数据迁移装置可以包括数据获取模块101、数据编排模块102、数据切分模块103、数据迁移模块104,本发明所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。The
在本实施例中,关于各模块/单元的功能如下:In this embodiment, the functions of each module/unit are as follows:
所述数据获取模块101,用于获取数据源表中的待迁移数据集及数据迁移目标表。The
本发明实施例中,所述待迁移数据集是指需要从数据源表迁移至数据迁移目标表的数据,比如将Oracle数据库中的数据迁移至Tidb数据库中;所述数据源表是指存储待迁移数据集的数据表;所述数据迁移目标表是指存储待迁移数据集迁移后的数据集的数据集。In the embodiment of the present invention, the data set to be migrated refers to the data that needs to be migrated from the data source table to the data migration target table, for example, the data in the Oracle database is migrated to the Tidb database; the data source table refers to the storage to be The data table of the data set to be migrated; the data migration target table refers to the data set that stores the migrated data set of the data set to be migrated.
本发明一可选实施例中,由于所述待迁移数据集中存在许多无用数据,于是,本发明实施例通过对所述待迁移数据进行数据清洗,得到标准数据集,可以筛选出所述待迁移数据集中的无用数据,提高数据迁移的效率。In an optional embodiment of the present invention, since there are a lot of useless data in the data set to be migrated, the embodiment of the present invention performs data cleaning on the data to be migrated to obtain a standard data set, and can filter out the data to be migrated Useless data in the data set improves the efficiency of data migration.
所述数据获取模块101还可用于:The
对所述待迁移数据集进行去重操作,并检测去重后的所述待迁移数据集中是否存在数据缺失值;若不存在数据缺失值,则得到去重后的所述待迁移数据集;若存在数据缺失值,则对所述数据缺失值进行填充,得到填充后的待迁移数据集。Perform a deduplication operation on the data set to be migrated, and detect whether there are missing data values in the data set to be migrated after deduplication; if there is no missing data value, obtain the data set to be migrated after deduplication; If there is a missing data value, the missing data value is filled to obtain a filled data set to be migrated.
本发明一实施例中,利用下述方法对所述待迁移数据集进行去重操作:In an embodiment of the present invention, the following method is used to perform a deduplication operation on the data set to be migrated:
其中,d表示待迁移数据集中任意两个数据的距离值,w1j和w2j表示待迁移数据集中任意两个数据,当所述距离值小于预设的距离值时,删除其中任意一个数据,若所述距离值不小于预设的距离值时,则同时保留两个数据。较佳地,所述预设的距离值可以为0.1。Among them, d represents the distance value of any two data in the data set to be migrated, w 1j and w 2j represent any two data in the data set to be migrated, when the distance value is less than the preset distance value, delete any one of the data, If the distance value is not less than the preset distance value, two pieces of data are kept at the same time. Preferably, the preset distance value may be 0.1.
所述数据编排模块102,用于将所述待迁移数据集进行数据编排,得到编排待迁移数据集。The
本发明实施例中,所述数据编排的主要作用是由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,为了适应数据迁移目标表的数据结构进行的数据编排。In the embodiment of the present invention, the main function of the data arrangement is that since the data structure in the data source table is inconsistent with the data structure of the data migration target table, the data arrangement is performed in order to adapt to the data structure of the data migration target table.
本发明实施例通过将所述待迁移数据集进行数据编排,得到编排待迁移数据集,可以避免由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,导致后续待迁移数据集进行迁移时出现异常,以提高后续数据迁移效率。In the embodiment of the present invention, by performing data arrangement on the data set to be migrated to obtain the data set to be arranged to be migrated, it is possible to avoid the subsequent data set to be migrated due to the inconsistency between the data structure in the data source table and the data structure of the data migration target table. An exception occurs during migration to improve the efficiency of subsequent data migration.
作为本发明的一个实施例,所述数据编排模块102通过执行下述操作将所述待迁移数据集进行数据编排,得到编排待迁移数据集,包括:As an embodiment of the present invention, the
获取所述待迁移数据集的数据类型;obtaining the data type of the data set to be migrated;
根据所述数据类型,识别所述待迁移数据集的数据结构;Identifying the data structure of the data set to be migrated according to the data type;
根据预设的编排规则将所述数据结构进行编排,得到所述编排待迁移数据集。The data structure is arranged according to a preset arrangement rule to obtain the arranged data set to be migrated.
其中,所述数据类型主要用于表征待迁移数据集信息的数据;所述数据结构是指待迁移数据集之间存在一种或多种关系的数据元素的集合,比如客户投保数据中,客户与不同保险品类的投保关系。The data type is mainly used to represent the data of the data set information to be migrated; the data structure refers to a collection of data elements with one or more relationships between the data sets to be migrated, for example, in the customer insurance data, the customer Insurance relationship with different insurance types.
本发明一实施例中,所述编排规则可以根据实际场景自定义,比如,保险领域中,数据源表中的待迁移数据集将所有客户的投保情况表,则编排规则可以为根据客户类别进行编排,当识别到客户类型为个体客户则编排至个体表,识别到客户类型为团体客户则编排至团体表。In an embodiment of the present invention, the arrangement rules can be customized according to actual scenarios. For example, in the insurance field, the data set to be migrated in the data source table lists the insurance application status of all customers, and the arrangement rules can be based on customer categories. Arrangement, when it is identified that the customer type is an individual customer, it is arranged to the individual table, and the customer type is recognized to be a group customer, it is arranged to the group table.
所述数据切分模块103,用于将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集。The
将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集。A segmentation operation is performed on the data set to be migrated, and the segmented data set to be migrated is obtained.
本发明实施例中,所述切分待迁移数据集是指对所述编排待迁移数据集进行分库、分表后的数据。In the embodiment of the present invention, the dividing the data set to be migrated refers to the data after the data set to be migrated is divided into databases and tables.
本发明实施例通过将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,可以避免因大量数据一次性迁移过程中出现的异常场景导致整体数据迁移失败的后果,便于在数据迁移过程出现异常时,通过识别切分待迁移数据集中的异常待迁移数据集,只需重新进行异常待迁移数据集的数据迁移修复,并保证数据迁移过程中的数据完整性。In the embodiment of the present invention, the data set to be migrated is obtained by dividing the data set to be migrated, which can avoid the consequence of the failure of the overall data migration caused by the abnormal scenario that occurs during the one-time migration of a large amount of data, and is convenient for When an abnormality occurs in the data migration process, by identifying and dividing the abnormal data set to be migrated in the data set to be migrated, it is only necessary to perform data migration and repair of the abnormal data set to be migrated again, and ensure the data integrity during the data migration process.
作为本发明的一个实施例,所述数据切分模块103通过执行下述操作将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,包括:As an embodiment of the present invention, the
将所述数据源库进行分库操作,得到多个数据源分库;Performing a sub-database operation on the data source database to obtain a plurality of data source sub-databases;
在多个所述数据源分库中进行分表操作,得到多个数据源分表;Perform a table splitting operation in a plurality of the data source sub-databases to obtain a plurality of data source sub-tables;
根据多个所述数据源分表将所述编排待迁移数据集进行切分,得到所述切分待迁移数据集。Divide the data set to be migrated according to the plurality of data source sub-tables to obtain the divided data set to be migrated.
其中,由于数据源库的性能限制,导致数据源库的数据库容量不能过大,需要对数据源库进行分库操作,得到多个数据源分库,比如,数据源库为A,则多个数据源分库可以为A1、A2、A3及A4等;将数据源分库进行分表操作是为了防止数据表存储的记录数据较多,避免数据迁移的异常中断,还可以在该分表数据出现异常情况时,不会影响其他分表数据的迁移,比如,数据源分库数量为六个,且每个分库中都存储十个分表,则数据源分表总共为六十个,根据所述数据源分表将待迁移数据集进行切分,可以六十个切分待迁移数据集。Among them, due to the performance limitations of the data source database, the database capacity of the data source database cannot be too large, and the data source database needs to be sub-database operation to obtain multiple data source sub-databases, for example, if the data source database is A, then multiple The data source sub-database can be A1, A2, A3, A4, etc.; the data source sub-database is divided into tables to prevent the data table from storing more record data and avoid abnormal interruption of data migration. When an exception occurs, it will not affect the migration of other sub-table data. For example, if the number of data source sub-databases is six, and each sub-database stores ten sub-tables, the total number of data source sub-tables is 60. The data set to be migrated is segmented according to the data source segment table, and sixty data sets to be migrated can be segmented.
所述数据迁移模块104,用于创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中。The
本发明实施例中,所述数据迁移任务是指切分待迁移数据集迁移至数据迁移目标表中的任务。比如,切分待迁移数据集为保险公司的所有客户投保信息,则数据迁移任务为普通客户车险投保信息、普通客户重疾险投保信息、VIP客户重疾险投保信息及VIP客户车险投保信息等数据迁移任务。In the embodiment of the present invention, the data migration task refers to the task of dividing the data set to be migrated and migrating to the data migration target table. For example, if the data set to be migrated is divided into the insurance information of all customers of an insurance company, the data migration task is the insurance information of ordinary customers, critical illness insurance, VIP customers, and VIP customers. Data migration tasks.
本发明实施例中,所述预设的优先级是指用户根据需求进行多个数据迁移任务的自定义优先级排序,比如,第一级可以为VIP客户车险投保信息、第二级可以为VIP客户重疾险投保信息、第三级可以为普通客户重疾险投保信息、第四级可以为普通客户车险投保信息。In the embodiment of the present invention, the preset priority refers to the user-defined priority ordering of multiple data migration tasks according to requirements. For example, the first level may be the auto insurance application information of VIP customers, and the second level may be VIP customers. Customer critical illness insurance insurance information, third-level critical illness insurance insurance information for ordinary customers, and fourth-level auto insurance insurance information for ordinary customers.
本发明实施例通过创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,可以实现数据迁移任务的智能调度,提高数据迁移效率。In the embodiment of the present invention, by creating a plurality of data migration tasks for dividing the data set to be migrated, and sorting the plurality of data migration tasks according to a preset priority, a sorted data migration task is obtained, and according to the sorting data The migration task migrates the divided data set to be migrated to the data migration target table, which can realize intelligent scheduling of data migration tasks and improve data migration efficiency.
详细地,所述数据迁移模块104通过执行下述操作创建所述切分待迁移数据集的多个数据迁移任务,包括:Specifically, the
获取所述切分待迁移数据集的切分编号及切分地址;将所述切分待迁移数据集与对应的所述切分编号及所述切分地址分别进行关联,得到所述切分待迁移数据集的多个数据迁移任务。Obtain the segment number and segment address of the segmented data set to be migrated; associate the segmented data set to be migrated with the corresponding segment number and segment address, respectively, to obtain the segment Multiple data migration tasks for the dataset to be migrated.
进一步地,所述根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,包括:Further, migrating the segmented data set to be migrated to the data migration target table according to the sorting data migration task includes:
执行所述排序数据迁移任务,利用预设的插件读取所述排序数据迁移任务的执行参数;将所述执行参数与预设的负荷系数进行对比;当所述执行参数未超过所述负荷系数阈值时,利用预设的数据迁移工具将所述切分待迁移数据集通过预设的迁移线程加载至所述数据迁移目标表中;当所述执行参数超过所述负荷系数阈值时,新增多个迁移线程,利用所述数据迁移工具依次将所述切分待迁移数据集通过多个所述迁移线程加载至所述数据迁移目标表中。Execute the sorting data migration task, and use a preset plug-in to read the execution parameters of the sorting data migration task; compare the execution parameters with the preset load factor; when the execution parameter does not exceed the load factor When the threshold is set, use a preset data migration tool to load the segmented data set to be migrated into the data migration target table through a preset migration thread; when the execution parameter exceeds the load factor threshold, add a new Multiple migration threads, using the data migration tool to sequentially load the segmented data set to be migrated into the data migration target table through the multiple migration threads.
其中,所述执行参数是指所述排序数据迁移任务在执行过程中数据迁移目标表所处的目标数据库的资源消耗参数,比如,数据库连接数、tps、qps、CPU、内存等数据库的运行负荷系数;所述预设的负荷系数阈值为80%。The execution parameter refers to the resource consumption parameter of the target database where the data migration target table is located during the execution of the sorting data migration task, for example, the operating load of the database such as the number of database connections, tps, qps, CPU, memory, etc. coefficient; the preset load coefficient threshold is 80%.
本发明一实施例中,所述排序数据迁移任务是通过迁移线程执行的,通过目标数据库的资源消耗可以通过不同的线程执行任务,实现任务执行的智能调度,并提高数据迁移的迁移效率。In an embodiment of the present invention, the sorting data migration task is performed by a migration thread, and the task can be performed by different threads according to the resource consumption of the target database, so as to realize intelligent scheduling of task execution and improve the migration efficiency of data migration.
较佳的,所述数据迁移工具可以为KETTLE工具。Preferably, the data migration tool may be a KETTLE tool.
本发明另一实施例中,所述数据迁移模块104还可用于:In another embodiment of the present invention, the
根据预设的全量规则核对所述切分待迁移数据集与所述数据迁移目标表中的全量迁移数据集的一致性,当所述切分待迁移数据集与所述全量迁移数据集不一致时,记录所述切分待迁移数据集的迁移异常点,根据所述迁移异常点,重新执行切分待迁移数据集的数据迁移;根据预设的增量规则核对所述切分待迁移数据集与所述数据迁移目标表中的增量迁移数据集的一致性,当所述切分待迁移数据集与所述增量迁移数据集不一致时,记录所述切分待迁移数据集的迁移异常点,根据所述迁移异常点,重新执行切分待迁移数据集的数据迁移。Check the consistency of the split data set to be migrated and the full migration data set in the data migration target table according to the preset full volume rule. When the split to be migrated data set is inconsistent with the full migration data set , record the migration abnormal point of the divided data set to be migrated, re-execute the data migration of the divided data set to be migrated according to the migration abnormal point; check the divided data set to be migrated according to the preset increment rule Consistency with the incremental migration data set in the data migration target table, when the split data set to be migrated is inconsistent with the incremental migration data set, record the migration exception of the split data set to be migrated point, re-execute the data migration of dividing the data set to be migrated according to the migration abnormal point.
其中,所述全量规则主要作用是识别源数据表在指定时间内的存储的切分待迁移数据集在迁移至数据目标表中的全量迁移数据集是否同步,且数据源表的变化会实时反应至数据迁移目标表,最终数据源表的切分迁移数据集与全量迁移数据集一致;所述增量规则主要作用是在不停产的情况下实现的数据迁移的同步。The main function of the full-scale rule is to identify whether the full-scale migration data set stored in the source data table within a specified period of time is synchronized with the full-scale migration data set migrated to the data target table, and changes in the data source table will be reflected in real time. To the data migration target table, the split migration data set of the final data source table is consistent with the full migration data set; the main function of the incremental rule is to realize the synchronization of data migration without production interruption.
比如,2022年2月2日前数据源表的数据迁移都看作全量数据迁移,2022年2月2日后数据源表的数据迁移都看作增量数据迁移。For example, data migration of data source tables before February 2, 2022 is regarded as full data migration, and data migration of data source tables after February 2, 2022 is regarded as incremental data migration.
本发明实施例中,首先通过将所述待迁移数据集进行数据编排,得到编排待迁移数据集,可以避免由于数据源表中的数据结构与数据迁移目标表的数据结构不一致,导致后续待迁移数据集进行迁移时出现异常;其次,将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集,可以避免因大量数据一次性迁移过程中出现的异常场景导致整体数据迁移失败的后果,便于在数据迁移过程出现异常时,通过识别切分待迁移数据集中的异常待迁移数据集,只需重新进行异常待迁移数据集的数据迁移修复,保证数据迁移过程中的数据完整性;最后根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中,可以实现数据迁移任务的智能调度,提高数据迁移效率。因此本发明实施例提出的数据迁移装置可以提高数据迁移效率。In the embodiment of the present invention, the data set to be migrated is obtained by first performing data arrangement on the data set to be migrated, which can avoid subsequent migration due to inconsistency between the data structure in the data source table and the data structure of the data migration target table. An exception occurs when the data set is migrated; secondly, the data set to be migrated is divided into the data set to be divided, which can avoid the failure of the overall data migration due to abnormal scenarios that occur during the one-time migration of a large amount of data. The result is that when an exception occurs in the data migration process, by identifying and dividing the abnormal data set to be migrated in the data set to be migrated, it is only necessary to perform data migration and repair of the abnormal data set to be migrated again to ensure data integrity during the data migration process. Finally, according to the sorted data migration task, the segmented data set to be migrated is migrated to the data migration target table, which can realize intelligent scheduling of data migration tasks and improve data migration efficiency. Therefore, the data migration apparatus provided by the embodiments of the present invention can improve the data migration efficiency.
如图5所示,是本发明实现数据迁移方法的电子设备的结构示意图。As shown in FIG. 5 , it is a schematic structural diagram of an electronic device implementing the data migration method of the present invention.
所述电子设备可以包括处理器10、存储器11、通信总线12和通信接口13,还可以包括存储在所述存储器11中并可在所述处理器10上运行的计算机程序,如数据迁移程序。The electronic device may include a
其中,所述存储器11至少包括一种类型的介质,所述介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、本地磁盘、光盘等。所述存储器11在一些实施例中可以是电子设备的内部存储单元,例如该电子设备的移动硬盘。所述存储器11在另一些实施例中也可以是电子设备的外部存储设备,例如电子设备上配备的插接式移动硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡、闪存卡(Flash Card)等。进一步地,所述存储器11还可以既包括电子设备的内部存储单元也包括外部存储设备。所述存储器11不仅可以用于存储安装于电子设备的应用软件及各类数据,例如数据迁移程序的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。Wherein, the
所述处理器10在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing Unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。所述处理器10是所述电子设备的控制核心(Control Unit),利用各种接口和线路连接整个电子设备的各个部件,通过运行或执行存储在所述存储器11内的程序或者模块(例如数据迁移程序等),以及调用存储在所述存储器11内的数据,以执行电子设备的各种功能和处理数据。In some embodiments, the
所述通信总线12可以是外设部件互连标准(PerIPheral ComponentInterconnect,简称PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。所述通信总线12总线被设置为实现所述存储器11以及至少一个处理器10等之间的连接通信。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The
图5仅示出了具有部件的电子设备,本领域技术人员可以理解的是,图5示出的结构并不构成对所述电子设备的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。FIG. 5 only shows an electronic device with components. Those skilled in the art can understand that the structure shown in FIG. 5 does not constitute a limitation on the electronic device, and may include fewer or more components than those shown in the drawings. , or a combination of certain components, or a different arrangement of components.
例如,尽管未示出,所述电子设备还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器10逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。For example, although not shown, the electronic device may also include a power source (such as a battery) for powering the various components, preferably, the power source may be logically connected to the at least one
可选地,所述通信接口13可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备与其他电子设备之间建立通信连接。Optionally, the
可选地,所述通信接口13还可以包括用户接口,用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备中处理的信息以及用于显示可视化的用户界面。Optionally, the
应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。It should be understood that the embodiments are only used for illustration, and are not limited by this structure in the scope of the patent application.
所述电子设备中的所述存储器11存储的数据迁移程序是多个计算机程序的组合,在所述处理器10中运行时,可以实现:The data migration program stored in the
获取数据源表中的待迁移数据集及数据迁移目标表;Obtain the data set to be migrated and the data migration target table in the data source table;
将所述待迁移数据集进行数据编排,得到编排待迁移数据集;Perform data arrangement on the data set to be migrated to obtain a data set to be migrated;
将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集;performing a segmentation operation on the data set to be migrated, to obtain a segmented data set to be migrated;
创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中。Create multiple data migration tasks for dividing the data set to be migrated, sort the multiple data migration tasks according to preset priorities to obtain sorted data migration tasks, and transfer the data migration tasks according to the sorted data migration tasks The data set to be migrated is divided and migrated to the data migration target table.
具体地,所述处理器10对上述计算机程序的具体实现方法可参考图1对应实施例中相关步骤的描述,在此不赘述。Specifically, for the specific implementation method of the above-mentioned computer program by the
进一步地,所述电子设备集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取介质中。所述计算机可读介质可以是非易失性的,也可以是易失性的。所述计算机可读介质可以包括:能够携待所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。Further, if the modules/units integrated in the electronic device are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable medium. The computer-readable medium may be non-volatile or volatile. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) ).
本发明实施例还可以提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序在被电子设备的处理器所执行时,可以实现:Embodiments of the present invention may further provide a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when executed by a processor of an electronic device, the computer program may implement:
获取数据源表中的待迁移数据集及数据迁移目标表;Obtain the data set to be migrated and the data migration target table in the data source table;
将所述待迁移数据集进行数据编排,得到编排待迁移数据集;Perform data arrangement on the data set to be migrated to obtain a data set to be migrated;
将所述编排待迁移数据集进行切分操作,得到切分待迁移数据集;performing a segmentation operation on the data set to be migrated, to obtain a segmented data set to be migrated;
创建所述切分待迁移数据集的多个数据迁移任务,将多个所述数据迁移任务按照预设的优先级进行排序,得到排序数据迁移任务,并根据所述排序数据迁移任务将所述切分待迁移数据集迁移至所述数据迁移目标表中。Create multiple data migration tasks for dividing the data set to be migrated, sort the multiple data migration tasks according to preset priorities to obtain sorted data migration tasks, and transfer the data migration tasks according to the sorted data migration tasks The data set to be migrated is divided and migrated to the data migration target table.
进一步地,所述计算机可读存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据区块链节点的使用所创建的数据等。Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function, and the like; The data created by the use of the node, etc.
在本发明所提供的几个实施例中,应该理解到,所揭露的介质、设备、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed medium, apparatus, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division manners in actual implementation.
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and components shown as modules may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本发明各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.
对于本领域技术人员而言,显然本发明不限于上述示范性实施例的细节,而且在不背离本发明的精神或基本特征的情况下,能够以其他的具体形式实现本发明。It will be apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, but that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics of the invention.
因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本发明的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本发明内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。Therefore, the embodiments are to be regarded in all respects as illustrative and not restrictive, and the scope of the invention is to be defined by the appended claims rather than the foregoing description, which are therefore intended to fall within the scope of the claims. All changes within the meaning and range of the equivalents of , are included in the present invention. Any reference signs in the claims shall not be construed as limiting the involved claim.
本发明所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。Furthermore, it is clear that the word "comprising" does not exclude other units or steps and the singular does not exclude the plural. Several units or means recited in the system claims can also be realized by one unit or means by means of software or hardware. Second-class terms are used to denote names and do not denote any particular order.
最后应说明的是,以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或等同替换,而不脱离本发明技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent substitutions can be made without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210512455.6A CN114860690A (en) | 2022-05-12 | 2022-05-12 | Data migration method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210512455.6A CN114860690A (en) | 2022-05-12 | 2022-05-12 | Data migration method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114860690A true CN114860690A (en) | 2022-08-05 |
Family
ID=82637392
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210512455.6A Pending CN114860690A (en) | 2022-05-12 | 2022-05-12 | Data migration method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114860690A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117149915A (en) * | 2023-10-31 | 2023-12-01 | 湖南三湘银行股份有限公司 | Method for migrating cloud database to open source database |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112068937A (en) * | 2020-07-29 | 2020-12-11 | 苏州浪潮智能科技有限公司 | A Software Adaptive Multithreading Control Method Based on Load Efficiency and Priority |
CN113051245A (en) * | 2019-12-26 | 2021-06-29 | 云丁网络技术(北京)有限公司 | Method, device and system for migrating data |
CN113297182A (en) * | 2021-06-16 | 2021-08-24 | 中国农业银行股份有限公司 | Data migration method, device, storage medium and program product |
CN114090547A (en) * | 2021-11-29 | 2022-02-25 | 平安养老保险股份有限公司 | A method, device, computer equipment and storage medium for data migration |
-
2022
- 2022-05-12 CN CN202210512455.6A patent/CN114860690A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113051245A (en) * | 2019-12-26 | 2021-06-29 | 云丁网络技术(北京)有限公司 | Method, device and system for migrating data |
CN112068937A (en) * | 2020-07-29 | 2020-12-11 | 苏州浪潮智能科技有限公司 | A Software Adaptive Multithreading Control Method Based on Load Efficiency and Priority |
CN113297182A (en) * | 2021-06-16 | 2021-08-24 | 中国农业银行股份有限公司 | Data migration method, device, storage medium and program product |
CN114090547A (en) * | 2021-11-29 | 2022-02-25 | 平安养老保险股份有限公司 | A method, device, computer equipment and storage medium for data migration |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117149915A (en) * | 2023-10-31 | 2023-12-01 | 湖南三湘银行股份有限公司 | Method for migrating cloud database to open source database |
CN117149915B (en) * | 2023-10-31 | 2024-03-29 | 湖南三湘银行股份有限公司 | Method for migrating cloud database to open source database |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022121171A1 (en) | Similar text matching method and apparatus, and electronic device and computer storage medium | |
WO2021169173A1 (en) | Data clustering storage method and apparatus, computer device, and storage medium | |
CN112052370A (en) | Message generation method and device, electronic equipment and computer readable storage medium | |
WO2022160449A1 (en) | Text classification method and apparatus, electronic device, and storage medium | |
CN112418798A (en) | Information auditing method, device, electronic device and storage medium | |
CN112699142A (en) | Cold and hot data processing method and device, electronic equipment and storage medium | |
CN112347122B (en) | SQL workflow processing method, device, electronic equipment and storage medium | |
WO2022179119A1 (en) | Data verification method and apparatus, electronic device, and readable storage medium | |
CN114881616A (en) | Business process execution method and device, electronic equipment and storage medium | |
CN113590632A (en) | Database index creating method, device, equipment and medium | |
CN112631731A (en) | Data query method and device, electronic equipment and storage medium | |
CN111538573A (en) | Asynchronous task processing method, device and computer-readable storage medium | |
CN112256783A (en) | Data export method and device, electronic equipment and storage medium | |
CN111984731A (en) | Data synchronization method, device and storage medium between data warehouses of big data platform | |
CN114860690A (en) | Data migration method, device, equipment and storage medium | |
CN114880368A (en) | Data query method and device, electronic equipment and readable storage medium | |
CN112685384A (en) | Data migration method and device, electronic equipment and storage medium | |
CN105426119A (en) | Storage apparatus and data processing method | |
WO2022134345A1 (en) | File access method, apparatus, device, and readable storage medium | |
CN114626103A (en) | Data consistency comparison method, device, equipment and medium | |
CN113434397B (en) | Task system testing method and device, electronic equipment and storage medium | |
CN113360505B (en) | Time sequence data-based data processing method and device, electronic equipment and readable storage medium | |
CN113946543A (en) | Data archiving method, device, equipment and storage medium based on artificial intelligence | |
CN114911479A (en) | Interface generation method, device, equipment and storage medium based on configuration | |
CN114238233A (en) | Automatic file cleaning method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |