Data migration method and device, equipment, storage medium and product
By obtaining target data migration tasks from the preconfigured migration task table and using configured scripts to migrate data, the shortcomings of CDC technology in multi-table association and single-table split-table migration scenarios are solved, and efficient and accurate data migration is achieved. Meet the diverse needs of enterprises and reduce operation and maintenance costs.
Patent Information
- Application Number
- CN202410738817.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-08-27
AI Technical Summary
Existing CDC technology is inadequate in multi-table associated data migration and single-table data split-table migration scenarios, and cannot provide effective solutions, causing enterprises to face scalability and efficiency problems during the data migration process.
By obtaining the target data migration task from the preconfigured migration task table, determine the source data set and target data set, and perform data migration according to the preset migration pre-processing strategy and configured migration script, supporting multi-table data aggregation and single-data migration. Table data is migrated from table to table, providing a flexible configuration solution.
It improves the timeliness, accuracy and completeness of data migration, meets enterprises' needs for diverse data migration, reduces operation and maintenance costs, and improves operational efficiency.
Smart Images

Figure CN118550898A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data migration method, device, equipment, storage medium and product. Background Art
[0002] In enterprise big data application scenarios, it is often necessary to implement data migration between different platforms and heterogeneous databases. Currently, the technology CDC (Change Data Capture) is mainly used to capture database data change scenarios. It performs real-time data migration based on database logs and provides data replication that can maintain transaction integrity. It provides customers with a relatively complete solution in applications such as data migration, data integration, data synchronization, dynamic data warehouse, master data management, and real-time BI analysis.
[0003] Before CDC performs data migration, it is necessary to configure the migration objects, convert the database objects of the source database into DDL (Data Definition Language) executable by the target database, and then start the DDL target database execution without stopping the application to perform full data replication from the source database to the target database. For incremental data, the incremental data from the start time of replication to the end of full replication is matched, and the newly added data after the full replication of the source database is completed is synchronized to the target database in real time.
[0004] CDC technology supports table-level field name mapping, space removal, and conversion of empty strings to NULL values when migrating single-table data. However, it cannot cope with complex scenarios of multi-table associated data migration and single-table data migration. When two data tables with different structures need to merge data and migrate them to a new table, or a large data table needs to be divided according to customized rules and migrated to multiple new data tables, CDC technology cannot provide an effective response plan. Data migration can only rely on program development. Implementing a set of customized logic in the program limits the scalability of the tool's functions. Different data fusion / splitting solutions require the development of multiple programs to support data migration, which cannot meet enterprise requirements in terms of cost and efficiency.
[0005] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of this application is to provide a data migration method, device, equipment, storage medium and computer program product, aiming to improve the timeliness, accuracy and completeness of data migration in large data volume migration scenarios.
[0007] To achieve the above objectives, the present application proposes a data migration method, which includes:
[0008] Get the target data migration task from the pre-configured migration task table;
[0009] Determine a source data set and a target data set corresponding to the target data migration task;
[0010] Performing migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated;
[0011] The to-be-migrated data set is migrated to the target data set based on a preset configured migration script.
[0012] In one embodiment, the method further comprises:
[0013] Obtaining a migration task configuration table corresponding to the target data migration task;
[0014] Confirming the migration mapping relationship between the source data set and the target data set according to the migration task configuration table;
[0015] The step of migrating the to-be-migrated data set to the target data set based on a preset configured migration script includes:
[0016] Based on a preset configured migration script, the to-be-migrated data set is migrated to the target data set according to the migration mapping relationship.
[0017] In one embodiment, the step of performing migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain the data set to be migrated includes:
[0018] Determine the data migration type of the target data migration task according to the migration task configuration table;
[0019] Extracting data from the source data set according to the data migration type to obtain a source migration data set;
[0020] The source migration data set is preprocessed to obtain a data set to be migrated.
[0021] In one embodiment, the migration task configuration table is configured with a data extraction script, the data migration types include multi-table aggregation migration and single-table separation migration, and the step of extracting data from the source data set according to the data migration type to obtain the source migration data set includes:
[0022] If the data migration type is the multi-table aggregate migration, determining a number of aggregate data tables corresponding to the source data set;
[0023] Performing aggregate query on the plurality of aggregate data tables through the data extraction script, and extracting a plurality of aggregate data fields in the plurality of aggregate data tables to form a source migration data set;
[0024] If the migration type is single-table separation migration, determining the separation data table corresponding to the source data set;
[0025] The data extraction script is used to perform a separate query on the separation data table, and a number of separation data fields in the separation data table are extracted to form a source migration data set.
[0026] In one embodiment, the source migration data set includes a plurality of source migration data, and the step of performing data preprocessing on the source migration data set to obtain the data set to be migrated includes:
[0027] Establishing a data migration queue and several data migration threads corresponding to the target data migration task;
[0028] Storing the source migration data in the data migration queue;
[0029] According to a preset thread processing volume threshold, the source migration data in the data migration queue is sliced by the plurality of data migration threads to obtain a sliced data set;
[0030] Perform data pre-processing on the sharded data set to obtain a data set to be migrated.
[0031] In one embodiment, the step of performing data pre-processing on the sharded data set to obtain the data set to be migrated includes:
[0032] Obtain the pre-processing function configured in the migration task configuration table;
[0033] Performing data legitimacy verification and data integrity verification on the sharded data set;
[0034] The sharded data set is legalized and completed according to the pre-processing function to obtain the data set to be migrated.
[0035] In addition, to achieve the above-mentioned purpose, the present application also proposes a data migration device, which includes:
[0036] An acquisition module is used to acquire a target data migration task from a preconfigured migration task table;
[0037] A determination module, used to determine a source data set and a target data set corresponding to the target data migration task;
[0038] A processing module, configured to perform migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated;
[0039] The migration module is used to migrate the to-be-migrated data set to the target data set based on a preset configured migration script.
[0040] In addition, to achieve the above objectives, the present application also proposes a data migration device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the data migration method described above.
[0041] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the data migration method described above are implemented.
[0042] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the data migration method described above are implemented.
[0043] One or more technical solutions proposed in the present application obtain a target data migration task from a preconfigured migration task table; determine a source data set and a target data set corresponding to the target data migration task; perform migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated; and migrate the data set to be migrated to the target data set based on a preset configured migration script. Through the above method, specifically through a preset migration pre-processing strategy, after performing migration pre-processing on the source data, customized data migration is performed through a configured migration script. On the basis of ensuring the timeliness, data accuracy and data integrity of a large amount of data migration, a flexible configured solution is provided for multi-table data aggregation migration and single-table data sub-table migration. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0046] Figure 1 A flowchart of the first embodiment of the data migration method of this application is provided;
[0047] Figure 2 This is a schematic diagram of the implementation process of the data migration method for this application;
[0048] Figure 3 A brief flowchart of the data migration method provided in Example 2 of the present application;
[0049] Figure 4 This is a schematic diagram of the module structure of the data migration device according to an embodiment of the present application;
[0050] Figure 5 A schematic diagram of the device structure of the hardware operating environment involved in the data migration method in the embodiment of the present application.
[0051] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0053] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0054] The main solution of the embodiment of the present application is to provide a data migration configuration tool to perform customized data migration based on configured scripts, and to provide flexible configuration solutions for multi-table data aggregation migration and single-table data sub-table migration while ensuring the timeliness, data accuracy and data integrity of large-scale data migration.
[0055] First, obtain the list of data migration tasks to be executed from the migration task table, process multiple migration tasks in parallel through multi-threading, obtain the mapping relationship between the source data set field and the target data set field corresponding to each task from the configuration table, and flexibly modify the new table field name through configuration, and specify the specific data source field of the new table field, such as specifying that the col1 field of table C comes from the col5 field of table A, and execute the data query sql script in the configuration table. The script configuration can realize the migration of data sets after multi-table joint query, and support the scenario of multi-table data aggregation migration; for example, if some fields in table A and some fields in table B of two related tables need to be extracted and migrated to table C respectively, then first execute the associated query of tables AB through the script, and select the required fields to form a new data set to be migrated.
[0056] Through multiple threads simultaneously monitoring the queue, 2500 data in the queue are distributed to a single idle thread for processing. If there is a migration pre-processing function in the configuration table, the pre-processing function is executed for each batch of data. The pre-processing function can be flexibly implemented in the program through the interface and added to the configuration table; for example, the data with the same customer number hash value in the filter data are saved in the same table to achieve single-table data migration. The table partitioning algorithm can be flexibly adjusted in the specified way through the configuration. For the migration data set, date format conversion, numerical precision adjustment, space removal, empty string to NULL value processing and other data sorting operations are performed, and the SQL script for migrating data to the target table in the configuration table is executed to migrate the sorted data.
[0057] This solution supports multi-table data aggregation migration and single-table data sub-table migration. Compared with customized program application development, it supports various different data migration solutions more flexibly through configured scripts.
[0058] In the existing technology, CDC (Change Data Capture) is widely used in enterprise big data migration. It captures data changes in real time based on database logs to ensure transaction integrity. Before migration, you need to configure the migration object and execute DDL to adapt to the target database. CDC can handle field mapping during single table migration, but it is powerless when faced with complex scenarios such as multi-table association or single table migration. At present, handling these complex migration requirements usually relies on customized program development, which not only limits the scalability of the tool, but also increases cost and efficiency challenges, making it difficult to meet the efficient and flexible data migration needs of enterprises.
[0059] The present application provides a solution, which obtains a target data migration task from a preconfigured migration task table; determines a source data set and a target data set corresponding to the target data migration task; performs migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated; and migrates the data set to be migrated to the target data set based on a preset configured migration script. Through the above method, specifically through a preset migration pre-processing strategy, after performing migration pre-processing on the source data, customized data migration is performed through a configured migration script. On the basis of ensuring the timeliness, data accuracy and data integrity of a large amount of data migration, a flexible configured solution is provided for multi-table data aggregation migration and single-table data sub-table migration.
[0060] It should be noted that the execution subject of this embodiment may be a computing service device with data migration, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a data migration system, etc. The following takes the data migration system as an example to illustrate this embodiment and the following embodiments.
[0061] Based on this, the present application embodiment provides a data migration method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the data migration method of the present application.
[0062] In this embodiment, the data migration method includes steps S1000 to S4000:
[0063] Step S1000: Obtaining a target data migration task from a pre-configured migration task table;
[0064] It should be noted that the purpose of this embodiment is to provide a data migration method based on configuration to solve the problem that the traditional CDC (Change Data Capture) technology cannot effectively cope with the complex scenarios of multi-table related data migration and single-table data migration in enterprise big data application scenarios, especially in the process of data migration, data integration, data synchronization, etc. This solution aims to provide a flexible, efficient and accurate data migration solution to meet the diverse needs of enterprises for data migration through the method of configuration scripts.
[0065] In addition, it should be noted that the means used to achieve the above purpose, through the configuration script, users can flexibly define each link of data migration, including the mapping relationship between the source data set field and the target data set field, the data set migration rules after multi-table joint query, the pre-processing function, etc., so as to achieve comprehensive customization of the data migration process. And in order to improve the efficiency of data migration, this solution adopts a multi-threaded parallel processing method, which can handle multiple migration tasks at the same time, and multi-threaded concurrent processing is also used for the data processing in each task to make full use of system resources and speed up the data migration. During the data migration process, this solution supports a variety of data processing operations, such as date format conversion, numerical precision adjustment, space removal, empty string to NULL value processing, etc., to ensure the accuracy and integrity of the migrated data. In order to meet the specific needs of different data migrations, this solution allows users to specify multiple pre-processing functions in the configuration table. These functions can filter and pre-process the data before the data migration is executed, so as to achieve flexible control of the migrated data.
[0066] Through the method of configured scripts, this solution can flexibly respond to various complex data migration scenarios and meet the diverse needs of enterprises for data migration. The multi-threaded parallel processing method can significantly improve the efficiency of data migration, shorten the time of data migration, and reduce the operation and maintenance costs of enterprises. Through flexible data processing and pre-processing functions, this solution can ensure the accuracy and completeness of migrated data and reduce errors and losses in the data migration process. The pre-processing functions of this solution can be flexibly implemented and expanded through interfaces to adapt to changes in different migration data requirements in the future. In summary, this solution provides a flexible, efficient, and accurate data migration solution through the method of configured scripts, which can meet the diverse needs of enterprises for data migration, reduce the operation and maintenance costs of enterprises, and improve the operational efficiency of enterprises.
[0067] More specifically, see Figure 2 As shown, Figure 2 This is a schematic diagram of the implementation process of the data migration method of this embodiment. When the migration starts, the data migration system first checks the migration tasks to see whether there are any migration tasks in the list. If so, the migration tasks that need to be processed can be determined based on factors such as the generation order or priority of the migration tasks, that is, the target data migration tasks can be determined.
[0068] Step S2000: determining a source data set and a target data set corresponding to the target data migration task;
[0069] It should be noted that, in the present embodiment, the template data migration task corresponds to a source data set and a target data set. The source data set refers to the data source on which the data migration task needs to be executed, i.e., the migrated object; the target data set refers to the data source on which the migration data needs to be received, i.e., the migration object. The data migration task migrates the data to be migrated from the source data set to the target data set. Therefore, after determining the target data migration task, the corresponding source data set and target data set can be determined according to the target data migration task.
[0070] Step S3000: performing migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated;
[0071] It should be noted that before the formal data migration, the system may perform a series of pre-processing on the source data set according to actual needs. These pre-processing may include data cleaning (removing invalid or duplicate data), data conversion (such as field format conversion, data desensitization, etc.), data aggregation (merging data from multiple tables into one table), etc. These processing strategies are usually pre-set and stored in the configuration file for system calls. For example, in the user data migration task, due to the need for privacy protection, the system needs to desensitize the user email field in the "users" table. In addition, if the table structure of the new data warehouse is adjusted, the system also needs to split or merge some fields in the old table. These pre-processing strategies are pre-set and automatically applied to the source data set when the migration task is executed, so as to obtain a data set to be migrated that meets the migration requirements.
[0072] Step S4000: Migrate the to-be-migrated data set to the target data set based on a preset configured migration script.
[0073] It should be noted that after completing the pre-processing, the system can start to perform data migration operations. This can usually be achieved by running one or more configured migration scripts, which contain the specific logic and steps of data migration, such as connecting the source database and the target database, reading the data set to be migrated, and writing the data to the target data set. Since the script is configured, it can be flexibly adjusted according to different migration tasks.
[0074] For example, in a user data migration task, the system can connect to the source data set and the new data set according to the preset migration script. Then, it reads the pre-processed data set to be migrated (such as desensitized and adjusted user data) and writes it one by one to the "new_users" table of the new data warehouse. The entire migration process is automated, and the progress and results of the migration can be monitored and tracked through log records.
[0075] In a feasible implementation manner, a data migration method provided in this embodiment may further include steps S5000 to S6000:
[0076] Step S5000: Obtain a migration task configuration table corresponding to the target data migration task;
[0077] It should be noted that in the configuration-based data migration method of this embodiment, the configuration table is a tool for storing and managing various configuration information required in the data migration process. Such configuration information generally includes data source information, target database information, data mapping rules, conversion rules, filtering conditions, etc. The design of the configuration table makes the data migration process more flexible and configurable, and can meet the data migration requirements in different scenarios. It mainly involves retrieving a migration task configuration table related to a specific target data migration task from a storage system or database.
[0078] In addition, it should be noted that the configuration table corresponding to the data migration task in this embodiment can be used to manage data source information. The configuration table can store the type, address, port, user name, password and other connection information of the data source, so as to facilitate the rapid positioning and connection to the data source during the data migration process. It is also used to define the target database structure. Through the configuration table, the table structure, field type, primary key, foreign key and other information in the target database can be defined to ensure that the migrated data can be correctly stored in the target database. In addition, it can also be used to set data mapping rules. The configuration table can specify the mapping relationship between the source data and the target data, including field mapping, data type conversion, etc., to ensure the accuracy and consistency of data migration. Alternatively, it is used to define conversion and filtering rules. During the data migration process, it may be necessary to clean, convert or filter the data. The configuration table can store these rules, such as date format conversion, numerical precision adjustment, space removal processing, empty string conversion NULL value processing, etc. As well as being used to manage migration tasks, the configuration table can also be used to manage the execution plan, execution status, execution results and other information of the data migration task, so as to facilitate monitoring and management of the migration task.
[0079] In this embodiment, after determining the target migration task, the corresponding migration task configuration table can also be determined according to the target data migration task, so as to obtain configuration information including data source information, target database information, data mapping rules, conversion rules, filtering conditions, etc. First, it is necessary to determine the specific storage location of the migration task configuration table. Before accessing the migration task configuration table, the system can perform permission verification to ensure that only authorized users or processes can access this information, which can be achieved through username / password, API key, OAuth token or other authentication mechanism. After determining the storage location and passing the permission verification, the system can retrieve the migration task configuration table, which usually involves executing SQL queries (if the configuration table is stored in the database) or reading and parsing files (if the configuration table is stored in the form of files). For example, when the system receives a migration request, it retrieves the migration task configuration table related to the request. First, the system will connect to the cloud database storing the configuration table and use the API key stored in the service for authentication. Then, it will execute an SQL query to retrieve the configuration table of the target migration task. Finally, the system will verify the integrity and accuracy of the retrieved data to ensure that the migration process can proceed smoothly.
[0080] Step S6000: confirming the migration mapping relationship between the source data set and the target data set according to the migration task configuration table;
[0081] It should be noted that, in this embodiment, after the migration task configuration table is obtained, the migration mapping relationship between the source data set and the target data set may be further confirmed based on the information therein.
[0082] In a feasible implementation manner, the step S3000 may include:
[0083] Based on a preset configured migration script, the to-be-migrated data set is migrated to the target data set according to the migration mapping relationship.
[0084] First, the system can parse the migration task configuration table to extract information about the source data set and the target data set, including database name, table name, field name, data type, etc.
[0085] Based on the parsed information, the system can establish a mapping relationship between the source dataset and the target dataset. The mapping relationship includes one-to-one, one-to-many, or many-to-one mapping, depending on the requirements and configuration of the migration task. After the mapping relationship is established, the system can perform verification to ensure the accuracy and consistency of the mapping relationship. The verification can include checking whether the field names match, whether the data types are compatible, whether there are unmapped fields, etc. Finally, the established mapping relationship can be recorded by storing the mapping relationship in a database, file, or memory for use in subsequent data migration processes. Through the preset configured migration script, the configuration information of the dataset to be migrated and the configuration information of the migration target dataset are determined according to the migration mapping relationship, so as to migrate the dataset to be migrated to the target dataset.
[0086] After the system retrieves the migration task configuration table, it can further confirm the migration mapping relationship between the source and target datasets. First, the system parses the configuration table to extract the table name (such as "customers") and field names (such as "id", "name", "email") of the source database (such as MySQL), as well as the corresponding information of the target database (such as PostgreSQL). Then, the system establishes the field mapping relationship between the source table and the target table, such as mapping "id" to "customer_id" and "name" to "first_name" (and possibly creating an additional "last_name" field to store the split name information). After the mapping relationship is established, the system verifies that all fields have been mapped correctly and that the data types are compatible. Finally, the system stores these mapping relationships in the database for use in subsequent data migration processes.
[0087] The present embodiment provides a data migration method, including obtaining a target data migration task from a preconfigured migration task table; determining a source data set and a target data set corresponding to the target data migration task; performing migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated; and migrating the data set to be migrated to the target data set based on a preset configured migration script. Through the above method, a migration pre-processing strategy is specifically provided through a configured data migration script, and customized data migration is performed after the migration pre-processing is performed on the source data. On the basis of ensuring the timeliness, data accuracy and data integrity of a large amount of data migration, a flexible configured solution is provided for multi-table data aggregation migration and single-table data sub-table migration.
[0088] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 3, step S3000 of the data migration method may include steps S3100 to S3300:
[0089] Step S3100: determining the data migration type of the target data migration task according to the migration task configuration table;
[0090] It should be noted that, during the data migration process, different migration tasks may require different migration strategies and methods to adapt to different data structures and migration requirements. Therefore, before the migration begins, it is necessary to determine the data migration type of the current target data migration task according to the migration task configuration table. First, the system will read the migration task configuration table, which usually contains the configuration information of multiple migration tasks, including but not limited to the migration type, source data set, target data set, mapping relationship, etc. Then, the system will locate the corresponding configuration information according to the unique identifier (such as task ID) of the target data migration task to be executed. The data migration type field in the configuration information determines the strategy for subsequent data extraction and processing. There are many types of data migration, such as multi-table aggregation migration, single-table separation migration, full-table replication migration, etc. Each type has its specific application scenario and processing logic. By parsing the migration type field, the system can accurately determine the migration strategy that needs to be adopted for the current task and prepare for subsequent data extraction and preprocessing.
[0091] For example, in a migration task of user order migration, the task ID in the migration task configuration table is 1001, the migration type is multi-table aggregate migration, the source data set includes user table, order table, product table, etc., and the target data includes user order summary table. When executing this migration task, the system will first read the migration task configuration table and find the corresponding configuration information according to the task ID (1001). Then, the system will parse the value of the migration type field to "multi-table aggregate migration", thus determining that this task needs to aggregate the data in the user table, order table, and product table and migrate them to the user order summary table.
[0092] Step S3200: extracting data from the source data set according to the data migration type to obtain a source migration data set;
[0093] It should be noted that after determining the data migration type, you can further extract data from the source data set according to the type. Data extraction is an important step in the data migration process, which is mainly responsible for extracting the data to be migrated from the source data set.
[0094] The data extraction method varies for different migration types. For example, for multi-table aggregation migration, you may need to extract related data fields from multiple tables and perform aggregation operations. For single-table separation migration, you may only need to extract specific data fields from a single table. In the data extraction process, you can use SQL query statements or data extraction scripts to achieve it. These query statements or scripts can be written according to the migration type and the structure of the source data set to ensure that the required data can be accurately extracted.
[0095] As mentioned above, the user order migration task is a multi-table aggregate migration, so it is necessary to extract relevant data fields from the user table, order table, and product table. Assuming that fields such as user ID, user name, order ID, order amount, and product name need to be extracted, the following method can be used to implement data extraction through SQL query statements:
[0096] SELECT u.user_id,u.username,o.order_id,o.order_amount,p.product_nameFROM users u
[0097] JOIN orders o ON u.user_id=o.user_id
[0098] JOIN products p ON o.product_id=p.product_id;
[0099] Step S3300: performing data preprocessing on the source migration data set to obtain a data set to be migrated.
[0100] It should be noted that after obtaining the source migration data set, data preprocessing can also be performed on it to ensure the quality and consistency of the data. Data preprocessing is an indispensable step in the data migration process, which can include data cleaning, data conversion, data verification and other operations. The specific steps of data preprocessing may vary depending on the migration task. But generally speaking, we all need to perform data cleaning, data conversion and data verification on the source migration data set, among which data cleaning includes removing duplicate data, invalid data, empty data and other data that do not meet the requirements. Data conversion includes format conversion, unit conversion, encoding conversion and other operations on the data in the source migration data set according to the structure and format requirements of the target data set. Data verification includes legality verification and integrity verification of the cleaned and converted data to ensure the quality and accuracy of the data.
[0101] In a feasible implementation manner, the migration task configuration table is configured with a data extraction script, the data migration types include multi-table aggregation migration and single-table separation migration, and step S3200 may include steps S3210 to S3240:
[0102] Step S3210: If the data migration type is the multi-table aggregate migration, determine a number of aggregate data tables corresponding to the source data set;
[0103] It should be noted that during the data migration process, when you need to aggregate and migrate data from multiple tables, you first need to identify which tables are the source data tables involved in the aggregation. For example, suppose in a sales data system, you want to aggregate the relevant fields in the "Order Table" and the "Customer Information Table" to analyze the total order amount of each customer. In this case, the "Order Table" and the "Customer Information Table" are several aggregated data tables corresponding to the source data set.
[0104] For example, in the e-commerce order analysis data migration task, it is necessary to count the total order amount of each customer. To this end, the system uses the "order table" (including fields such as order ID, customer ID, order amount, etc.) and the "customer information table" (including fields such as customer ID, customer name, customer email, etc.) as aggregate data tables, and through the data migration configuration tool, specifies these two tables as source data sets, and prepares for subsequent aggregate query and data extraction.
[0105] Step S3220: performing aggregate query on the aggregate data tables through the data extraction script, and extracting a number of aggregate data fields in the aggregate data tables to form a source migration data set;
[0106] It should be noted that after determining the source data tables involved in the aggregation, the next step is to perform aggregation queries on these tables through the data extraction script. Aggregation queries can include JOIN operations, which are used to associate data from multiple tables based on one or more common fields (such as customer ID). During the query process, you can select the fields that need to be migrated and combine them into a new data set, namely the source migration data set.
[0107] In the example of the e-commerce order analysis data migration task mentioned above, the task configuration table pre-configures a data extraction script for extracting data from the "order table" and the "customer information table". The script first joins the two tables by customer ID, and then selects fields such as customer name and order amount to form a new data set. This data set contains the name of each customer and their order total, which is the source migration data set to be migrated next.
[0108] Step S3230: If the migration type is single-table separation migration, determine the separation data table corresponding to the source data set;
[0109] It should be noted that in some cases, the data migration task requires splitting the data in a large table into multiple small tables according to certain rules, that is, single-table separation migration. In this scenario, you first need to determine which table is the separated data table corresponding to the source data set.
[0110] For example, in an enterprise employee information management system, the data migration task needs to migrate an "employee information table" containing all employee information. Since the table has a huge amount of data and often needs to be queried by different departments or positions, it is split into multiple small tables during data migration, each of which contains employee information of a certain department or position. In this case, the "employee information table" is the separated data table corresponding to the source data set.
[0111] Step S3240: performing a separate query on the separate data table through the data extraction script, and extracting a number of separate data fields in the separate data table to form a source migration data set.
[0112] It should be noted that after determining the separation data table, the next step is to perform a separation query on the table through the data extraction script. The separation query, for example, uses the WHERE clause to filter out data based on the value of a certain field (such as department ID or position ID). During the query process, you can select the fields that need to be migrated and combine them into one or more new data sets, namely the source migration data sets.
[0113] In the example of the employee information management system mentioned above, when performing data migration tasks in the system, a data extraction script can be written to extract data from the employee information table. The script first filters out employee information of a certain department or position through the WHERE clause, and then selects fields such as employee ID, name, and position to form one or more new data sets. These data sets contain employee information of a specific department or position and are the source migration data sets to be migrated next.
[0114] In a feasible implementation manner, step S3300 may include steps S3310 to S3340:
[0115] Step S3310: establishing a data migration queue and several data migration threads corresponding to the target data migration task;
[0116] Step S3320: storing the source migration data into the data migration queue;
[0117] Step S3330: According to a preset thread processing volume threshold, the source migration data in the data migration queue is segmented by the plurality of data migration threads to obtain a segmented data set;
[0118] Step S3340: performing data pre-processing on the sharded data set to obtain a data set to be migrated.
[0119] It should be noted that in the process of data migration, establishing efficient and orderly data migration queues and data migration threads is a key step. First, refer to Figure 2 According to the characteristics and requirements of the target data migration task, the system creates a corresponding data migration queue. This queue will serve as a temporary storage and forwarding area for the source migration data to ensure the consistency and order of data migration. After the data migration task is started, the source data to be migrated can be stored in the previously established data migration queue in a specific format and order. This process needs to ensure the integrity and accuracy of the data to avoid data loss or confusion during the migration process. At the same time, the storage strategy and capacity of the queue can be dynamically adjusted according to the type and scale of the source data to ensure the smooth progress of the migration process. At the same time, according to the performance of the system and the scale of the migration task, several data migration threads can be dynamically generated or allocated. These threads will monitor the data migration queue at the same time, and when the data in the queue meets certain conditions (such as the amount of data reaches 2500), the batch of data will be processed through a separate idle thread, so that the established multi-thread can process the data in the data migration queue in parallel, improving the efficiency and speed of migration.
[0120] In addition, it should be noted that in order to improve the parallel processing capability and efficiency of data migration, the source data in the data migration queue can also be sharded. This process will be carried out according to the preset thread processing volume threshold to ensure that each data migration thread can obtain an appropriate amount of data for processing. At the same time, a suitable sharding strategy (such as hash sharding, range sharding, etc.) can be adopted to ensure that the sharded data set can be evenly distributed among the threads to achieve load balancing and efficient migration.
[0121] For example, in a data migration task, a data migration queue named "OrderMigrationQueue" is established, and 10 data migration threads (Thread1 to Thread10) are allocated. Each thread is responsible for processing a part of the data in the queue to ensure that the order data can be quickly and accurately migrated from the old system to the new system.
[0122] In the data migration process of this embodiment, data pre-processing can also be performed on the sharded data set. This process may include cleaning, converting, and verifying the sharded data to ensure the quality and accuracy of the data. Specific pre-processing operations include but are not limited to removing duplicate data, correcting erroneous data, and converting data formats. Through this process, we can obtain a data set to be migrated that meets the requirements of the target system and make full preparations for subsequent migration work.
[0123] In a feasible implementation manner, step S3340 may include steps S3341 to S3343:
[0124] Step S3341: Obtain the pre-processing function configured in the migration task configuration table;
[0125] Step S3342: performing data legitimacy verification and data integrity verification on the sharded data set;
[0126] Step S3343: perform legalization and integrity processing on the sharded data set according to the pre-processing function to obtain the data set to be migrated.
[0127] It should be noted that, in the data migration process of this embodiment, the pre-processing function can perform a series of pre-processing operations on the original data before data migration to ensure the accuracy and consistency of the data during the migration process. The system first obtains these configured pre-processing functions from the migration task configuration table.
[0128] For example, in a data migration task that contains a customer order data source, two pre-processing functions are configured: removeDuplicates and sanitizeData. The removeDuplicates function is used to remove duplicate records in the order data to ensure the uniqueness of each order, while the sanitizeData function is used to clean up illegal characters and formatting problems in the data, such as removing HTML tags in the order description or escaping special characters. The system reads the migration task configuration table, identifies the two pre-processing functions, and loads them into memory for use in subsequent steps. For details, please refer to Figure 2 As shown in the figure, if there is a migration pre-processing function in the configuration table corresponding to the target data migration task, the pre-processing function will be executed for each batch of data. The pre-processing function can be flexibly implemented in the program through the interface and added to the configuration table. For example, the data with the same customer number hash value in the filter data can be saved in the same table to achieve single-table data migration. The algorithm for splitting the tables can be flexibly adjusted through the configuration specified method. The migration pre-processing function can also be used to perform data sorting operations such as date format conversion, numerical precision adjustment, space removal, and empty string to NULL value processing on the migration data set.
[0129] In addition, it should be noted that after obtaining the pre-processing function, the system will perform data legitimacy verification and data integrity verification on the sharded data set (i.e., each thread that performs data migration processing separately). This is to ensure that before data migration, each piece of data is complete and legal, without missing or damaged. In the example above, the sharded data set may contain multiple order fragments. The system will verify each order fragment to check whether each order contains necessary fields (such as order ID, customer ID, order amount, etc.), and whether the data in these fields conform to the predefined format and range (such as order amount cannot be negative, customer ID must be a valid number or string, etc.). If any illegal or incomplete data is found, the system will record it and process it in subsequent steps.
[0130] After completing the data verification, the system will perform legalization and integrity processing on the sharded data set according to the pre-processing function obtained in step S3341. These processes may include removing duplicate data, cleaning illegal characters, formatting data, etc.
[0131] The system processes each order fragment according to the previously loaded removeDuplicates and sanitizeData pre-processing functions. First, the removeDuplicates function will traverse each order fragment, find and delete duplicate order records, and then the sanitizeData function will clean up the remaining order data, remove HTML tags and special characters in the order description, and ensure the cleanliness and consistency of the data. After these two steps, a clean, legal and complete data set to be migrated is obtained, and subsequent data migration operations can be carried out safely.
[0132] Finally, execute the SQL script that migrates the data in the configuration table to the target table to migrate the sorted data.
[0133] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the data migration method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0134] The present application also provides a data migration device 40, please refer to Figure 4 , the data migration device comprises:
[0135] An acquisition module 41 is used to acquire a target data migration task from a preconfigured migration task table;
[0136] A determination module 42, configured to determine a source data set and a target data set corresponding to the target data migration task;
[0137] The processing module 43 is used to perform migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated;
[0138] The migration module 44 is configured to migrate the to-be-migrated data set to the target data set based on a preset configured migration script.
[0139] The data migration device provided by the present application adopts the data migration method in the above embodiment to solve the technical problem of data migration. Compared with the prior art, the beneficial effects of the data migration device provided by the present application are the same as the beneficial effects of the data migration method provided by the above embodiment, and other technical features in the data migration device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0140] The present application provides a data migration device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data migration method in the above-mentioned embodiment one.
[0141] Reference below Figure 5 , which shows a schematic diagram of the structure of a data migration device suitable for implementing an embodiment of the present application. The data migration device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The data migration device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0142] like Figure 5As shown, the data migration device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the data migration device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the data migration device to communicate with other devices wirelessly or by wire to exchange data. Although the data migration device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0143] In particular, according to the embodiments disclosed in the present application, 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 application 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 a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0144] The data migration device provided by the present application adopts the data migration method in the above embodiment to solve the technical problem of data migration. Compared with the prior art, the beneficial effects of the data migration device provided by the present application are the same as the beneficial effects of the data migration method provided by the above embodiment, and the other technical features in the data migration device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0145] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0146] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0147] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the data migration method in the above-mentioned embodiment.
[0148] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, 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 this embodiment, the 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, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0149] The computer-readable storage medium may be included in the data migration device; or may exist independently without being assembled into the data migration device.
[0150] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the data migration device, the data migration device performs data migration.
[0151] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0152] 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 application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the 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 square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / 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.
[0153] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0154] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned data migration method, and can solve the technical problem of data migration. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the data migration method provided in the above-mentioned embodiment, and will not be elaborated here.
[0155] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned data migration method when executed by a processor.
[0156] The computer program product provided by the present application can solve the technical problem of data migration. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the data migration method provided by the above embodiment, which will not be repeated here.
[0157] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A data migration method, It is characterized in that The method comprises: Get the target data migration task from the pre-configured migration task table; Determine a source data set and a target data set corresponding to the target data migration task; Performing migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated; The to-be-migrated data set is migrated to the target data set based on a preset configured migration script.
2. The method according to claim 1, It is characterized in that The method further comprises: Obtaining a migration task configuration table corresponding to the target data migration task; Confirming the migration mapping relationship between the source data set and the target data set according to the migration task configuration table; The step of migrating the to-be-migrated data set to the target data set based on a preset configured migration script includes: Based on a preset configured migration script, the to-be-migrated data set is migrated to the target data set according to the migration mapping relationship.
3. The method according to claim 2, It is characterized in that The step of performing migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain the data set to be migrated includes: Determine the data migration type of the target data migration task according to the migration task configuration table; Extracting data from the source data set according to the data migration type to obtain a source migration data set; The source migration data set is preprocessed to obtain a data set to be migrated.
4. The method according to claim 3, It is characterized in that The migration task configuration table is configured with a data extraction script, the data migration types include multi-table aggregation migration and single-table separation migration, and the step of extracting data from the source data set according to the data migration type to obtain the source migration data set includes: If the data migration type is the multi-table aggregate migration, determining a number of aggregate data tables corresponding to the source data set; Performing aggregate query on the plurality of aggregate data tables through the data extraction script, and extracting a plurality of aggregate data fields in the plurality of aggregate data tables to form a source migration data set; If the migration type is single-table separation migration, determining the separation data table corresponding to the source data set; The data extraction script is used to perform a separate query on the separation data table, and a number of separation data fields in the separation data table are extracted to form a source migration data set.
5. The method according to claim 4, It is characterized in that The source migration data set includes a plurality of source migration data, and the step of performing data preprocessing on the source migration data set to obtain the data set to be migrated includes: Establishing a data migration queue and several data migration threads corresponding to the target data migration task; Storing the source migration data in the data migration queue; According to a preset thread processing volume threshold, the source migration data in the data migration queue is sliced by the plurality of data migration threads to obtain a sliced data set; Perform data pre-processing on the sharded data set to obtain a data set to be migrated.
6. The method according to claim 5, It is characterized in that The step of performing data pre-processing on the sharded data set to obtain the data set to be migrated includes: Obtain the pre-processing function configured in the migration task configuration table; Performing data legitimacy verification and data integrity verification on the sharded data set; The sharded data set is legalized and completed according to the pre-processing function to obtain the data set to be migrated.
7. A data migration device, It is characterized in that The device comprises: An acquisition module is used to acquire a target data migration task from a preconfigured migration task table; A determination module, used to determine a source data set and a target data set corresponding to the target data migration task; A processing module, configured to perform migration pre-processing on the source data set according to a preset migration pre-processing strategy to obtain a data set to be migrated; The migration module is used to migrate the to-be-migrated data set to the target data set based on a preset configured migration script.
8. A data migration device, It is characterized in that The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the data migration method according to any one of claims 1 to 6.
9. A storage medium, It is characterized in that The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the data migration method according to any one of claims 1 to 6 are implemented.
10. A computer program product, It is characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the data migration method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Data migration method and device, electronic equipment and computer readable storage medium
CN113568890A
Cited By
Data synchronization method, device and equipment, readable storage medium and program product
CN119537476A
Self-adaptive data management method and system
CN120763141A
