Data verification method, device, equipment and medium based on database migration
By performing multi-dimensional data verification during the database migration process, the problem of data consistency verification in database migration is solved and efficient and accurate data migration is achieved.
Patent Information
- Application Number
- CN202110724734.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-06-29
AI Technical Summary
During the database migration process, existing technology is difficult to effectively verify the consistency of millions or even tens of millions of data. Manual comparison is cumbersome and error-prone. Automatic machine verification such as the MD5 algorithm has unreliable results in different environments.
During the database migration process, tabular data is obtained from the source database and the target database, multi-dimensional verification is performed, including comparison of numerical and character data, data is obtained using regular expressions and tag matching, and data summation is calculated. Maximum value, minimum value and standard deviation are verified to ensure data consistency.
It achieves efficient and accurate verification of data during database migration, avoids data inconsistency and invalid migration, and improves the reliability and efficiency of data migration.
Smart Images

Figure CN113392090B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of testing technology, and in particular to a data verification method, device, equipment and medium based on database migration. Background Art
[0002] In the process of enterprise development, based on operating costs or technical considerations, it is usually necessary to migrate the data in the database, and the corresponding batch computing tasks also need to be modified synchronously. Due to the differences in syntax between different databases, after modifying the script of the computing task, it is also necessary to verify the calculation results to ensure that after the task is modified, the calculation results are still consistent with the original data to avoid affecting the subsequent data reporting and analysis.
[0003] In the process of verifying data consistency, we usually face millions or even tens of millions of data. If we only compare the data roughly manually, it is difficult to ensure the integrity of the data verification; if we compare all the data one by one, the workload is huge and it takes a lot of time; at the same time, manual comparison of massive data is also prone to errors. In the process of consistency verification, if the data synchronization of a data source is delayed or the base table data is changed, the final result may be inconsistent again. If we don’t know the specific reason, it will also cause a waste of manpower to compare again.
[0004] When using machine automatic verification, the MD5 (Message-Digest Algorithm) algorithm is currently commonly used. However, the values obtained by the MD5 algorithm when running in different environments may be different, resulting in unreliable verification results. Summary of the invention
[0005] In view of the above, it is necessary to provide a data verification method, device, equipment and medium based on database migration, which can automatically perform continuous verification from multiple dimensions during the database migration process to ensure that the data is accurately migrated from the source database to the target database, efficiently and accurately.
[0006] A data verification method based on database migration, the data verification method based on database migration comprising:
[0007] In response to a data verification request, obtaining a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database;
[0008] During the data migration process, obtaining a table in the target database as a migrated data table at a preset time interval, and obtaining a table corresponding to the migrated data table from the source database as a reference data table;
[0009] Verifying whether the number of the migrated data tables is consistent with the number of the benchmark data tables;
[0010] When the number of the migrated data tables is consistent with the number of the reference data tables, acquiring numerical data from the migrated data tables as first data, and acquiring numerical data from the reference data tables as second data;
[0011] Verifying data consistency according to the first data and the second data;
[0012] When the data consistency passes the verification, character data is obtained from the migrated data table as the third data, and character data is obtained from the reference data table as the fourth data;
[0013] Cleaning the third data to obtain fifth data, and cleaning the fourth data to obtain sixth data;
[0014] Verifying character consistency according to the fifth data and the sixth data;
[0015] When the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database.
[0016] According to a preferred embodiment of the present invention, obtaining the source database and the target database according to the data verification request includes:
[0017] Parsing the data verification request to obtain information carried by the data verification request;
[0018] Acquire a preconfigured first tag and a second tag, wherein the first tag corresponds to a database identifier of the source database, and the second tag corresponds to a database identifier of the target database;
[0019] Creating a first regular expression according to the first tag, and creating a second regular expression according to the second tag;
[0020] Using the first regular expression to traverse the information carried in the data verification request, and determining the traversed information that matches the first regular expression as the database identifier of the source database, and determining the source database according to the database identifier of the source database;
[0021] The information carried in the data verification request is traversed using the second regular expression, and the traversed information matching the second regular expression is determined as the database identifier of the target database, and the target database is determined according to the database identifier of the target database.
[0022] According to a preferred embodiment of the present invention, verifying data consistency according to the first data and the second data includes:
[0023] Calculating a data sum of the first data, and calculating a data sum of the second data;
[0024] Obtaining a maximum value in the first data and a minimum value in the first data, and obtaining a maximum value in the second data and a minimum value in the second data;
[0025] Calculating the standard deviation of the first data, and calculating the standard deviation of the second data;
[0026] When the data sum of the first data is consistent with the data sum of the second data, the maximum value in the first data is consistent with the maximum value in the second data, the minimum value in the first data is consistent with the minimum value in the second data, and the standard deviation of the first data is consistent with the standard deviation of the second data, it is determined that the data consistency passes the verification; or
[0027] When the data sum of the first data is inconsistent with the data sum of the second data, and / or the maximum value in the first data is inconsistent with the maximum value in the second data, and / or the minimum value in the first data is inconsistent with the minimum value in the second data, and / or the standard deviation of the first data is inconsistent with the standard deviation of the second data, it is determined that the data consistency has failed the verification.
[0028] According to a preferred embodiment of the present invention, the fifth data is deduplicated to obtain the character category and the number of character categories in the fifth data, and the sixth data is deduplicated to obtain the character category and the number of character categories in the sixth data;
[0029] Obtaining the records and the total number of records of each character category in the fifth data, and obtaining the records and the total number of records of each character category in the sixth data;
[0030] Calculating a first sum value corresponding to the fifth data according to the record of each character category in the fifth data;
[0031] Calculating a second sum value corresponding to the sixth data according to the record of each character category in the sixth data;
[0032] Obtaining a maximum value in the records of each character category in the fifth data and a minimum value in the records of each character category in the fifth data;
[0033] Obtaining a maximum value in the records of each character category in the sixth data and a minimum value in the records of each character category in the sixth data;
[0034] Calculating the standard deviation of the fifth data and calculating the standard deviation of the sixth data;
[0035] When the character category in the fifth data is consistent with the character category in the sixth data, and the number of character categories in the fifth data is consistent with the number of character categories in the sixth data, and the total number of records of each character category in the fifth data is consistent with the total number of records of each character category in the sixth data, and the first sum value is consistent with the second sum value, and the maximum value in the records of each character category in the fifth data is consistent with the maximum value in the records of each character category in the sixth data, and the minimum value in the records of each character category in the fifth data is consistent with the minimum value in the records of each character category in the sixth data, and the standard deviation of the fifth data is consistent with the standard deviation of the sixth data, it is determined that the character consistency passes the verification; or
[0036] When the character category in the fifth data is inconsistent with the character category in the sixth data, and / or the number of character categories in the fifth data is inconsistent with the number of character categories in the sixth data, and / or the total number of records of each character category in the fifth data is inconsistent with the total number of records of each character category in the sixth data, and / or the first sum value is inconsistent with the second sum value, and / or the maximum value in the records of each character category in the fifth data is inconsistent with the maximum value in the records of each character category in the sixth data, and / or the minimum value in the records of each character category in the fifth data is inconsistent with the minimum value in the records of each character category in the sixth data, and / or the standard deviation of the fifth data is inconsistent with the standard deviation of the sixth data, it is determined that the character consistency has not passed the verification.
[0037] According to a preferred embodiment of the present invention, calculating the first sum value corresponding to the fifth data according to the records of each character category in the fifth data includes:
[0038] In the fifth data, a record value of each record is obtained from the record of each character category;
[0039] Calculate the cumulative sum of the record values of each record corresponding to each character category as the total record value of each character category;
[0040] A sum operation is performed using the sum of the record values of each character category to obtain a first sum value corresponding to the fifth data.
[0041] According to a preferred embodiment of the present invention, the method further comprises:
[0042] When the number of the migrated data tables is inconsistent with the number of the reference data tables, and / or the data consistency fails to pass the verification, and / or the character consistency fails to pass the verification, stopping the migration of data from the source database to the target database;
[0043] Generate warning information and send the warning information to the designated terminal device.
[0044] According to a preferred embodiment of the present invention, sending the alarm information to a designated terminal device includes:
[0045] When the warning information is detected, determining that the verification is completed;
[0046] Transmitting the alarm information to Kafka;
[0047] Connect to the email notification interface;
[0048] When the email notification interface monitors that the Kafka consumes the alarm information, a prompt email with the alarm information is sent to the designated terminal device through the email notification interface.
[0049] A data verification device based on database migration, the data verification device based on database migration comprising:
[0050] an acquisition unit, configured to respond to a data verification request and acquire a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database;
[0051] The acquisition unit is further configured to acquire, during the data migration process, a table in the target database as a migrated data table at a preset time interval, and acquire a table corresponding to the migrated data table from the source database as a reference data table;
[0052] A verification unit, used to verify whether the number of the migrated data tables is consistent with the number of the reference data tables;
[0053] The acquisition unit is further configured to acquire numerical data from the migrated data table as first data and acquire numerical data from the benchmark data table as second data when the number of the migrated data table is consistent with the number of the benchmark data table;
[0054] The verification unit is further used to verify data consistency according to the first data and the second data;
[0055] The acquisition unit is further configured to acquire character data from the migrated data table as third data and acquire character data from the reference data table as fourth data when the data consistency passes verification;
[0056] a cleaning unit, configured to clean the third data to obtain fifth data, and clean the fourth data to obtain sixth data;
[0057] The verification unit is further used to verify character consistency according to the fifth data and the sixth data;
[0058] The migration unit is used to determine that the data in the migrated data table passes the verification when the character consistency passes the verification, and continue to migrate the data from the source database to the target database.
[0059] A computer device, comprising:
[0060] a memory storing at least one instruction; and
[0061] A processor executes instructions stored in the memory to implement the data verification method based on database migration.
[0062] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the data verification method based on database migration.
[0063] It can be seen from the above technical scheme that the present invention can respond to a data verification request, obtain a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database, and required data is obtained based on labels and regular expressions, and due to the uniqueness of the labels, the accuracy of the acquired data is guaranteed while the efficiency of data acquisition is improved. During the data migration process, a table in the target database is obtained as a migrated data table at a preset time interval, and a table corresponding to the migrated data table is obtained from the source database as a benchmark data table to verify whether the number of the migrated data tables is consistent with the number of the benchmark data tables. First, the number of migrated data tables is verified to verify whether there is omission or repeated migration of data tables during the database migration process. When the number of migrated data tables is consistent with the number of benchmark data tables, numerical data is obtained from the migrated data table as the first data, and numerical data is obtained from the benchmark data table as the second data. When the number of migrated data tables is consistent with the number of benchmark data tables, it is indicated that During the database migration process, the number of data tables is consistent. At this time, the subsequent verification is continued to be performed to avoid invalid verification from bringing operating burden to the system. The data consistency is verified according to the first data and the second data. When the data consistency passes the verification, the character data is obtained from the migrated data table as the third data, and the character data is obtained from the reference data table as the fourth data. The third data is cleaned to obtain the fifth data, and the fourth data is cleaned to obtain the sixth data, thereby reducing the difficulty of subsequent verification and improving the efficiency of verification. The character consistency is verified according to the fifth data and the sixth data. The data consistency can be verified in the dimension of the character data through data calculation to avoid the inconsistency of the character data during the database migration process. When the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database. Then, during the database migration process, continuous verification is automatically performed from multiple dimensions to ensure that the data is accurately migrated from the source database to the target database, which is efficient and accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 It is a flow chart of a preferred embodiment of the data verification method based on database migration of the present invention.
[0065] Figure 2 It is a functional module diagram of a preferred embodiment of the data verification device based on database migration of the present invention.
[0066] Figure 3It is a structural schematic diagram of a computer device of a preferred embodiment of the present invention for implementing a data verification method based on database migration. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0068] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of a data verification method based on database migration according to the present invention. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.
[0069] The data verification method based on database migration is applied to one or more computer devices, and the computer device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0070] The computer device may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0071] The computer device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.
[0072] The network where the computer device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0073] S10, in response to a data verification request, obtaining a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database.
[0074] In this embodiment, the data verification request can be automatically triggered. For example, when data migration is started, data is migrated from the source database to the target database, and the data verification request is triggered at the same time to ensure that real-time verification of data can be achieved during the data migration process.
[0075] Of course, in other embodiments, the data verification request may also be triggered by relevant staff according to actual verification requirements, and the present invention is not limited thereto.
[0076] In at least one embodiment of the present invention, obtaining a source database and a target database according to the data verification request includes:
[0077] Parsing the data verification request to obtain information carried by the data verification request;
[0078] Acquire a preconfigured first tag and a second tag, wherein the first tag corresponds to a database identifier of the source database, and the second tag corresponds to a database identifier of the target database;
[0079] Creating a first regular expression according to the first tag, and creating a second regular expression according to the second tag;
[0080] Using the first regular expression to traverse the information carried in the data verification request, and determining the traversed information that matches the first regular expression as the database identifier of the source database, and determining the source database according to the database identifier of the source database;
[0081] The information carried in the data verification request is traversed using the second regular expression, and the traversed information matching the second regular expression is determined as the database identifier of the target database, and the target database is determined according to the database identifier of the target database.
[0082] The first label and the second label can be custom configured.
[0083] For example, the first tag may be configured as SourceID, and the second tag may be configured as TargetID.
[0084] Further, the first regular expression established according to the first tag may be SourceID(), and the second regular expression established according to the second tag may be TargetID().
[0085] Further, the information carried by the data verification request is traversed using the first regular expression SourceID(), and the traversed information matching the first regular expression SourceID() is determined as the database identifier of the source database, and the database with the database identifier of the source database is further determined as the source database. The information carried by the data verification request is traversed using the second regular expression TargetID(), and the traversed information matching the second regular expression TargetID() is determined as the database identifier of the target database, and the database with the database identifier of the target database is further determined as the target database.
[0086] Through the above implementation, the required data can be obtained based on the label and the regular expression, and due to the uniqueness of the label, the data acquisition efficiency is improved while the accuracy of the acquired data is guaranteed.
[0087] S11, during the data migration process, obtaining a table in the target database as a migrated data table at a preset time interval, and obtaining a table corresponding to the migrated data table from the source database as a reference data table.
[0088] In this embodiment, the preset time interval can be customized, such as 5 minutes, 1 minute, etc. The configuration of the preset time interval ensures the frequency of data verification and further ensures the correctness of data migration.
[0089] In this embodiment, the data in the target database is migrated from the source database. Therefore, the original data in the source database is correct and can be used as the basis for subsequent verification, while the data in the target database serves as the object to be verified to determine whether data errors occur during the data migration process.
[0090] The data in the target database and the source database are stored in the form of tables. Therefore, this embodiment obtains a table in the target database as a migrated data table, and obtains a table corresponding to the migrated data table from the source database as a reference data table.
[0091] The data in the migrated data table is the data to be verified, and the data in the reference data table is the reference for verification.
[0092] S12: Verify whether the number of the migrated data tables is consistent with the number of the reference data tables.
[0093] It should be noted that during the database migration process, the migrated data may be duplicated or omitted. Therefore, the number of tables needs to be verified first.
[0094] In at least one embodiment of the present invention, the verifying whether the number of the migrated data tables is consistent with the number of the benchmark data tables comprises:
[0095] Determining the number of the migrated data tables and determining the number of the benchmark data tables;
[0096] When the number of the migrated data tables is equal to the number of the reference data tables, determining that the number of the migrated data tables is consistent with the number of the reference data tables; or
[0097] When the number of the migrated data tables is not equal to the number of the reference data tables, it is determined that the number of the migrated data tables is inconsistent with the number of the reference data tables.
[0098] Through the above implementation, the number of migrated data tables is first verified to verify whether there is any omission or duplication of migration of data tables during the database migration process.
[0099] S13, when the number of the migrated data tables is consistent with the number of the reference data tables, obtaining numerical data from the migrated data tables as first data, and obtaining numerical data from the reference data tables as second data.
[0100] It is understandable that when the number of migrated data tables is consistent with the number of benchmark data tables, it means that the number of data tables is consistent during the database migration process. At this time, subsequent verification is continued to avoid invalid verification bringing operational burden to the system.
[0101] Furthermore, numerical data is obtained from the migrated data table as the first data, and numerical data is obtained from the reference data table as the second data, for use in subsequent verification of data consistency.
[0102] The numerical data refers to digital data, such as sales volume.
[0103] S14: Verify data consistency according to the first data and the second data.
[0104] In at least one embodiment of the present invention, verifying data consistency according to the first data and the second data includes:
[0105] Calculating a data sum of the first data, and calculating a data sum of the second data;
[0106] Obtaining a maximum value in the first data and a minimum value in the first data, and obtaining a maximum value in the second data and a minimum value in the second data;
[0107] Calculating the standard deviation of the first data, and calculating the standard deviation of the second data;
[0108] When the data sum of the first data is consistent with the data sum of the second data, the maximum value in the first data is consistent with the maximum value in the second data, the minimum value in the first data is consistent with the minimum value in the second data, and the standard deviation of the first data is consistent with the standard deviation of the second data, it is determined that the data consistency passes the verification; or
[0109] When the data sum of the first data is inconsistent with the data sum of the second data, and / or the maximum value in the first data is inconsistent with the maximum value in the second data, and / or the minimum value in the first data is inconsistent with the minimum value in the second data, and / or the standard deviation of the first data is inconsistent with the standard deviation of the second data, it is determined that the data consistency has failed the verification.
[0110] Through the above implementation, data consistency can be verified in the dimension of numerical data through data calculation, thereby avoiding data inconsistency during database migration.
[0111] S15, when the data consistency passes the verification, obtaining character data from the migrated data table as third data, and obtaining character data from the reference data table as fourth data.
[0112] After the data consistency is verified, it indicates that there is no error in data migration in the dimension of numerical data, and therefore, the dimension of character data is further verified.
[0113] Specifically, character data is obtained from the migrated data table as the third data, and character data is obtained from the reference data table as the fourth data, for use in subsequent verification of character consistency.
[0114] The character data may include product identification and other data.
[0115] For example: Product A has logo A, and Product B has logo B.
[0116] S16, cleaning the third data to obtain fifth data, and cleaning the fourth data to obtain sixth data.
[0117] It is understandable that there may be some invalid characters in the character data, such as " / ", etc. In order to reduce the difficulty of subsequent verification and improve the efficiency of verification, the third data and the fourth data may be cleaned, which will not be elaborated here.
[0118] S17, verifying character consistency according to the fifth data and the sixth data.
[0119] In at least one embodiment of the present invention, verifying the character consistency according to the fifth data and the sixth data includes:
[0120] Performing deduplication processing on the fifth data to obtain character categories and the number of character categories in the fifth data, and performing deduplication processing on the sixth data to obtain character categories and the number of character categories in the sixth data;
[0121] Obtaining the records and the total number of records of each character category in the fifth data, and obtaining the records and the total number of records of each character category in the sixth data;
[0122] Calculating a first sum value corresponding to the fifth data according to the record of each character category in the fifth data;
[0123] Calculating a second sum value corresponding to the sixth data according to the record of each character category in the sixth data;
[0124] Obtaining a maximum value in the records of each character category in the fifth data and a minimum value in the records of each character category in the fifth data;
[0125] Obtaining a maximum value in the records of each character category in the sixth data and a minimum value in the records of each character category in the sixth data;
[0126] Calculating the standard deviation of the fifth data and calculating the standard deviation of the sixth data;
[0127] When the character category in the fifth data is consistent with the character category in the sixth data, and the number of character categories in the fifth data is consistent with the number of character categories in the sixth data, and the total number of records of each character category in the fifth data is consistent with the total number of records of each character category in the sixth data, and the first sum value is consistent with the second sum value, and the maximum value in the records of each character category in the fifth data is consistent with the maximum value in the records of each character category in the sixth data, and the minimum value in the records of each character category in the fifth data is consistent with the minimum value in the records of each character category in the sixth data, and the standard deviation of the fifth data is consistent with the standard deviation of the sixth data, it is determined that the character consistency passes the verification; or
[0128] When the character category in the fifth data is inconsistent with the character category in the sixth data, and / or the number of character categories in the fifth data is inconsistent with the number of character categories in the sixth data, and / or the total number of records of each character category in the fifth data is inconsistent with the total number of records of each character category in the sixth data, and / or the first sum value is inconsistent with the second sum value, and / or the maximum value in the records of each character category in the fifth data is inconsistent with the maximum value in the records of each character category in the sixth data, and / or the minimum value in the records of each character category in the fifth data is inconsistent with the minimum value in the records of each character category in the sixth data, and / or the standard deviation of the fifth data is inconsistent with the standard deviation of the sixth data, it is determined that the character consistency has not passed the verification.
[0129] Among them, through the de-duplication process, it is possible to determine how many types of characters there are, so as to first determine whether the categories of the characters are consistent.
[0130] Furthermore, by calculating relevant data such as character categories, various values are further calculated from a quantitative perspective, and it is determined whether there are character migration errors during the database migration process.
[0131] Through the above implementation, data consistency can be verified in the dimension of character data through data calculation, thereby avoiding the inconsistency of character data during database migration.
[0132] Specifically, calculating the first sum value corresponding to the fifth data according to the record of each character category in the fifth data includes:
[0133] In the fifth data, a record value of each record is obtained from the record of each character category;
[0134] Calculate the cumulative sum of the record values of each record corresponding to each character category as the total record value of each character category;
[0135] A sum operation is performed using the sum of the record values of each character category to obtain a first sum value corresponding to the fifth data.
[0136] For example, in the record of product A, a transaction record appears at 9:00 a.m. on a certain day, and the transaction value (i.e., the record value) is 1 million yuan, and another transaction record appears at 13:00 p.m. on the same day, and the transaction value (i.e., the record value) is 2 million yuan, then the cumulative sum of the record values of the record of product A is 1 million yuan + 2 million yuan = 3 million yuan. Further, the above cumulative sum calculation is performed for each character category in the fifth data, and the sum of all cumulative sums is calculated to obtain the first sum value corresponding to the fifth data.
[0137] In this embodiment, the method of calculating the second sum value corresponding to the sixth data is similar to the method of calculating the first sum value corresponding to the fifth data, which is not repeated here.
[0138] S18, when the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database.
[0139] In the process of database migration, this embodiment automatically and continuously performs verification from multiple dimensions to ensure that the data is accurately migrated from the source database to the target database.
[0140] Furthermore, after determining that the data in the migrated data table has passed the verification, continue to migrate the data from the source database to the target database so as not to affect the normal migration of the database.
[0141] In at least one embodiment of the present invention, the method further comprises:
[0142] When the number of the migrated data tables is inconsistent with the number of the reference data tables, and / or the data consistency fails to pass the verification, and / or the character consistency fails to pass the verification, stopping the migration of data from the source database to the target database;
[0143] Generate warning information and send the warning information to the designated terminal device.
[0144] The designated terminal device may include a developer's terminal device, a tester's terminal device, etc., which is not limited in the present invention.
[0145] The alarm information may be used to prompt the user of the designated terminal device to promptly troubleshoot errors and modify related scripts (such as batch scripts of the target database) so as to correctly perform database migration.
[0146] In addition, when an abnormality is found (i.e., the number of migrated data tables is inconsistent with the number of benchmark data tables, and / or the data consistency fails to pass the verification, and / or the character consistency fails to pass the verification), the migration of data from the source database to the target database is stopped in time to avoid the subsequent data migration from being executed invalidly.
[0147] The sending of the warning information to a designated terminal device includes:
[0148] When the warning information is detected, determining that the verification is completed;
[0149] Transmitting the alarm information to Kafka;
[0150] Connect to the email notification interface;
[0151] When the email notification interface monitors that the Kafka consumes the alarm information, a prompt email with the alarm information is sent to the designated terminal device through the email notification interface.
[0152] Through the above implementation, after the verification is completed, the relevant staff can be automatically notified by email, so as to prompt the relevant staff to check and handle the exception in time, which not only improves the work efficiency of the relevant staff, but also indirectly improves the efficiency of database migration.
[0153] During the database migration process, based on the verification logic in this embodiment, the data source is continuously monitored until the new batch script and the target database completely replace the old batch script and the source database, ensuring that the database migration can be executed accurately and quickly. In addition, the verification logic used in this embodiment can quickly compare massive data (after testing, the verification method in this embodiment can verify tens of millions of data within a few minutes), and perform regular verification as needed, which is efficient and accurate.
[0154] It should be noted that in order to further improve the security of data and prevent data from being maliciously tampered with, the target database can be deployed on the blockchain.
[0155] It can be seen from the above technical scheme that the present invention can respond to a data verification request, obtain a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database, and required data is obtained based on labels and regular expressions, and due to the uniqueness of the labels, the accuracy of the acquired data is guaranteed while the efficiency of data acquisition is improved. During the data migration process, a table in the target database is obtained as a migrated data table at a preset time interval, and a table corresponding to the migrated data table is obtained from the source database as a benchmark data table to verify whether the number of the migrated data tables is consistent with the number of the benchmark data tables. First, the number of migrated data tables is verified to verify whether there is omission or repeated migration of data tables during the database migration process. When the number of migrated data tables is consistent with the number of benchmark data tables, numerical data is obtained from the migrated data table as the first data, and numerical data is obtained from the benchmark data table as the second data. When the number of migrated data tables is consistent with the number of benchmark data tables, it is indicated that During the database migration process, the number of data tables is consistent. At this time, the subsequent verification is continued to be performed to avoid invalid verification from bringing operating burden to the system. The data consistency is verified according to the first data and the second data. When the data consistency passes the verification, the character data is obtained from the migrated data table as the third data, and the character data is obtained from the reference data table as the fourth data. The third data is cleaned to obtain the fifth data, and the fourth data is cleaned to obtain the sixth data, thereby reducing the difficulty of subsequent verification and improving the efficiency of verification. The character consistency is verified according to the fifth data and the sixth data. The data consistency can be verified in the dimension of the character data through data calculation to avoid the inconsistency of the character data during the database migration process. When the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database. Then, during the database migration process, continuous verification is automatically performed from multiple dimensions to ensure that the data is accurately migrated from the source database to the target database, which is efficient and accurate.
[0156] like Figure 2 , which is a functional module diagram of a preferred embodiment of a data verification device based on database migration of the present invention. The data verification device based on database migration 11 includes an acquisition unit 110, a verification unit 111, a cleaning unit 112, and a migration unit 113. The module / unit referred to in the present invention refers to a series of computer program segments that can be executed by a processor 13 and can complete fixed functions, which are stored in a memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0157] In response to the data verification request, the acquisition unit 110 acquires a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database.
[0158] In this embodiment, the data verification request can be automatically triggered. For example, when data migration is started, data is migrated from the source database to the target database, and the data verification request is triggered at the same time to ensure that real-time verification of data can be achieved during the data migration process.
[0159] Of course, in other embodiments, the data verification request may also be triggered by relevant staff according to actual verification requirements, and the present invention is not limited thereto.
[0160] In at least one embodiment of the present invention, the acquiring unit 110 acquires the source database and the target database according to the data verification request, including:
[0161] Parsing the data verification request to obtain information carried by the data verification request;
[0162] Acquire a preconfigured first tag and a second tag, wherein the first tag corresponds to a database identifier of the source database, and the second tag corresponds to a database identifier of the target database;
[0163] Creating a first regular expression according to the first tag, and creating a second regular expression according to the second tag;
[0164] Using the first regular expression to traverse the information carried in the data verification request, and determining the traversed information that matches the first regular expression as the database identifier of the source database, and determining the source database according to the database identifier of the source database;
[0165] The information carried in the data verification request is traversed using the second regular expression, and the traversed information matching the second regular expression is determined as the database identifier of the target database, and the target database is determined according to the database identifier of the target database.
[0166] The first label and the second label can be custom configured.
[0167] For example, the first tag may be configured as SourceID, and the second tag may be configured as TargetID.
[0168] Further, the first regular expression established according to the first tag may be SourceID(), and the second regular expression established according to the second tag may be TargetID().
[0169] Further, the information carried by the data verification request is traversed using the first regular expression SourceID(), and the traversed information matching the first regular expression SourceID() is determined as the database identifier of the source database, and the database with the database identifier of the source database is further determined as the source database. The information carried by the data verification request is traversed using the second regular expression TargetID(), and the traversed information matching the second regular expression TargetID() is determined as the database identifier of the target database, and the database with the database identifier of the target database is further determined as the target database.
[0170] Through the above implementation, the required data can be obtained based on the label and the regular expression, and due to the uniqueness of the label, the data acquisition efficiency is improved while the accuracy of the acquired data is guaranteed.
[0171] During the data migration process, the verification unit 111 obtains a table in the target database as a migrated data table at a preset time interval, and obtains a table corresponding to the migrated data table from the source database as a reference data table.
[0172] In this embodiment, the preset time interval can be customized, such as 5 minutes, 1 minute, etc. The configuration of the preset time interval ensures the frequency of data verification and further ensures the correctness of data migration.
[0173] In this embodiment, the data in the target database is migrated from the source database. Therefore, the original data in the source database is correct and can be used as the basis for subsequent verification, while the data in the target database serves as the object to be verified to determine whether data errors occur during the data migration process.
[0174] The data in the target database and the source database are stored in the form of tables. Therefore, this embodiment obtains a table in the target database as a migrated data table, and obtains a table corresponding to the migrated data table from the source database as a reference data table.
[0175] The data in the migrated data table is the data to be verified, and the data in the reference data table is the reference for verification.
[0176] The verification unit 111 verifies whether the number of the migrated data tables is consistent with the number of the reference data tables.
[0177] It should be noted that during the database migration process, the migrated data may be duplicated or omitted. Therefore, the number of tables needs to be verified first.
[0178] In at least one embodiment of the present invention, the verification unit 111 verifies whether the number of the migrated data tables is consistent with the number of the reference data tables, including:
[0179] Determining the number of the migrated data tables and determining the number of the benchmark data tables;
[0180] When the number of the migrated data tables is equal to the number of the reference data tables, determining that the number of the migrated data tables is consistent with the number of the reference data tables; or
[0181] When the number of the migrated data tables is not equal to the number of the reference data tables, it is determined that the number of the migrated data tables is inconsistent with the number of the reference data tables.
[0182] Through the above implementation, the number of migrated data tables is first verified to verify whether there is any omission or duplication of migration of data tables during the database migration process.
[0183] When the number of the migrated data tables is consistent with the number of the reference data tables, the acquisition unit 110 acquires numerical data from the migrated data tables as first data, and acquires numerical data from the reference data tables as second data.
[0184] It is understandable that when the number of migrated data tables is consistent with the number of benchmark data tables, it means that the number of data tables is consistent during the database migration process. At this time, subsequent verification is continued to avoid invalid verification bringing operational burden to the system.
[0185] Furthermore, numerical data is obtained from the migrated data table as the first data, and numerical data is obtained from the reference data table as the second data, for use in subsequent verification of data consistency.
[0186] The numerical data refers to digital data, such as sales volume.
[0187] The verification unit 111 verifies data consistency according to the first data and the second data.
[0188] In at least one embodiment of the present invention, the verification unit 111 verifies data consistency according to the first data and the second data, including:
[0189] Calculating a data sum of the first data, and calculating a data sum of the second data;
[0190] Obtaining a maximum value in the first data and a minimum value in the first data, and obtaining a maximum value in the second data and a minimum value in the second data;
[0191] Calculating the standard deviation of the first data, and calculating the standard deviation of the second data;
[0192] When the data sum of the first data is consistent with the data sum of the second data, the maximum value in the first data is consistent with the maximum value in the second data, the minimum value in the first data is consistent with the minimum value in the second data, and the standard deviation of the first data is consistent with the standard deviation of the second data, it is determined that the data consistency passes the verification; or
[0193] When the data sum of the first data is inconsistent with the data sum of the second data, and / or the maximum value in the first data is inconsistent with the maximum value in the second data, and / or the minimum value in the first data is inconsistent with the minimum value in the second data, and / or the standard deviation of the first data is inconsistent with the standard deviation of the second data, it is determined that the data consistency has failed the verification.
[0194] Through the above implementation, data consistency can be verified in the dimension of numerical data through data calculation, thereby avoiding data inconsistency during database migration.
[0195] When the data consistency passes the verification, the acquisition unit 110 acquires character data from the migrated data table as the third data, and acquires character data from the reference data table as the fourth data.
[0196] After the data consistency is verified, it indicates that there is no error in data migration in the dimension of numerical data, and therefore, the dimension of character data is further verified.
[0197] Specifically, character data is obtained from the migrated data table as the third data, and character data is obtained from the reference data table as the fourth data, for use in subsequent verification of character consistency.
[0198] The character data may include product identification and other data.
[0199] For example: Product A has logo A, and Product B has logo B.
[0200] The cleaning unit 112 cleans the third data to obtain fifth data, and cleans the fourth data to obtain sixth data.
[0201] It is understandable that there may be some invalid characters in the character data, such as " / ", etc. In order to reduce the difficulty of subsequent verification and improve the efficiency of verification, the third data and the fourth data may be cleaned, which will not be elaborated here.
[0202] The verification unit 111 verifies character consistency according to the fifth data and the sixth data.
[0203] In at least one embodiment of the present invention, the verification unit 111 verifies the character consistency according to the fifth data and the sixth data, including:
[0204] Performing deduplication processing on the fifth data to obtain character categories and the number of character categories in the fifth data, and performing deduplication processing on the sixth data to obtain character categories and the number of character categories in the sixth data;
[0205] Obtaining the records and the total number of records of each character category in the fifth data, and obtaining the records and the total number of records of each character category in the sixth data;
[0206] Calculating a first sum value corresponding to the fifth data according to the record of each character category in the fifth data;
[0207] Calculating a second sum value corresponding to the sixth data according to the record of each character category in the sixth data;
[0208] Obtaining a maximum value in the records of each character category in the fifth data and a minimum value in the records of each character category in the fifth data;
[0209] Obtaining a maximum value in the records of each character category in the sixth data and a minimum value in the records of each character category in the sixth data;
[0210] Calculating the standard deviation of the fifth data and calculating the standard deviation of the sixth data;
[0211] When the character category in the fifth data is consistent with the character category in the sixth data, and the number of character categories in the fifth data is consistent with the number of character categories in the sixth data, and the total number of records of each character category in the fifth data is consistent with the total number of records of each character category in the sixth data, and the first sum value is consistent with the second sum value, and the maximum value in the records of each character category in the fifth data is consistent with the maximum value in the records of each character category in the sixth data, and the minimum value in the records of each character category in the fifth data is consistent with the minimum value in the records of each character category in the sixth data, and the standard deviation of the fifth data is consistent with the standard deviation of the sixth data, it is determined that the character consistency passes the verification; or
[0212] When the character category in the fifth data is inconsistent with the character category in the sixth data, and / or the number of character categories in the fifth data is inconsistent with the number of character categories in the sixth data, and / or the total number of records of each character category in the fifth data is inconsistent with the total number of records of each character category in the sixth data, and / or the first sum value is inconsistent with the second sum value, and / or the maximum value in the records of each character category in the fifth data is inconsistent with the maximum value in the records of each character category in the sixth data, and / or the minimum value in the records of each character category in the fifth data is inconsistent with the minimum value in the records of each character category in the sixth data, and / or the standard deviation of the fifth data is inconsistent with the standard deviation of the sixth data, it is determined that the character consistency has not passed the verification.
[0213] Among them, through the de-duplication process, it is possible to determine how many types of characters there are, so as to first determine whether the categories of the characters are consistent.
[0214] Furthermore, by calculating relevant data such as character categories, various values are further calculated from a quantitative perspective, and it is determined whether there are character migration errors during the database migration process.
[0215] Through the above implementation, data consistency can be verified in the dimension of character data through data calculation, thereby avoiding the inconsistency of character data during database migration.
[0216] Specifically, calculating the first sum value corresponding to the fifth data according to the record of each character category in the fifth data includes:
[0217] In the fifth data, a record value of each record is obtained from the record of each character category;
[0218] Calculate the cumulative sum of the record values of each record corresponding to each character category as the total record value of each character category;
[0219] A sum operation is performed using the sum of the record values of each character category to obtain a first sum value corresponding to the fifth data.
[0220] For example, in the record of product A, a transaction record appears at 9:00 a.m. on a certain day, and the transaction value (i.e., the record value) is 1 million yuan, and another transaction record appears at 13:00 p.m. on the same day, and the transaction value (i.e., the record value) is 2 million yuan, then the cumulative sum of the record values of the record of product A is 1 million yuan + 2 million yuan = 3 million yuan. Further, the above cumulative sum calculation is performed for each character category in the fifth data, and the sum of all cumulative sums is calculated to obtain the first sum value corresponding to the fifth data.
[0221] In this embodiment, the method of calculating the second sum value corresponding to the sixth data is similar to the method of calculating the first sum value corresponding to the fifth data, which is not repeated here.
[0222] When the character consistency passes the verification, the migration unit 113 determines that the data in the migrated data table passes the verification, and continues to migrate the data from the source database to the target database.
[0223] In the process of database migration, this embodiment automatically and continuously performs verification from multiple dimensions to ensure that the data is accurately migrated from the source database to the target database.
[0224] Furthermore, after determining that the data in the migrated data table has passed the verification, continue to migrate the data from the source database to the target database so as not to affect the normal migration of the database.
[0225] In at least one embodiment of the present invention, when the number of the migrated data tables is inconsistent with the number of the reference data tables, and / or the data consistency fails to pass the verification, and / or the character consistency fails to pass the verification, the migration of data from the source database to the target database is stopped;
[0226] Generate warning information and send the warning information to the designated terminal device.
[0227] The designated terminal device may include a developer's terminal device, a tester's terminal device, etc., which is not limited in the present invention.
[0228] The alarm information may be used to prompt the user of the designated terminal device to promptly troubleshoot errors and modify related scripts (such as batch scripts of the target database) so as to correctly perform database migration.
[0229] In addition, when an abnormality is found (i.e., the number of migrated data tables is inconsistent with the number of benchmark data tables, and / or the data consistency fails to pass the verification, and / or the character consistency fails to pass the verification), the migration of data from the source database to the target database is stopped in time to avoid the subsequent data migration from being executed invalidly.
[0230] The sending of the warning information to a designated terminal device includes:
[0231] When the warning information is detected, determining that the verification is completed;
[0232] Transmitting the alarm information to Kafka;
[0233] Connect to the email notification interface;
[0234] When the email notification interface monitors that the Kafka consumes the alarm information, a prompt email with the alarm information is sent to the designated terminal device through the email notification interface.
[0235] Through the above implementation, after the verification is completed, the relevant staff can be automatically notified by email, so as to prompt the relevant staff to check and handle the exception in time, which not only improves the work efficiency of the relevant staff, but also indirectly improves the efficiency of database migration.
[0236] During the database migration process, based on the verification logic in this embodiment, the data source is continuously monitored until the new batch script and the target database completely replace the old batch script and the source database, ensuring that the database migration can be executed accurately and quickly. In addition, the verification logic used in this embodiment can quickly compare massive data (after testing, the verification method in this embodiment can verify tens of millions of data within a few minutes), and perform regular verification as needed, which is efficient and accurate.
[0237] It should be noted that in order to further improve the security of data and prevent data from being maliciously tampered with, the target database can be deployed on the blockchain.
[0238] It can be seen from the above technical scheme that the present invention can respond to a data verification request, obtain a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database, and required data is obtained based on labels and regular expressions, and due to the uniqueness of the labels, the accuracy of the acquired data is guaranteed while the efficiency of data acquisition is improved. During the data migration process, a table in the target database is obtained as a migrated data table at a preset time interval, and a table corresponding to the migrated data table is obtained from the source database as a benchmark data table to verify whether the number of the migrated data tables is consistent with the number of the benchmark data tables. First, the number of migrated data tables is verified to verify whether there is omission or repeated migration of data tables during the database migration process. When the number of migrated data tables is consistent with the number of benchmark data tables, numerical data is obtained from the migrated data table as the first data, and numerical data is obtained from the benchmark data table as the second data. When the number of migrated data tables is consistent with the number of benchmark data tables, it is indicated that During the database migration process, the number of data tables is consistent. At this time, the subsequent verification is continued to be performed to avoid invalid verification from bringing operating burden to the system. The data consistency is verified according to the first data and the second data. When the data consistency passes the verification, the character data is obtained from the migrated data table as the third data, and the character data is obtained from the reference data table as the fourth data. The third data is cleaned to obtain the fifth data, and the fourth data is cleaned to obtain the sixth data, thereby reducing the difficulty of subsequent verification and improving the efficiency of verification. The character consistency is verified according to the fifth data and the sixth data. The data consistency can be verified in the dimension of the character data through data calculation to avoid the inconsistency of the character data during the database migration process. When the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database. Then, during the database migration process, continuous verification is automatically performed from multiple dimensions to ensure that the data is accurately migrated from the source database to the target database, which is efficient and accurate.
[0239] like Figure 3 , which is a schematic diagram of the structure of a computer device of a preferred embodiment of the data verification method based on database migration of the present invention.
[0240] The computer device 1 may include a memory 12 , a processor 13 , and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13 , such as a data verification program based on database migration.
[0241] Those skilled in the art will appreciate that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation on the computer device 1. The computer device 1 may be a bus-type structure or a star-type structure. The computer device 1 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the computer device 1 may also include input and output devices, network access devices, etc.
[0242] It should be noted that the computer device 1 is only an example, and other existing or future electronic products that are suitable for the present invention should also be included in the protection scope of the present invention and included here by reference.
[0243] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the computer device 1, such as a mobile hard disk of the computer device 1. In other embodiments, the memory 12 can also be an external storage device of the computer device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 1. Further, the memory 12 can also include both an internal storage unit of the computer device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the computer device 1, such as the code of the data verification program based on database migration, but also can be used to temporarily store data that has been output or is to be output.
[0244] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the computer device 1, and uses various interfaces and lines to connect various components of the entire computer device 1, and executes various functions and processes data of the computer device 1 by running or executing programs or modules stored in the memory 12 (for example, executing a data verification program based on database migration, etc.), and calling data stored in the memory 12.
[0245] The processor 13 executes the operating system of the computer device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned data verification method embodiments based on database migration, for example Figure 1 Steps shown.
[0246] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the computer device 1. For example, the computer program may be divided into an acquisition unit 110, a verification unit 111, a cleaning unit 112, and a migration unit 113.
[0247] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, and includes a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the data verification method based on database migration described in various embodiments of the present invention.
[0248] If the module / unit integrated in the computer device 1 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 present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware devices through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of each of the above-mentioned method embodiments can be implemented.
[0249] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, etc.
[0250] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0251] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0252] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The bus is represented by only one straight line, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.
[0253] Although not shown, the computer device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 13 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The computer device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0254] Furthermore, the computer device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the computer device 1 and other computer devices.
[0255] Optionally, the computer device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the computer device 1 and to display a visual user interface.
[0256] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0257] Figure 3 Only the computer device 1 having components 12-13 is shown, and it can be understood by those skilled in the art that Figure 3 The structure shown does not constitute a limitation on the computer device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0258] Combination Figure 1 , the memory 12 in the computer device 1 stores a plurality of instructions to implement a data verification method based on database migration, and the processor 13 can execute the plurality of instructions to implement:
[0259] In response to a data verification request, obtaining a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database;
[0260] During the data migration process, obtaining a table in the target database as a migrated data table at a preset time interval, and obtaining a table corresponding to the migrated data table from the source database as a reference data table;
[0261] Verifying whether the number of the migrated data tables is consistent with the number of the benchmark data tables;
[0262] When the number of the migrated data tables is consistent with the number of the reference data tables, acquiring numerical data from the migrated data tables as first data, and acquiring numerical data from the reference data tables as second data;
[0263] Verifying data consistency according to the first data and the second data;
[0264] When the data consistency passes the verification, character data is obtained from the migrated data table as the third data, and character data is obtained from the reference data table as the fourth data;
[0265] Cleaning the third data to obtain fifth data, and cleaning the fourth data to obtain sixth data;
[0266] Verifying character consistency according to the fifth data and the sixth data;
[0267] When the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database.
[0268] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0269] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0270] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0271] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, 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 hardware plus software functional modules.
[0272] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0273] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0274] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the present invention can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0275] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A data verification method based on database migration, characterized in that: The data verification method based on database migration includes: In response to a data verification request, obtaining a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database; During the data migration process, obtaining a table in the target database as a migrated data table at a preset time interval, and obtaining a table corresponding to the migrated data table from the source database as a reference data table; Verifying whether the number of the migrated data tables is consistent with the number of the benchmark data tables; When the number of the migrated data tables is consistent with the number of the reference data tables, obtaining numerical data from the migrated data tables as first data, and obtaining numerical data from the reference data tables as second data; Verifying data consistency according to the first data and the second data; When the data consistency passes the verification, character data is obtained from the migrated data table as the third data, and character data is obtained from the reference data table as the fourth data; Cleaning the third data to obtain fifth data, and cleaning the fourth data to obtain sixth data; Verifying character consistency according to the fifth data and the sixth data; When the character consistency passes the verification, it is determined that the data in the migrated data table passes the verification, and the data is continued to be migrated from the source database to the target database.
2. The data verification method based on database migration according to claim 1, characterized in that: The acquiring of the source database and the target database according to the data verification request comprises: Parsing the data verification request to obtain information carried by the data verification request; Acquire a preconfigured first tag and a second tag, wherein the first tag corresponds to a database identifier of the source database, and the second tag corresponds to a database identifier of the target database; Creating a first regular expression according to the first tag, and creating a second regular expression according to the second tag; Using the first regular expression to traverse the information carried in the data verification request, and determining the traversed information that matches the first regular expression as the database identifier of the source database, and determining the source database according to the database identifier of the source database; The information carried in the data verification request is traversed using the second regular expression, and the traversed information matching the second regular expression is determined as the database identifier of the target database, and the target database is determined according to the database identifier of the target database.
3. The data verification method based on database migration according to claim 1, characterized in that: Verifying data consistency according to the first data and the second data includes: Calculating a data sum of the first data, and calculating a data sum of the second data; Obtaining a maximum value of the first data and a minimum value of the first data, and obtaining a maximum value of the second data and a minimum value of the second data; Calculating the standard deviation of the first data, and calculating the standard deviation of the second data; When the data sum of the first data is consistent with the data sum of the second data, the maximum value in the first data is consistent with the maximum value in the second data, the minimum value in the first data is consistent with the minimum value in the second data, and the standard deviation of the first data is consistent with the standard deviation of the second data, it is determined that the data consistency passes the verification; or When the data sum of the first data is inconsistent with the data sum of the second data, and / or the maximum value in the first data is inconsistent with the maximum value in the second data, and / or the minimum value in the first data is inconsistent with the minimum value in the second data, and / or the standard deviation of the first data is inconsistent with the standard deviation of the second data, it is determined that the data consistency has failed the verification.
4. The data verification method based on database migration according to claim 1, characterized in that: The verifying character consistency according to the fifth data and the sixth data comprises: Performing deduplication processing on the fifth data to obtain character categories and the number of character categories in the fifth data, and performing deduplication processing on the sixth data to obtain character categories and the number of character categories in the sixth data; Obtaining the records and the total number of records of each character category in the fifth data, and obtaining the records and the total number of records of each character category in the sixth data; Calculating a first sum value corresponding to the fifth data according to the record of each character category in the fifth data; Calculating a second sum value corresponding to the sixth data according to the record of each character category in the sixth data; Obtaining the maximum value in the records of each character category in the fifth data and the minimum value in the records of each character category in the fifth data; Obtaining a maximum value in the records of each character category in the sixth data and a minimum value in the records of each character category in the sixth data; Calculating the standard deviation of the fifth data and calculating the standard deviation of the sixth data; When the character category in the fifth data is consistent with the character category in the sixth data, and the number of character categories in the fifth data is consistent with the number of character categories in the sixth data, and the total number of records of each character category in the fifth data is consistent with the total number of records of each character category in the sixth data, and the first sum value is consistent with the second sum value, and the maximum value in the records of each character category in the fifth data is consistent with the maximum value in the records of each character category in the sixth data, and the minimum value in the records of each character category in the fifth data is consistent with the minimum value in the records of each character category in the sixth data, and the standard deviation of the fifth data is consistent with the standard deviation of the sixth data, it is determined that the character consistency passes the verification; or When the character category in the fifth data is inconsistent with the character category in the sixth data, and / or the number of character categories in the fifth data is inconsistent with the number of character categories in the sixth data, and / or the total number of records of each character category in the fifth data is inconsistent with the total number of records of each character category in the sixth data, and / or the first sum value is inconsistent with the second sum value, and / or the maximum value in the records of each character category in the fifth data is inconsistent with the maximum value in the records of each character category in the sixth data, and / or the minimum value in the records of each character category in the fifth data is inconsistent with the minimum value in the records of each character category in the sixth data, and / or the standard deviation of the fifth data is inconsistent with the standard deviation of the sixth data, it is determined that the character consistency has not passed the verification.
5. The data verification method based on database migration according to claim 4, characterized in that: The calculating the first sum value corresponding to the fifth data according to the record of each character category in the fifth data comprises: In the fifth data, a record value of each record is obtained from the record of each character category; Calculate the cumulative sum of the record values of each record corresponding to each character category as the total record value of each character category; A sum operation is performed using the sum of the record values of each character category to obtain a first sum value corresponding to the fifth data.
6. The data verification method based on database migration according to claim 1, characterized in that: The method further comprises: When the number of the migrated data tables is inconsistent with the number of the reference data tables, and / or the data consistency fails to pass the verification, and / or the character consistency fails to pass the verification, stopping the migration of data from the source database to the target database; Generate warning information and send the warning information to the designated terminal device.
7. The data verification method based on database migration according to claim 6, characterized in that: The sending of the alarm information to a designated terminal device comprises: When the warning information is detected, determining that the verification is completed; Transmitting the alarm information to Kafka; Connect to the email notification interface; When the email notification interface monitors that the Kafka consumes the alarm information, a prompt email with the alarm information is sent to the designated terminal device through the email notification interface.
8. A data verification device based on database migration, characterized in that: The data verification device based on database migration includes: an acquisition unit, configured to respond to a data verification request and acquire a source database and a target database according to the data verification request, wherein data is migrated from the source database to the target database; The acquisition unit is further configured to acquire, during the data migration process, a table in the target database as a migrated data table at a preset time interval, and acquire a table corresponding to the migrated data table from the source database as a reference data table; A verification unit, used to verify whether the number of the migrated data tables is consistent with the number of the reference data tables; The acquisition unit is further configured to acquire numerical data from the migrated data table as first data and acquire numerical data from the benchmark data table as second data when the number of the migrated data table is consistent with the number of the benchmark data table; The verification unit is further used to verify data consistency according to the first data and the second data; The acquisition unit is further configured to acquire character data from the migrated data table as third data and acquire character data from the reference data table as fourth data when the data consistency passes verification; a cleaning unit, configured to clean the third data to obtain fifth data, and clean the fourth data to obtain sixth data; The verification unit is further used to verify character consistency according to the fifth data and the sixth data; The migration unit is used to determine that the data in the migrated data table passes the verification when the character consistency passes the verification, and continue to migrate the data from the source database to the target database.
9. A computer device, characterized in that: The computer device comprises: a memory storing at least one instruction; and A processor executes instructions stored in the memory to implement the data verification method based on database migration as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the data verification method based on database migration as described in any one of claims 1 to 7.
