Multi-database data migration method, storage medium and electronic equipment

Through the Druid library, SQL instructions are parsed and field mapping relationships are established, automatic data migration between multiple databases is realized, cumbersome problems of data migration process are solved, and development efficiency and richness of data processing are improved.

CN118885455AActive Publication Date: 2024-11-01MOBILE TECH COMPANY CHINA TRAVELSKY HLDG

Patent Information

Application Number
CN202410900326.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-11-01
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

In multiple business scenarios, the data migration process is cumbersome and time-consuming, resulting in inefficient development. Especially when data tables involving multiple different databases are involved, data acquisition programs need to be developed manually, which increases the development difficulty and time cost.

Method used

Provide a multi-database data migration method, using the Druid library to parse SQL operation instructions, generate parsing results and establish field mapping relationships, and automatically perform data migration through the data migration system, supporting multi-field aggregation and processing of SQL statements, reducing developers The requirement of manually writing a data acquisition program.

Benefits of technology

It improves the automation level and development efficiency of data migration, simplifies the data migration process between multiple databases, enhances the practicality and richness of data, and reduces the workload of developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885455A_ABST
    Figure CN118885455A_ABST
Patent Text Reader

Abstract

The invention relates to the field of data processing, in particular to a multi-database data migration method, a storage medium and electronic equipment. Comprising the steps that if a data reading instruction is an SQL operation instruction, SQL analysis is conducted on the SQL operation instruction, and an operation result field and storage position information are generated; if the verification is passed, taking the operation result field as a to-be-migrated field; obtaining a corresponding target receiving field written into the database; and establishing a mapping relationship between the to-be-migrated field and the target receiving field to perform data migration. After a developer inputs the data reading instruction or the data writing instruction, the corresponding storage component can be automatically used for calling the target field in the corresponding database according to the specific parameter information carried in the instruction, and the field mapping relation of data migration is formed, so that subsequent data migration is facilitated. Developers do not need to develop corresponding data acquisition programs by themselves in the process, and the development efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In the prior art, when technical personnel are developing applications for corresponding business scenarios, they usually have to deal with the storage of business data. And when developing business, technical personnel may choose different storage components based on the specific needs of the project, technology stack, performance requirements, cost budget, team familiarity and other factors. For example, for scenarios that require transaction consistency and complex query capabilities, storage components suitable for storing structured data will be selected, such as MySQL, PostgreSQL, Oracle, SQL Server, etc. For scenarios that store large amounts of unstructured data, such as pictures, videos, backup files, etc., storage components such as Amazon S3 and Azure Blob Storage can be selected.

[0003] Based on this situation, when a business needs to use the data of another business, it usually requires technical personnel to use the corresponding storage components and develop corresponding programs to read and process the data and then store it in their own database for use, which is also called data migration. If a business application involves using data from multiple other businesses or different data tables in the same business during the development process, a lot of time and energy will be spent in the development process to complete the relatively basic and tedious data migration development work, thereby reducing development efficiency. Summary of the invention

[0004] In view of the above technical problems, the technical solution adopted by the present invention is:

[0005] According to one aspect of the present invention, a multi-database data migration method is provided, which is applied to a data migration system. The data migration system includes multiple databases and storage components corresponding to each database. The multiple databases are used to store different business data, and the types of the multiple databases are different; each database includes multiple data tables;

[0006] The method comprises the following steps:

[0007] Get data reading instructions;

[0008] If the data reading instruction is an SQL operation instruction, the Druid library is used to perform SQL parsing on the SQL operation instruction to generate a parsing result; the parsing result includes the storage location information corresponding to the operation result field and the data supply field, and the storage location information includes the storage table name and the storage field name; the SQL operation instruction is used to indicate that the preset operation is performed after reading the value of the corresponding data supply field in the database;

[0009] Verify and process SQL operation instructions based on storage location information;

[0010] If the verification passes, the operation result field will be used as the field to be migrated;

[0011] According to the data writing instruction, obtain the corresponding target receiving field written into the database;

[0012] Establish a mapping relationship between the fields to be migrated and the target receiving fields, and perform data migration based on the mapping relationship;

[0013] Verification processing, including:

[0014] Use the corresponding storage component to obtain the original field set corresponding to the table name stored in the database;

[0015] If the stored field names are a subset of the original field set, the validation passes.

[0016] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the multi-database data migration method described above is implemented.

[0017] According to a third aspect of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned multi-database data migration method when executing the computer program.

[0018] The present invention has at least the following beneficial effects:

[0019] The data migration system in the technical solution of the present invention integrates multiple databases and storage components corresponding to each database. Therefore, after the developer inputs a data read instruction or a data write instruction, the corresponding storage component can be automatically used to call the target field in the corresponding database according to the specific parameter information carried in the instruction, forming a field mapping relationship for data migration for subsequent data migration. In this process, the developer does not need to develop the corresponding data acquisition program by himself, which can improve development efficiency.

[0020] In addition, in the present invention, when acquiring the data to be migrated, it also supports setting the data reading instructions as SQL operation instructions formed by SQL statements, thereby enriching the diversity of data processing for the data to be migrated, such as performing operations such as aggregation, summation, and difference of multiple fields, that is, the initial data can be processed before migration to improve the practicality of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 The present invention provides a flowchart of a multi-database data migration method.

[0023] Figure 2 A flowchart of a method for executing a data migration task provided by an embodiment of the present invention. DETAILED DESCRIPTION

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

[0025] As a possible embodiment of the present invention, Figure 1 As shown, a multi-database data migration method is provided, which is applied to a data migration system. The data migration system includes multiple databases and storage components corresponding to each database. The multiple databases are used to store different business data, and the types of the multiple databases are different. Each database includes multiple data tables.

[0026] The multi-database data migration method in this embodiment may be a method for specifically operating a task information acquisition module in a data migration system, and is mainly used to more quickly and conveniently establish migration task information corresponding to data migration through simple and necessary parameters of a migration task input by a user, so as to facilitate the execution of subsequent migration tasks. Specifically, the method includes the following steps:

[0027] S100: Get data reading instruction. This instruction is input by the user according to his / her own needs. Usually, this instruction is used to indicate which fields of the existing database the user needs to obtain the required data from, that is, to indicate the fields to be migrated.

[0028] Usually, the fields to be migrated can be fields contained in a data table in the database, or can be new fields formed by processing multiple different fields. Of course, these fields can also be fields from different data tables in the same database.

[0029] Specifically, when the data reading instruction is an SQL operation instruction, a new field may be formed after processing a plurality of different fields, thereby improving the richness of the acquired data and further improving the availability of the data.

[0030] The following S200 to S400 are the corresponding methods for determining the fields to be migrated when the data reading instruction is an SQL operation instruction:

[0031] S200: If the data reading instruction is an SQL operation instruction, the Druid library is used to perform SQL parsing on the SQL operation instruction to generate a parsing result. The parsing result includes the storage location information corresponding to the operation result field and the data supply field, and the storage location information includes the storage table name and the storage field name. The SQL operation instruction is used to indicate that a preset operation is performed after reading the value of the corresponding data supply field in the database.

[0032] The above SQL operation instructions can be customized and edited by the user according to his own needs. SQL (Structured Query Language) is a standard language for managing relational databases, which can represent and execute a variety of database operations. The Druid library is an open source tool from Alibaba, which provides a powerful SQL parsing module that can parse SQL statements into an abstract syntax tree (AST), which is very useful for tasks such as SQL statement analysis, optimization, and rewriting. After using the Druid library for SQL parsing in this step, the user-defined various operation fields (that is, the operation result fields) and the storage location information corresponding to the data supply fields can be more accurately determined.

[0033] Specifically, the SQL operation instruction corresponding to the addition operation of different fields in two different tables is used as an example for explanation:

[0034] The SQL operation instructions entered are as follows:

[0035] SELECT

[0036] TableA.common_field,(TableA.field1+TableB.field2)AS sum_of_fields

[0037] FROM

[0038] TableA

[0039] INNER JOIN

[0040] TableB ON TableA.common_field=TableB.common_field;

[0041] In this example:

[0042] INNER JOIN is used to associate TableA and TableB based on the common_field field.

[0043] TableA.field1+TableB.field2 calculates the sum of these two fields in each row of records after the association.

[0044] AS sum_of_fields gives the calculated sum an alias for easy identification in query results.

[0045] In actual applications, users need to adjust the above SQL operation instructions according to the specific table structure and association logic. In this way, users can analyze and process existing data more flexibly and generate new data with more practical significance.

[0046] S300: Verify the SQL operation instruction according to the storage location information.

[0047] Verification processing, including:

[0048] S301: Use the corresponding storage component to obtain the original field set corresponding to the table name stored in the read database. The read database can be a hive database, a mysql database, an oracle database, or a doris database.

[0049] S302: If the stored field name is a subset of the original field set, the verification passes.

[0050] S303: If the intersection of the stored field name and the original field set is empty, a preset prompt message indicating that an error exists in the SQL operation instruction is generated.

[0051] S400: If the verification passes, the operation result field is used as the field to be migrated.

[0052] S300 performs a verification operation on the SQL operation instruction through the attribution relationship of the fields. Usually, since the SQL operation instruction is a command written by the user, there may be certain errors. Therefore, the verification of S300 can ensure the accuracy of the fields to be migrated that are subsequently obtained.

[0053] In addition, when the data reading instruction is data table location information, the original existing standard fields in the data table can be quickly extracted according to the steps in S210 to S230, so that the user can perform corresponding addition and deletion operations according to his own needs.

[0054] S210: If the data reading instruction is data table location information, the data table location information includes: database ID and data table ID, then according to the database ID, the corresponding storage component is called to read the data table to be migrated corresponding to the data table ID, and the original field set of the data table to be migrated corresponding to the data table ID is generated.

[0055] Usually, to obtain all the field information of the existing data table in the database, you can use SQL query or database management tools. The storage component in this step can be database management work.

[0056] Most database management tools (such as MySQL Workbench, Oracle SQL Developer, SQL Server Management Studio, etc.) provide a graphical interface that allows you to directly view the structure of the database table, including all field names, data types, lengths, whether to allow nulls, etc. Just connect to the database, select the target database and table, and you can usually see these details under tabs such as "Design" or "Table Information".

[0057] S220: In response to the field add / delete instruction, perform add / delete operations on the corresponding fields in the original field set.

[0058] S230: The remaining fields are used as fields to be migrated.

[0059] S500: According to the data writing instruction, a corresponding target receiving field in a writing database is obtained. The writing database may be a hive database, a mysql database, an oracle database, a doris database, an hdfs database, or an elasticsearch database.

[0060] S500 includes:

[0061] S501: Acquire data table location information corresponding to the target received data table. The data table location information includes: database ID and data table ID.

[0062] S502: calling the corresponding storage component according to the database ID to read the target receiving data table corresponding to the data table ID, and generating an original field set of the target receiving data table corresponding to the data table ID.

[0063] S503: In response to the field add / delete instruction, perform add / delete operations on the corresponding fields in the original field set.

[0064] S504: Use the remaining fields as target receiving fields.

[0065] Since in the actual data migration process, it is generally not necessary to modify the data in the target receiving data table, only the fields into which the data needs to be imported need to be determined, thus, the process can be the same as the steps in S210 to S230.

[0066] S600: Establish a mapping relationship between the field to be migrated and the target receiving field, and perform data migration according to the mapping relationship.

[0067] S600 includes:

[0068] S601: Obtain task dependency configuration information.

[0069] S602: When the conditions restricted by the task dependency configuration information are met, data migration is performed according to the mapping relationship.

[0070] The task dependency configuration information can be used to define the execution conditions of the corresponding data migration task. Since data migration requires obtaining data from the corresponding data table, and some data table information is also updated in real time, in order to ensure the accuracy of the data, it is usually necessary to perform data migration after the data table is updated. The above conditions are the dependencies of the task. Therefore, in order to better execute the data migration task based on the dependency, the following embodiments are provided.

[0071] As another possible embodiment of the present invention, Figure 2 As shown, a method for executing a data migration task is also provided, which is applied to a data migration system, wherein the data migration system also includes a data migration middle platform and a task scheduling platform. The data migration middle platform and the task scheduling platform are connected in communication. The task scheduling platform is an Apache DolphinScheduler task scheduling platform.

[0072] Apache DolphinScheduler (Dolphin Scheduling Platform) is a distributed and easily scalable visual DAG workflow task scheduling open source system. Suitable for enterprise-level scenarios, it provides a solution for visual operation tasks, workflows, and full life cycle data processing processes. Apache DolphinScheduler aims to solve complex big data task dependencies and provide applications with data and relationships in various OPS orchestrations. It solves the problem of complex dependencies in data research and development ETL (ExtractTransformLoad, which means extraction, transformation, and loading in Chinese) and the inability to monitor the health status of tasks. DolphinScheduler assembles tasks in a DAG (Directed Acyclic Graph, DAG) streaming manner, can monitor the execution status of tasks in a timely manner, and supports operations such as retry, failure to restore specified nodes, pause, resume, and terminate tasks.

[0073] The data migration task execution method includes the following steps:

[0074] W100: The data migration center obtains migration task configuration information. The migration task configuration information includes data migration information and task dependency configuration information. The data migration information in this embodiment is the mapping relationship between the to-be-migrated field and the target receiving field established in the above embodiment.

[0075] The migration task configuration information is the information obtained from the above embodiment.

[0076] Specifically, the task dependency configuration information includes the dependent task ID.

[0077] W101: Obtain the dependent task ID as follows:

[0078] W102: Obtain the dependent task ID corresponding to each newly created data migration task through the task scheduling platform.

[0079] The task scheduling platform in this implementation manages multiple tasks, including the established data migration tasks and other tasks, such as database data update tasks. Usually, these existing tasks will carry some dependency prompt information. Therefore, when the new data migration task needs to use the data in it, the corresponding task dependency configuration information can be written according to the dependency prompt information.

[0080] Since the newly created data migration task has not been processed by the task scheduling platform, no corresponding new task ID has been assigned to it. Therefore, the new task ID is still missing in the task dependency configuration information at this time.

[0081] W200: The data migration platform generates the execution script corresponding to the data migration task based on the acquired data migration information. The execution script is used to call the corresponding heterogeneous data source offline synchronization tool to perform data migration. The heterogeneous data source offline synchronization tool is the DataX heterogeneous data source offline synchronization tool. DataX is an open source heterogeneous data source offline synchronization tool from Alibaba, dedicated to achieving stable and efficient data synchronization between various heterogeneous data sources including relational databases (MySQL, Oracle, etc.), HDFS, Hive, ODPS, HBase, FTP, etc.

[0082] Since the basic data migration configuration information in the migration task configuration information is complete, an execution script can be generated from this information. The script is used by a heterogeneous data source offline synchronization tool (such as DataX) to perform data migration synchronization between different databases according to the existing data migration information.

[0083] W300: The data migration center sends the execution script to the task scheduling platform.

[0084] W400: The task scheduling platform performs compliance checks on the execution scripts and generates compliance results.

[0085] W500: If the compliance result is passed, the task scheduling platform generates a new task ID for the data migration task corresponding to the migration task configuration information and sends it to the data migration center.

[0086] After generating the compliance result, the method further includes:

[0087] W501: If the compliance result is that the inspection fails, the task scheduling platform generates a preset alarm message for the data migration task corresponding to the migration task configuration information and sends it to the data migration center. The preset alarm message is used to prompt that there is a problem with the corresponding execution script and it needs to be revised and uploaded again.

[0088] In the data migration system of this embodiment, the task scheduling platform is ultimately responsible for managing these newly created data migration tasks. Therefore, the generated execution script needs to be sent to the task scheduling platform for subsequent scheduling. Of course, in this embodiment, the task scheduling platform itself also needs to detect whether the execution script is compliant to ensure that each execution script stored thereon is a script that can run normally. To ensure the normal start of each subsequent task. At the same time, if the execution script is compliant, a new task ID that uniquely represents the task corresponding to the execution script will be generated, and the new task ID will be returned to the data migration center.

[0089] W600: The data migration center generates dependency execution instructions for the data migration task corresponding to the new task ID based on the new task ID and task dependency configuration information, and sends them to the task scheduling platform.

[0090] After the data migration center receives the new task ID, it can use the new task ID to complete the original task dependency configuration information that has missing information. Specifically, fill in the new task ID in the position where the ID needs to be changed in the task dependency configuration information. Then, the corresponding dependency execution instructions can be generated based on the improved task dependency configuration information.

[0091] W700: The task scheduling platform executes instructions according to dependency relationships. When the corresponding dependency conditions are met, the execution script is run to call the corresponding heterogeneous data source offline synchronization tool to perform data migration.

[0092] In this embodiment, the execution script and dependency execution instructions corresponding to the new data migration task can be imported into the task scheduling platform, and then the task scheduling platform executes the instructions according to the dependency relationship. When the corresponding dependency conditions are met, the execution script is run to call the corresponding heterogeneous data source offline synchronization tool to perform data migration. Therefore, in this embodiment, the corresponding dependency relationship can be added to any new data migration task, so as to more accurately and meticulously restrict the execution conditions of the task, and ultimately improve the accuracy of the data obtained during data migration.

[0093] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0094] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0095] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.

[0096] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0097] The electronic device according to this embodiment of the present invention is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0098] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: the at least one processor mentioned above, the at least one storage device mentioned above, and a bus connecting different system components (including storage devices and processors).

[0099] The storage stores program codes, which can be executed by the processor, so that the processor executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0100] The memory may include readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory, and may further include read only memory (ROM).

[0101] The storage may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0102] The bus may represent one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.

[0103] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may communicate with one or more devices that enable a user to interact with the electronic device, and / or may communicate with any device (e.g., routers, modems, etc.) that enables the electronic device to communicate with one or more other computing devices. Such communication may be performed through an input / output (I / O) interface. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter. The network adapter communicates with other modules of the electronic device through a bus. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0104] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0105] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0106] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable 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.

[0107] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0108] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0109] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0110] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0111] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0112] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A multi-database data migration method, It is characterized in that Applied to a data migration system, the data migration system includes multiple databases and storage components corresponding to each database, the multiple databases are used to store different business data, the types of the multiple databases are different; each database includes multiple data tables; The method comprises the following steps: Get data reading instructions; If the data reading instruction is an SQL operation instruction, the Druid library is used to perform SQL parsing on the SQL operation instruction to generate a parsing result; the parsing result includes the storage location information corresponding to the operation result field and the data supply field, and the storage location information includes the storage table name and the storage field name; the SQL operation instruction is used to indicate that a preset operation is performed after reading the value of the corresponding data supply field in the reading database; Verifying the SQL operation instruction according to the storage location information; If the verification passes, the operation result field is used as the field to be migrated; According to the data writing instruction, obtain the corresponding target receiving field written into the database; Establishing a mapping relationship between the to-be-migrated field and the target receiving field, and performing data migration according to the mapping relationship; The verification process includes: Using the corresponding storage component, obtain the original field set corresponding to the storage table name in the read database; If the stored field name is a subset of the original field set, the verification passes.

2. The method according to claim 1, It is characterized in that After obtaining the original field set corresponding to the storage table name in the read database, the method further includes: If the intersection of the stored field name and the original field set is empty, a preset prompt message indicating that an error exists in the SQL operation instruction is generated.

3. The method according to claim 1, It is characterized in that The reading database is a hive database, a mysql database, an oracle database, or a doris database.

4. The method according to claim 1, It is characterized in that The write database is a hive database, a mysql database, an oracle database, a doris database, an hdfs database, or an elasticsearch database.

5. The method according to claim 1, It is characterized in that The data table location information includes: database ID and data table ID; After acquiring the data read instruction, the method further includes: If the data reading instruction is data table location information, then calling the corresponding storage component according to the database ID to read the to-be-migrated data table corresponding to the data table ID, and generating an original field set of the to-be-migrated data table corresponding to the data table ID; In response to the field add / delete instruction, perform add / delete operations on the corresponding fields in the original field set; The remaining fields are considered as fields to be migrated.

6. The method according to claim 1, It is characterized in that According to the data writing instruction, the corresponding target receiving field in the writing database is obtained, including: Obtaining data table location information corresponding to the target receiving data table; the data table location information includes: database ID and data table ID; Calling the corresponding storage component according to the database ID to read the target receiving data table corresponding to the data table ID, and generating an original field set of the target receiving data table corresponding to the data table ID; In response to the field add / delete instruction, perform add / delete operations on the corresponding fields in the original field set; The remaining fields are used as the target receiving fields.

7. The method according to claim 1, It is characterized in that Establishing a mapping relationship between the to-be-migrated field and the target receiving field, and performing data migration according to the mapping relationship, including: Get task dependency configuration information; When the conditions restricted by the task dependency configuration information are met, data migration is performed according to the mapping relationship.

8. The method according to claim 7, It is characterized in that The data migration system also includes a data migration platform and a task scheduling platform; the data migration platform and the task scheduling platform are connected in communication; After obtaining the task dependency configuration information, the method further includes: The data migration center generates an execution script corresponding to the data migration task according to the acquired mapping relationship; the execution script is used to call the corresponding heterogeneous data source offline synchronization tool to perform data migration; The data migration platform sends the execution script to the task scheduling platform; The task scheduling platform performs compliance detection on the execution script and generates a compliance result; If the compliance result is that the inspection is passed, the task scheduling platform generates a new task ID for the data migration task corresponding to the migration task configuration information, and sends it to the data migration middle station; The data migration middle platform generates a dependency execution instruction of the data migration task corresponding to the new task ID according to the new task ID and the task dependency configuration information, and sends it to the task scheduling platform; The task scheduling platform executes instructions according to the dependency relationship, and when the corresponding dependency conditions are met, runs the execution script to call the corresponding heterogeneous data source offline synchronization tool to perform data migration.

9. A non-transitory computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, a multi-database data migration method as described in any one of claims 1 to 8 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the multi-database data migration method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • A method and apparatus for migrating data

    CN109284281A

  • Lightweight concurrent migration method of database

    CN112783859A

  • Data migration method and device

    CN112817930A

  • Unified sql processing method and device for heterogeneous relational database

    CN117971862A

Cited By

  • Method for accelerating migration of data warehouse data to doris

    CN119474062A