Database migration method and device, electronic equipment and storage medium
By obtaining and matching the initial call parameters and execution results generated during the database migration process, the problem of low efficiency of traditional database migration is solved, and the safe, efficient migration and adaptation of the database system is achieved.
Patent Information
- Application Number
- CN202510010483.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-05-02
AI Technical Summary
Traditional database migration methods are inefficient and no effective solution has been proposed.
By obtaining the initial calling parameters generated during the call of multiple first system data, executing multiple first system data using the second database, obtaining the execution results corresponding to different first system data, and matching the results, the data is stored in the target database only when the match is successful.
It realizes the secure and efficient migration of database system data, avoids database system crashes or data exceptions caused by compatibility issues, and achieves the rapid adaptation of software systems and efficient migration of data in the new database environment.
Smart Images

Figure CN119917487A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of civil aviation services, and in particular to a database migration method and device, electronic equipment, and storage medium. Background Art
[0002] In today's digital age, the rapid progress of information technology has greatly promoted the innovation of enterprise operation models and management methods. With the rise of technologies such as cloud computing, big data, and artificial intelligence, enterprises are highly dependent on software systems. Software systems, especially those that support core businesses, have become a key factor in corporate competitiveness.
[0003] As the core component of enterprise software systems, databases are responsible for storing and managing various business data. Their performance, security, and stability are directly related to the reliability of software systems and the continuity of enterprise business. However, traditional database migration methods are inefficient.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a database migration method and device, an electronic device, and a storage medium, so as to at least solve the technical problem of low database migration efficiency in the related art.
[0006] According to one aspect of an embodiment of the present invention, a database migration method is provided, comprising: in response to receiving a plurality of first system data waiting to be migrated, obtaining initial call parameters generated in the process of calling the plurality of first system data, wherein the first system data is used to characterize the system data of the system used by the first database currently requiring migration; based on the initial call parameters, executing the plurality of first system data using a second database to obtain first execution results corresponding to different first system data, wherein the data stored in the second database is the same as the data stored in the first database, and the first address of the first database is different from the second address of the second database; matching the first execution result with the second execution result to obtain a data matching result, wherein the second execution result is used to characterize the execution result of executing different first system data based on the first database; in response to the data matching result being that the first execution result successfully matches the second execution result, storing the first system data corresponding to the first execution result to a target database, wherein the database address of the target database is the second address.
[0007] Furthermore, the initial calling parameters include at least: calling time of different first system data; based on the initial calling parameters, using the second database to execute multiple first system data to obtain first execution results corresponding to different first system data, including: based on the calling time, constructing a system data sequence corresponding to multiple first system data; reading the second system data from the system data sequence in sequence, and obtaining configuration parameters of the second system data; executing the configuration parameters based on the second database to obtain the first execution result corresponding to the second system data.
[0008] Further, the second system data is read from the system data sequence in sequence, including: obtaining the third system data read from the system data sequence before the second system data; obtaining the target matching result matching the third system data from the data matching result; in response to the target matching result being the first execution result corresponding to the third system data, the second execution result corresponding to the third system data is successfully matched, and based on the calling time of the third system data, the second system data is read from the system data sequence.
[0009] Furthermore, the method also includes: in response to the target matching result being the first execution result corresponding to the third system data, the matching with the second execution result corresponding to the third system data fails, and the third system data and the second database are output; in response to receiving a data adjustment instruction, the third system data is adjusted based on the data adjustment instruction to obtain new third system data; and the new third system data is executed based on the second database to match the second execution result corresponding to the third system data to obtain a new target matching result.
[0010] Furthermore, the method also includes: obtaining a database identifier of the first database; obtaining a data calling method matching the database identifier; based on the data calling method, calling initial system data from the system used by the first database; and generating first system data based on the database identifier and the initial system data.
[0011] Furthermore, before obtaining the initial call parameters generated in the process of calling the first system data, the method also includes: obtaining the database type and database identifier of the first database; based on the database type, constructing an initial database at the second database address, wherein the initial database is empty; extracting information from the first database to obtain target information contained in the first database; filling the initial database based on the target information and the database identifier to obtain the second database.
[0012] According to another aspect of an embodiment of the present invention, a migration device for a database system is also provided, including: a parameter acquisition module, for obtaining initial call parameters generated in the process of calling the plurality of first system data in response to receiving a plurality of first system data waiting to be migrated, wherein the first system data is used to characterize the system data of the system used by the first database currently requiring migration; a data execution module, for executing the plurality of first system data using a second database based on the initial call parameters to obtain first execution results corresponding to different first system data, wherein the data stored in the second database is the same as the data stored in the first database, and the first address of the first database is different from the second address of the second database; a result matching module, for matching the first execution result with the second execution result to obtain a data matching result, wherein the second execution result is used to characterize the execution result of executing different first system data based on the first database; a data storage module, for storing the first system data corresponding to the first execution result to a target database in response to the data matching result being that the first execution result matches the second execution result, wherein the database address of the target database is the second address.
[0013] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the method in each embodiment of the present invention is executed when the program is running.
[0014] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0015] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0016] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0017] According to another aspect of the embodiments of the present invention, a computer program is further provided. When the computer program is executed by a processor, the methods in the embodiments of the present invention are implemented.
[0018] In an embodiment of the present invention, in response to receiving a plurality of first system data waiting to be migrated, an initial call parameter generated in the process of calling the plurality of first system data is obtained; based on the initial call parameter, the plurality of first system data are executed using a second database to obtain first execution results corresponding to different first system data; the first execution result is matched with the second execution result to obtain a data matching result; in response to the data matching result that the first execution result successfully matches the second execution result, the first system data corresponding to the first execution result is stored in a target database, by using a second database having a data state completely identical to that of the first database to execute the plurality of first system data to obtain the first execution result, and matching the second execution result of the second database executing the same first system data with the first execution result to obtain the data matching result, and only when the first execution result successfully matches the second execution result, the first system data corresponding to the first execution result is stored in the target database, so that the database system data can be safely and efficiently migrated to the target database, and the database system crash or data anomaly caused by compatibility issues is avoided, so as to achieve the purpose of rapid adaptation of the software system in a new database environment and efficient migration of data, thereby achieving the technical effect of improving the database migration efficiency, and further solving the technical problem of low database migration efficiency in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0020] Figure 1 is a flow chart of a database migration method according to an embodiment of the present invention;
[0021] Figure 2 is a schematic diagram of an optional database migration system architecture according to an embodiment of the present invention;
[0022] Figure 3 is a flow chart of an optional SQL traffic collection according to an embodiment of the present invention;
[0023] Figure 4 is a flow chart of an optional SQL traffic playback according to an embodiment of the present invention;
[0024] Figure 5 is a schematic diagram of a migration device for a database system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] According to an embodiment of the present invention, an embodiment of a database migration method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] Figure 1 is a flowchart of a database migration method according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0029] Step S102, in response to receiving a plurality of first system data waiting to be migrated, obtaining initial call parameters generated in the process of calling the plurality of first system data, wherein the first system data is used to represent system data of a system used by a first database currently requiring migration.
[0030] The above-mentioned first system data may be data or data sets in the original database system waiting to be migrated to the new database. In the scenario of database migration, the above-mentioned first system data may be understood as the business data stored in the first database currently in use. The above-mentioned initial call parameters may refer to parameters generated in the process of calling the first system data. For example, the above-mentioned initial call parameters may include at least one or more of the following: specific SQL (Structured Query Language) statements, variable values passed in when executing SQL statements, call stack information, transaction ID (Identifier), etc., but not limited to this. The above-mentioned initial call parameters are crucial to understanding how the software system interacts with the first database and how to adapt to the characteristics of the new database during the database migration process. The above-mentioned first database may be the starting point for data migration, that is, the database environment on which the software system relies before migration.
[0031] In an optional embodiment, considering that the code volume of a large software system is huge and the business logic is complex, it is difficult to manually find and understand all the details of interacting with the database. Therefore, in the preliminary preparation stage of database migration, the database migration system (hereinafter referred to as the migration system) can accurately obtain the initial call parameters related to calling the first system data, which means that the key part of the software code that interacts with the database can be located more quickly and accurately. In this embodiment, the migration system can quickly identify the database access points that need to be migrated and adapted by directly capturing the call parameters through an automated tool, thereby saving the developer's code review and modification time and improving the efficiency of the overall migration process. In addition, it is also considered that the above-mentioned initial call parameters may contain key information when interacting with the database, such as the structure of the SQL statement, the parameter type, the reference of the database object, etc. These parameters are crucial to ensure the compatibility between the new and old databases during the migration process. In this embodiment, by accurately obtaining these parameters, it can help the migration system to more accurately understand and analyze the needs of database migration, thereby improving the accuracy of database migration. For example, some SQL statements may rely on specific data types or functions. Direct migration may result in syntax errors or functional failures. By analyzing the initial call parameters, the migration system can adjust the writing of SQL statements in a targeted manner, thereby ensuring the functional integrity and data consistency of the system after migration.
[0032] Step S104, based on the initial call parameters, use the second database to execute multiple first system data to obtain first execution results corresponding to different first system data, wherein the data stored in the second database is the same as the data stored in the first database, and the first address of the first database is different from the second address of the second database.
[0033] The second database can be a database copy that is consistent with the data content of the first database but runs independently during the database migration process. The second database can provide an environment for testing and verification without affecting the normal operation of the original system. The existence of the second database enables developers to perform tests in the new database environment and evaluate the compatibility of the software system with the new database, while avoiding the data risks and system instability that may be caused by conducting experiments directly on the first database.
[0034] The first execution result may refer to the execution result returned by the second database when the code call (based on the initial call parameters) in the software system is executed on the second database. For example, the first execution result may include at least one or more of the following: a query result set, a status code of an update or insert operation, a transaction execution result, etc., but is not limited thereto. The first execution result may be used as first-hand data for comparative analysis to verify whether the behavior of the software system in the second database environment is consistent with that in the first database environment.
[0035] The first address can be the network access address of the first database, and the first address is the unique identifier for the software system to access the original database in the current environment. During the migration process, the first address can be replaced by a new address, that is, the second address, to ensure that the software system can correctly connect to the new database environment.
[0036] The second address may refer to the network access address of the second database, i.e., the unique identifier of the software system for accessing the second database during the testing and verification phase. The second address is set to ensure that the software system can safely interact with the second database without interfering with the operation of the original system. During the implementation phase of database migration, the second address will be used as the access address of the target database. The migration system can modify the database configuration of the software system and replace the first address with the second address to achieve database switching.
[0037] In an optional embodiment, in order to evaluate the compatibility and stability of the software system in the new database environment, the migration system can use the second database to execute the above initial call parameters to reproduce the original database call behavior in the new database environment, thereby obtaining a first execution result different from the first system data. The above second database stores the same data set as the first database, but they are distinguished by different network addresses (first address and second address), which ensures the independence of the test environment and the consistency of the data. In the above steps, the initial call parameters are used to simulate the execution in the second database, so that compatibility issues between the software system and the new database can be discovered in advance. For example, some SQL statements may execute normally in the first database, but fail in the second database due to syntax differences or different function implementations.
[0038] Step S106: Match the first execution result with the second execution result to obtain a data matching result, wherein the second execution result is used to represent the execution result of executing different first system data based on the first database.
[0039] The second execution result may be the execution result returned by the first database after the software system executes operations related to the migration test in the first database. The operations are usually based on the collected initial call parameters, including but not limited to SQL query, data update, transaction processing, etc. The second execution result covers the detailed feedback when the operations are executed in the original database environment. For example, the second execution result may include at least one or more of the following: query result set, update status, error message, etc., but not limited to these. The second execution result is an important benchmark in the migration test, which is used to verify whether the behavior of the software system in the new database environment is consistent with that in the original database environment.
[0040] The above data matching result can be a difference conclusion obtained by comparing and analyzing the first execution result obtained by the interaction between the software system and the second database with the second execution result. The data matching result can reflect the compatibility of the software system function and the accuracy of data processing after the database migration.
[0041] In an optional embodiment, in the test process of database migration, the migration system is executed on the second database based on the initial call parameters to obtain the first execution result. At the same time, for comparison, the migration system can also be re-executed on the first database based on the same call parameters to obtain the second execution result. Although the technical architecture and management platform of the first database and the second database may be different, the data sets they store are consistent, which provides a reliable data environment foundation for migration testing. The generation of the above data matching results is completed through a series of automated comparison algorithms, which will compare the first execution result with the second execution result one by one to check whether the format, content, order, etc. of the data are completely consistent. For those execution results that contain complex data structures and logic (such as query result sets, transaction processing status), the migration system can also use deep data comparison technology to ensure that every detail is accurately verified. In addition, the migration system can also record the difference information in each comparison so that developers can quickly locate and solve problems.
[0042] Step S108 , in response to the data matching result being that the first execution result successfully matches the second execution result, the first system data corresponding to the first execution result is stored in a target database, wherein the database address of the target database is the second address.
[0043] The target database mentioned above may refer to a new database system that replaces the original database (ie, the first database).
[0044] In an optional embodiment, when the migration system executes multiple first system data using the second database based on the initial call parameters and obtains the first execution result, the migration system can automatically perform data matching, compare the first execution result with the second execution result obtained by performing the same operation on the first database, so as to obtain the above data matching result. If the data matching result shows that the first execution result is completely consistent with the second execution result, that is, the match is successful, this will trigger the data migration process, and the migration system can store the data set corresponding to the first execution result in the first system data to the target database. This storage process may be incremental, that is, only those data items that have been successfully matched are updated or synchronized, or it may be full, that is, all system data are migrated to achieve a complete replacement of the database environment. In the above steps, successful data matching can prove that the data processing capability of the software system on the target database is consistent with the original database environment, which provides a reliable premise for data migration, ensures accurate replication of data during the migration process, avoids subsequent repair measures caused by data loss, damage or logical errors, and thus improves the efficiency of database migration.
[0045] In an embodiment of the present invention, in response to receiving a plurality of first system data waiting to be migrated, an initial call parameter generated in the process of calling the plurality of first system data is obtained; based on the initial call parameter, the plurality of first system data are executed using a second database to obtain first execution results corresponding to different first system data; the first execution result is matched with the second execution result to obtain a data matching result; in response to the data matching result that the first execution result successfully matches the second execution result, the first system data corresponding to the first execution result is stored in a target database, by using a second database having a data state completely identical to that of the first database to execute the plurality of first system data to obtain the first execution result, and matching the second execution result of the second database executing the same first system data with the first execution result to obtain the data matching result, and only when the first execution result successfully matches the second execution result, the first system data corresponding to the first execution result is stored in the target database, so that the database system data can be safely and efficiently migrated to the target database, and the database system crash or data anomaly caused by compatibility issues is avoided, so as to achieve the purpose of rapid adaptation of the software system in a new database environment and efficient migration of data, thereby achieving the technical effect of improving the database migration efficiency, and further solving the technical problem of low database migration efficiency in the related art.
[0046] Furthermore, the initial calling parameters include at least: calling time of different first system data; based on the initial calling parameters, using the second database to execute multiple first system data to obtain first execution results corresponding to different first system data, including: based on the calling time, constructing a system data sequence corresponding to multiple first system data; reading the second system data from the system data sequence in sequence, and obtaining configuration parameters of the second system data; executing the configuration parameters based on the second database to obtain the first execution result corresponding to the second system data.
[0047] The above call time can be the timestamp of the database operation performed by the software system during the interaction with the first database. These timestamps record the precise time of each database call. In the testing phase of database migration, the call time information is crucial for building system data sequences and reproducing the business processes of the software system, and provides a time basis for data playback, ensuring that the operations on the second database can be performed in the order of the actual operation of the software system.
[0048] The above system data sequence can be a list of a series of software system data arranged in chronological order, which is constructed by call time information. The above system data can include parameters, SQL statements, transaction processing information, etc. required for various business operations, which is a direct reflection of the interaction between the software system and the database. The construction of the system data sequence can ensure that the testing and verification on the target database can follow the chronological order of the actual business process, which is crucial for discovering potential problems caused by time dependency.
[0049] The above-mentioned second system data may refer to data points in the system data sequence used to perform database operations on the second database. These data points may include specific business data and configuration parameters. During the migration testing phase, the migration system may read the second system data from the system data sequence in sequence and obtain the configuration parameters associated with the second system data to perform corresponding database operations on the target database.
[0050] In an optional embodiment, based on the call time recorded in the collected initial call parameters, the migration system can automatically construct the execution sequence of each first system data, that is, the above-mentioned system data sequence. The above-mentioned system data sequence can ensure that the playback of the data can be carried out in accordance with the actual business process and time sequence, which is crucial for reproducing problems and verifying functions. From the constructed system data sequence, the migration system can read the second system data one by one in time sequence, and at the same time obtain the configuration parameters related to the second system data. The above-mentioned configuration parameters may include SQL statements, transaction processing mechanisms, data format requirements, etc., which are specific instructions for executing database operations. The migration system can use the second database to perform corresponding database operations according to the read configuration parameters, thereby obtaining the first execution result corresponding to the second system data. This execution result is a direct feedback to verify the functional correctness and data processing consistency of the software system in the target database environment. In the above steps, the construction and automatic playback of the system data sequence improve the efficiency of database migration testing, avoid the cumbersome process of developers manually setting up the test environment and repeatedly performing test operations, and make the location and resolution of problems faster.
[0051] Further, the second system data is read from the system data sequence in sequence, including: obtaining the third system data read from the system data sequence before the second system data; obtaining the target matching result matching the third system data from the data matching result; in response to the target matching result being the first execution result corresponding to the third system data, the second execution result corresponding to the third system data is successfully matched, and based on the calling time of the third system data, the second system data is read from the system data sequence.
[0052] The third system data may refer to a data point in the system data sequence that is located before the second system data to be read. This data point is a collection of business data and its related configuration parameters arranged in chronological order during the interaction between the software system and the database. The target matching result may refer to the matching status obtained after the migration system compares and verifies the execution results of the interaction between the software system and the database during the database migration test.
[0053] In an optional embodiment, before reading the second system data, the migration system may first read the previous data point, i.e., the third system data, from the constructed system data sequence. The third system data may include the first system data that has been successfully executed and verified on the target database. The migration system may then search for a matching record corresponding to the third system data from the data matching result, i.e., the target matching result. The target matching result records the execution result of the third system data on the first database and the second database, as well as the matching status between these results. If the target matching result indicates that the first execution result (i.e., the result executed on the second database) corresponding to the third system data matches the second execution result (i.e., the result executed on the first database) successfully, i.e., the execution results of the two are consistent, this indicates that the adaptability verification of the software system on the target database has passed, and subsequent testing and verification may continue. After confirming that the match is successful, the migration system may continue to read the next data point, i.e., the second system data, from the system data sequence according to the call time of the third system data. The timestamp mechanism is used in the above steps to ensure the sequentiality of data playback, so that the business process of the software system can be reproduced and verified according to the actual time sequence. By systematically verifying the execution results of each system data on the target database, the stability and compatibility of the software system in the new database environment can be gradually confirmed. This orderly testing and verification strategy avoids subsequent problems caused by missing or incorrect execution of test data, thereby improving the efficiency of database migration.
[0054] Furthermore, the method also includes: in response to the target matching result being the first execution result corresponding to the third system data, the matching with the second execution result corresponding to the third system data fails, and the third system data and the second database are output; in response to receiving a data adjustment instruction, the third system data is adjusted based on the data adjustment instruction to obtain new third system data; and the new third system data is executed based on the second database to match the second execution result corresponding to the third system data to obtain a new target matching result.
[0055] The above-mentioned data adjustment instructions may refer to a series of specific operation instructions formulated by the database development team to correct the matching failure after analyzing the problem data and the execution results of the problem data on the target database.
[0056] In an optional embodiment, when the target matching result is that the first execution result corresponding to the third system data fails to match the second execution result, the migration system can automatically output the detailed information of the third system data and the relevant status of the target database (i.e., the second database) during the execution process. The output of this information provides the development team with key clues for problem location, including the erroneous SQL statement, call time, execution environment, etc., which helps to quickly identify the source of the problem. After the problem is output, the development team will conduct in-depth analysis and formulate a solution based on the problem information provided by the system. Once the problem-solving strategy is confirmed, the developer can make necessary adjustments to the third system data through data adjustment instructions. The data adjustment instructions may include modifying SQL statements, adjusting database configuration parameters, optimizing code logic, etc., aiming to ensure that the software system can adapt to the characteristics of the target database and achieve accuracy and consistency in data processing. The development team adjusts the third system data according to the data adjustment instructions and generates new third system data. Subsequently, the migration system re-executes the adjusted data on the target database to obtain a new first execution result. This execution process ensures that the repair effect of the problem data can be accurately verified and avoids further problems caused by improper modification. After the new third system data is successfully executed, the migration system will automatically compare the new first execution result with the second execution result of the third system data on the original database. If the match is successful, that is, the execution results of the two are consistent, the above matching result can be recorded as the new target matching result. The new target matching result not only verifies the effect of the problem repair, but also provides confidence for subsequent data migration and system testing, proving that the adaptability of the software system on the target database has been enhanced.
[0057] Furthermore, the method also includes: obtaining a database identifier of the first database; obtaining a data calling method matching the database identifier; based on the data calling method, calling initial system data from the system used by the first database; and generating first system data based on the database identifier and the initial system data.
[0058] The above-mentioned database identifier can be an identifier used to distinguish different databases. The above-mentioned data call method can refer to a specific method or protocol used when the software system interacts with the database, such as using a JDBC (Java Database Connectivity) driver to connect to a MySQL database, or using an ODBC (Open Database Connectivity) to connect to an Oracle database. A correctly matched data call method can avoid data loss or access anomalies caused by mismatched database connections or data call protocols, ensure the accuracy and integrity of data collection, and provide a solid foundation for subsequent database migration testing and verification. The above-mentioned initial system data can refer to the original data stream generated when the software system performs database operations in the original database environment (first database). For example, the above-mentioned initial system data can include at least one or more of the following: SQL query statements, transaction processing information, call stack details, data change records, etc., but are not limited to this.
[0059] In an optional embodiment, the database identifier is an identifier for uniquely identifying the characteristics of the first database, such as the database type, version number, etc. At the beginning of the database migration project, it is very important to accurately obtain the database identifier of the first database, which provides a basic basis for the subsequent data call method matching and system data generation, ensures the pertinence and systematicness of the database migration project, avoids the deviation in the formulation of the migration strategy due to unclear database identifiers, and improves the implementation efficiency of database migration. According to the obtained database identifier of the first database, the migration system can automatically match the call method that is more suitable for the database type and version, such as JDBC driver, ODBC driver, database API (Application Programming Interface), etc. This matching process ensures that the software system can interact with the original database in an efficient and compatible manner to obtain complete system data. Based on the matched data call method, the migration system can call the initial system data from the software system used by the first database, that is, the data stream generated when the software system performs database operations in the original database environment. The above initial system data may include SQL query statements, transaction records, call stack information, etc., which is a direct reflection of the interaction between the software system and the database. Finally, the migration system can generate first system data, i.e., system data points containing detailed database access information, based on the identifier of the first database and the collected initial system data. The above first system data will be used for subsequent database migration testing and verification, as well as data adaptability verification on the target database.
[0060] Furthermore, before obtaining the initial call parameters generated in the process of calling the first system data, the method also includes: obtaining the database type and database identifier of the first database; based on the database type, constructing an initial database at the second database address, wherein the initial database is empty; extracting information from the first database to obtain target information contained in the first database; filling the initial database based on the target information and the database identifier to obtain the second database.
[0061] The above-mentioned database type may refer to the type of the original database (i.e., the first database). The choice of database type determines the mechanism and performance characteristics of data storage, query, and transaction processing, as well as the data calling method that is compatible therewith. Correctly identifying the database type can ensure the compatibility and efficiency of the migration process and avoid adaptability problems caused by insufficient understanding of database characteristics. The above-mentioned initial database may be a database built under the target database address (i.e., the address of the second database) that matches the first database type but has not yet been filled with any data or logic. The above-mentioned target information may refer to the key database elements and data layout information that the software system relies on when performing database operations in the first database. For example, the above-mentioned target information may include at least one or more of the following: data table structure, stored procedures, functions, triggers, indexes, data type definitions, data integrity constraints, etc., but is not limited to this.
[0062] In an optional embodiment, in the initial stage of database migration, accurately obtaining the database type and database identifier of the first database (i.e., the original database) is a crucial first step. The database type indicates the type of the original database, while the database identifier contains key attributes such as the version information and configuration parameters of the database. The purpose of this operation is to be able to select a more matching data call method and a customized migration strategy in the future to ensure the pertinence and efficiency of the migration process. After understanding the type of the first database, the migration system can build an initial database that matches the original database type under the target database address (i.e., the address of the second database). At this time, the constructed initial database is empty, which means that it does not yet contain any data or business logic, providing a clean environment for subsequent database filling and adaptation. In the preparatory stage, the migration system can perform in-depth information extraction on the first database, extracting key target information contained in the database, such as data table structure, stored procedures, functions, triggers, etc., as well as data content. This information extraction process can be carried out through database backup, export tools, or by directly reading database metadata, aiming to fully understand the architecture and data layout of the original database. Finally, based on the extracted target information and the database identifier of the first database, the migration system can populate the constructed initial database and create a second database with similar functions and data layout to the first database. This populating process may include the creation of data tables, the migration of stored procedures and functions, and the import of data, etc., in order to achieve seamless connection between the new database and the original database in terms of functions and data consistency.
[0063] For ease of understanding, Figure 2 is a schematic diagram of an optional database migration system architecture according to an embodiment of the present invention, such as Figure 2As shown in the figure, the architecture includes source database, target database, traffic collection module, SQL traffic file, and traffic playback module. Among them, the source database is the database environment where the software system is currently running, and the target database is the database for this migration. Through the traffic collection and traffic playback modules, the software system can migrate from the original database environment to the domestic database environment, while ensuring the correctness of data access logic and database operations. The traffic collection module captures and records all access information to the original database through interaction with the JAVA program, including SQL call statements, call timestamps, call stack information, and database response results. This information is collected and stored as an SQL traffic file, providing a data basis for subsequent traffic playback and problem location. The SQL traffic file stores all SQL traffic information captured by the traffic collection module, that is, a detailed record of the interaction between the software system and the original database. The SQL traffic file is a bridge connecting the two key stages of traffic collection and traffic playback, ensuring the continuity and consistency of the data. The traffic replay module is responsible for reading the records in the SQL traffic file and replaying these SQL calls in the target database environment. During the above replay process, the traffic replay module will compare the execution results of the target database with the response results of the original database to discover incompatibility issues caused by database migration.
[0064] Figure 3 is a flow chart of an optional SQL traffic collection according to an embodiment of the present invention, such as Figure 3 As shown, at the beginning of the process, the program calls the database to perform data reading, writing or other types of database operations. The traffic collection module records the execution SQL, timestamp, and call stack information. After the traffic collection module records the call information, the migration system continues to call the database normally and perform database operations. The traffic collection module can not only record the database call request, but also record the database return information, including but not limited to data content, operation status, error information, etc. Finally, the migration system can record the execution SQL, timestamp, call stack information, and database return information in the SQL traffic file. Figure 3 The process shown achieves comprehensive monitoring and information capture of database access behavior through the intervention of the traffic collection module, providing a detailed data basis for subsequent traffic playback and database migration testing.
[0065] Figure 4 is a flowchart of an optional SQL traffic playback according to an embodiment of the present invention, such as Figure 4As shown, at the beginning of the process, the migration system can upload the SQL flow file to the flow replay module. Subsequently, the flow replay module obtains the SQL replay information from the SQL flow file in the order of timestamps and determines whether there is no replay information. If so, the replay ends. If not, the target database is called to execute the SQL in the SQL replay information. After the execution is completed, the database execution result is obtained and compared with the database result in the SQL replay information, and it is determined whether the comparison is consistent. If it is consistent, it means that the current SQL statement is executed correctly on the new database and the next information can be read. If it is inconsistent, the replay is paused and the progress is marked as the record consistent with the previous replay result. Then, the replay module displays the replay SQL, call stack information, original database response, and target database response to the developer for quick problem location and repair. After the developer repairs it, the modified SQL is provided and the traffic is continued to be replayed. Finally, the SQL in the replay information is replaced with the repaired SQL to continue replaying.
[0066] According to an embodiment of the present invention, an embodiment of a migration device for a database system is provided. It should be noted that the device can be used to execute the above database migration method. The specific implementation and application scenario are the same as those of the above embodiment and will not be described in detail here. Figure 5 is a schematic diagram of a migration device for a database system according to an embodiment of the present invention. Figure 5 As shown, the device comprises:
[0067] The parameter acquisition module 502 is used to obtain initial call parameters generated in the process of calling the multiple first system data in response to receiving the multiple first system data waiting to be migrated, wherein the first system data is used to represent the system data of the system used by the first database currently requiring migration.
[0068] The data execution module 504 is used to execute multiple first system data using the second database based on the initial call parameters to obtain first execution results corresponding to different first system data, wherein the data stored in the second database is the same as the data stored in the first database, and the first address of the first database is different from the second address of the second database.
[0069] The result matching module 506 is used to match the first execution result with the second execution result to obtain a data matching result, wherein the second execution result is used to represent the execution result of executing different first system data based on the first database.
[0070] The data storage module 508 is used to store the first system data corresponding to the first execution result to the target database in response to the data matching result being that the first execution result matches the second execution result, wherein the database address of the target database is the second address.
[0071] Furthermore, the initial calling parameters include at least: the calling time of different first system data; the data execution module is also used to: construct a system data sequence corresponding to multiple first system data based on the calling time; read the second system data from the system data sequence in sequence, and obtain the configuration parameters of the second system data; execute the configuration parameters based on the second database to obtain the first execution result corresponding to the second system data.
[0072] Furthermore, the data execution module is also used to: obtain a third system data read from the system data sequence before the second system data; obtain a target matching result matching the third system data from the data matching results; in response to the target matching result being a first execution result corresponding to the third system data, the second execution result corresponding to the third system data is successfully matched, and based on the calling time of the third system data, the second system data is read from the system data sequence.
[0073] Furthermore, the device also includes: a first output module, used to output the third system data and the second database in response to the target matching result being the first execution result corresponding to the third system data and the second execution result corresponding to the third system data failing to match; a first adjustment module, used to adjust the third system data based on the data adjustment instruction in response to receiving a data adjustment instruction to obtain new third system data; and a first matching module, used to execute the new third system data based on the second database, match the second execution result corresponding to the third system data, and obtain a new target matching result.
[0074] Furthermore, the device also includes: a first acquisition module, used to obtain a database identifier of the first database; a second acquisition module, used to obtain a data calling method matching the database identifier; a first calling module, used to call initial system data from the system used by the first database based on the data calling method; and a first generating module, used to generate first system data based on the database identifier and the initial system data.
[0075] Furthermore, before obtaining the initial call parameters generated in the process of calling the first system data, the device also includes: a third acquisition module, used to obtain the database type and database identifier of the first database; a first construction module, used to construct an initial database at the second database address based on the database type, wherein the initial database is empty; an information extraction module, used to extract information from the first database to obtain the target information contained in the first database; a data filling module, used to fill the initial database based on the target information and the database identifier to obtain the second database.
[0076] An embodiment of the present application further provides an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of the present invention when running.
[0077] An embodiment of the present application further provides a computer-readable storage medium, which includes a stored executable program, wherein when the executable program is running, the device where the computer-readable storage medium is located is controlled to execute the methods in various embodiments of the present invention.
[0078] An embodiment of the present application further provides a computer program product, including a computer program, which implements the methods in various embodiments of the present invention when executed by a processor.
[0079] An embodiment of the present application further provides a computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method in each embodiment of the present invention is implemented.
[0080] The embodiments of the present application further provide a computer program, which implements the methods in the above-mentioned embodiments of the present invention when executed by a processor.
[0081] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0082] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0083] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0084] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0085] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0086] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A database migration method, characterized in that: include: In response to receiving a plurality of first system data waiting to be migrated, obtaining initial call parameters generated in the process of calling the plurality of first system data, wherein the first system data is used to characterize system data of a system used by a first database currently requiring migration; Based on the initial call parameters, the plurality of first system data are executed using a second database to obtain first execution results corresponding to different first system data, wherein the data stored in the second database is the same as the data stored in the first database, and the first address of the first database is different from the second address of the second database; Matching the first execution result with the second execution result to obtain a data matching result, wherein the second execution result is used to represent an execution result of executing different first system data based on the first database; In response to the data matching result being that the first execution result successfully matches the second execution result, the first system data corresponding to the first execution result is stored in a target database, wherein the database address of the target database is the second address.
2. The method according to claim 1, characterized in that The initial call parameters at least include: the call time of different first system data; based on the initial call parameters, the plurality of first system data are executed using the second database to obtain first execution results corresponding to the different first system data, including: Based on the calling time, construct a system data sequence corresponding to the plurality of first system data; Reading second system data from the system data sequence in sequence, and acquiring configuration parameters of the second system data; The configuration parameters are executed based on the second database to obtain the first execution result corresponding to the second system data.
3. The method according to claim 2, characterized in that Sequentially reading second system data from the system data sequence includes: Acquire third system data read from the system data sequence before the second system data; From the data matching results, obtaining a target matching result that matches the third system data; In response to the target matching result being the first execution result corresponding to the third system data, the second execution result corresponding to the third system data is successfully matched, and based on the calling time of the third system data, the second system data is read from the system data sequence.
4. The method according to claim 3, characterized in that The method further comprises: In response to the target matching result being the first execution result corresponding to the third system data, and the second execution result corresponding to the third system data failing to match, outputting the third system data and the second database; In response to receiving the data adjustment instruction, adjusting the third system data based on the data adjustment instruction to obtain new third system data; The new third system data is executed based on the second database, and matched with the second execution result corresponding to the third system data to obtain a new target matching result.
5. The method according to claim 1, characterized in that: The method further comprises: Obtaining a database identifier of the first database; Acquire a data calling method matching the database identifier; Initial system data called from the system used by the first database based on the data calling method; The first system data is generated based on the database identifier and the initial system data.
6. The method according to claim 1, characterized in that Before acquiring the initial call parameters generated in the process of calling the first system data, the method further includes: Obtaining a database type and a database identifier of the first database; Based on the database type, construct an initial database at the second database address, wherein the initial database is empty; Extracting information from the first database to obtain target information contained in the first database; The initial database is filled based on the target information and the database identifier to obtain the second database.
7. A migration device for a database system, characterized in that: include: A parameter acquisition module, configured to, in response to receiving a plurality of first system data to be migrated, acquire initial call parameters generated in the process of calling the plurality of first system data, wherein the first system data is used to characterize system data of a system used by a first database currently requiring migration; a data execution module, configured to execute the plurality of first system data using a second database based on the initial call parameters to obtain first execution results corresponding to different first system data, wherein the data stored in the second database is the same as the data stored in the first database, and the first address of the first database is different from the second address of the second database; A result matching module, used for matching the first execution result with the second execution result to obtain a data matching result, wherein the second execution result is used to represent the execution result of executing different first system data based on the first database; A data storage module is used for storing the first system data corresponding to the first execution result to a target database in response to the data matching result being that the first execution result matches the second execution result, wherein the database address of the target database is the second address.
8. An electronic device, characterized in that: include: A memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 6 when running.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.