A database checking method and device
By generating data statistics files through a verification server and performing consistency verification at the database sharding level, the problem of low efficiency in database consistency verification in existing technologies is solved, improving the efficiency and flexibility of database consistency verification and ensuring high availability and security of the database.
Patent Information
- Application Number
- CN202111549739.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2041-12-17
AI Technical Summary
Existing database consistency verification methods are inefficient and have a significant impact on online transactions. They cannot be executed frequently during peak periods, resulting in low database consistency verification efficiency and affecting the high availability and security of the database.
A verification server is used to perform database consistency verification, generate data statistics files and send them to the target database for data statistics. Based on the verification strategy at the business logic level, SCP remote commands are used for data transmission and consistency verification is performed at the database sharding level, generating process log files and verification results.
It enables automated consistency verification of multiple databases, improving verification efficiency and flexibility, reducing the impact on online business, and ensuring high availability and security of the database.
Smart Images

Figure CN116266178B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database, and particularly relates to a database verification method and device. BACKGROUND
[0002] Nowadays, the use scenarios of databases are very wide, most business systems have high security and high reliability requirements for databases, and especially in the related scenarios involving financial business, the data security in the database is required to be higher.
[0003] In order to ensure that data is not lost, in the scenario of a distributed database, the database is mainly deployed in a master-slave mode, and in actual database operation and maintenance work, by ensuring the data consistency between the master database and the slave database, the reliability of the database can be improved, and the safety of the data can be ensured to the greatest extent.
[0004] At present, the consistency verification of the database is usually a physical layer verification, for example, by using the Checksum table to compare the data of each table in the master database and the slave database, however, this method can greatly affect online transactions, and usually cannot be executed online or can only be executed during the low peak period of business, which greatly limits the application scenarios, and the consistency verification efficiency of the database is not high. SUMMARY
[0005] Embodiments of the present application provide a database verification method and device to improve the consistency verification efficiency of the database.
[0006] The embodiments of the present application adopt the following technical solutions:
[0007] In a first aspect, the embodiments of the present application provide a database verification method executed by a verification server, wherein the method comprises:
[0008] receiving a database consistency verification request, wherein the database consistency verification request is a request for consistency verification of data in a plurality of target databases;
[0009] generating a data statistics file according to the database consistency verification request;
[0010] sending the data statistics file to the machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistics file;
[0011] performing consistency verification on the target databases according to the data statistics results returned by the machines where the target databases are located, to obtain a database consistency verification result.
[0012] Optionally, the receiving of the database consistency verification request comprises:
[0013] verifying the database consistency check request;
[0014] if the verification is passed, generating a data statistics file according to the database consistency check request is performed;
[0015] if the verification is not passed, a prompt information is output.
[0016] Optionally, the generating of the data statistics file according to the database consistency check request comprises:
[0017] determining an IP address of a target database and a check range according to the database consistency check request;
[0018] generating the data statistics file according to the IP address of the target database and the check range.
[0019] Optionally, the database consistency check request comprises a data center identifier, and the determining of the IP address of the target database according to the database consistency check request comprises:
[0020] determining a target data center and at least one set of sub-databases contained in the target data center according to the data center identifier, wherein the sub-databases are constructed based on a master-slave relationship between databases;
[0021] obtaining IP addresses of all databases contained in each sub-database as the IP addresses of target databases of each sub-database.
[0022] Optionally, each sub-database comprises a master database and a standby database, and the obtaining of the IP addresses of all databases contained in each sub-database as the IP addresses of target databases of each sub-database comprises:
[0023] obtaining an IP address of the master database in each sub-database;
[0024] obtaining an IP address of the standby database in each sub-database according to the IP address of the master database in each sub-database;
[0025] taking the IP address of the master database and the IP address of the standby database in each sub-database as the IP addresses of target databases of each sub-database.
[0026] Optionally, the database consistency check request comprises an IP address of at least one database, and the determining of the IP address of the target database according to the database consistency check request comprises:
[0027] determining a sub-database in which each database is located according to the IP address of each database;
[0028] obtaining IP addresses of all databases in each sub-database as the IP addresses of target databases of each sub-database.
[0029] Optionally, the sending of the data statistics file to the machine where each target database is located, so that the machine where each target database is located performs data statistics according to the data statistics file comprises:
[0030] sending the data statistics file to the machine where the target database under the same sub-library is located through an SCP remote command, so that the machine where the target database under the same sub-library is located performs data statistics according to the data statistics file respectively;
[0031] receiving the data statistics result returned by the machine where the target database under the same sub-library is located.
[0032] Optionally, the performing of the consistency check on each target database according to the data statistics result returned by the machine where each target database is located, to obtain a database consistency check result comprises:
[0033] comparing the data statistics result returned by the target database under the same sub-library with each other;
[0034] if the comparison is consistent, a database consistency check result of passing the check is obtained;
[0035] if the comparison is inconsistent, a database consistency check result of failing the check is obtained.
[0036] Optionally, after the sending of the data statistics file to the machine where each target database is located, the method further comprises:
[0037] receiving a process log file returned by each target database;
[0038] storing the process log file and the database consistency check result into a preset check database.
[0039] Optionally, after the performing of the consistency check on each target database according to the data statistics result returned by the machine where each target database is located, to obtain a database consistency check result, the method further comprises:
[0040] if the database consistency check result is of failing the check, obtaining a process log file of each target database;
[0041] determining an abnormal target database and abnormal data according to the process log file of each target database.
[0042] Optionally, the method further comprises:
[0043] providing a front-end page;
[0044] the receiving of the database consistency check request comprises:
[0045] The database consistency check request is received through the front-end page.
[0046] In a second aspect, the embodiments of the present application further provide a database check device, applied to a check server, wherein the device is used to implement any of the foregoing methods.
[0047] In a third aspect, the embodiments of the present application further provide an electronic device, comprising:
[0048] a processor; and
[0049] a memory arranged to store computer-executable instructions that, when executed, cause the processor to perform any of the foregoing methods.
[0050] In a fourth aspect, the embodiments of the present application further provide a computer-readable storage medium storing one or more programs, which, when executed by an electronic device comprising a plurality of applications, cause the electronic device to perform any of the foregoing methods.
[0051] The above at least one technical solution adopted by the embodiments of the present application can achieve the following beneficial effects: The database check method of the embodiments of the present application can be executed by a separately deployed check server. When performing database check, the database consistency check request is first received, wherein the database consistency check request refers to a request for performing consistency check on data in a plurality of target databases. Then, a data statistics file is generated according to the database consistency check request. After that, the data statistics file is sent to machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistics file. Finally, consistency check is performed on the target databases according to data statistics results returned by the machines where the target databases are located, and a database consistency check result is obtained. The database check method of the embodiments of the present application can realize automatic check on data consistency of a plurality of databases, and has higher check efficiency and flexibility. The check result can help database managers or business personnel to quickly find inconsistent data and solve the problem in time, thereby reducing the impact on actual business and ensuring high availability and high security of the database. BRIEF DESCRIPTION OF DRAWINGS
[0052] The accompanying drawings, which are included to provide a further understanding of the present application, constitute a part of the present application, illustrate the illustrative embodiments of the present application and their description serves to explain the present application, and do not constitute improper limitations on the present application. In the drawings:
[0053] Figure 1 FIG. 1 is a flowchart of a database check method according to an embodiment of the present application;
[0054] Figure 2A database verification process schematic diagram in an embodiment of the present application;
[0055] Figure 3 A database verification device structure schematic diagram in an embodiment of the present application;
[0056] Figure 4 A structure schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0057] To make the objectives, technical solutions and advantages of the present application clearer, the following will be a clear and complete description of the technical solutions of the present application in combination with the embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0058] The following will be a detailed description of the technical solutions provided by the embodiments of the present application in combination with the drawings.
[0059] A database verification method of an embodiment of the present application is executed by a verification server, as shown in the following flowchart, a database verification method in an embodiment of the present application is provided, and the method at least includes the following steps S110 to S140: Figure 1
[0060] Step S110, receiving a database consistency verification request, wherein the database consistency verification request refers to a request for consistency verification of data in a plurality of target databases.
[0061] The database verification method of the present application can be executed by a separately deployed verification server, that is, a server independent of the database server is used to uniformly execute the database verification operation. Compared with the way of directly performing data consistency verification on the database server, the database verification method of the present application has a lower degree of intrusion on the database server and occupies fewer resources of the database server, thereby reducing the impact on actual business.
[0062] In the database verification, a database consistency verification request is first received, wherein the database consistency verification request refers to a request for consistency verification of data in a plurality of target databases, which can be specifically a data consistency verification request between primary and backup databases.
[0063] The above database consistency verification request can be triggered by a user actively, or automatically triggered according to a preset verification frequency. How to trigger is flexible and can be set by those skilled in the art according to actual needs, which is not limited here.
[0064] Step S120, generating a data statistics file according to the database consistency check request.
[0065] In view of the fact that the data inconsistency between the primary and standby databases is less in actual business scenarios, if only the database check method at the physical layer is used to check the data in all database tables, the IO load to be occupied will be very high, and the time consumption will be longer. When the database server is in the business peak period, the consistency check operation at the physical layer cannot be performed at a high frequency, thereby resulting in low efficiency of the database consistency check and poor real-time performance.
[0066] Based on this, after receiving the database consistency check request, the embodiment of the present application can generate a data statistics file according to the specific check parameters carried in the request. The data statistics file can be regarded as a predefined check strategy at the business logic layer, and can specifically include the dimension of data statistics, the way of statistics and the like. For example, the number of data, the size of data and the business state in each data table can be counted. Of course, how to configure the information contained in the data statistics file can be adjusted flexibly by the person skilled in the art according to the actual business requirements, which is not limited here.
[0067] Step S130, sending the data statistics file to the machine where each target database is located, so that the machine where each target database is located performs data statistics according to the data statistics file.
[0068] After the data statistics file is generated, the data statistics file is sent to the machine where each target database is located, so that each target database can perform statistics on the data according to the statistical dimension and the statistical way and the like contained in the data statistics file, and obtain the data statistics result.
[0069] Step S140, performing consistency check on each target database according to the data statistics result returned by the machine where each target database is located, and obtaining the database consistency check result.
[0070] According to the data statistics result returned by the machine where each target database is located, the data of each database is checked for consistency, and then the database consistency check result can be obtained. As long as the data statistics result of each target database obtained based on the data statistics file conforms to the business logic, the consistency required by the business can be guaranteed. Compared with the check method at the physical layer, the process is more efficient, and has little effect on the online business.
[0071] The database checking method of the embodiments of the present application can realize automatic checking of the data consistency of multiple databases, and has higher checking efficiency and flexibility. The checking result can help database managers or business personnel to quickly find inconsistent data and solve the problem in time, thereby reducing the impact on actual business and ensuring high availability and high security of the database.
[0072] In an embodiment of the present application, the receiving of the database consistency checking request comprises: verifying the database consistency checking request; if the verification is passed, performing the step of generating a data statistics file according to the database consistency checking request; and if the verification is not passed, outputting prompt information.
[0073] In order to ensure the smooth progress of the subsequent database checking process, after receiving the database consistency checking request triggered by the user, the embodiments of the present application can also perform legality verification on the parameters in the database consistency checking request, for example, verifying whether the format of the parameters carried in the request conforms to the pre-set parameter format, whether the parameter type conforms to the business requirements, and the like. If the legality verification is passed, the subsequent steps can be performed, and if the verification is not passed, the user can be reminded to re-initiate the database consistency checking request by outputting prompt information.
[0074] In an embodiment of the present application, the generating of the data statistics file according to the database consistency checking request comprises: determining the IP address and the checking range of the target database according to the database consistency checking request; and generating the data statistics file according to the IP address of the target database and the checking range.
[0075] In the distributed database scenario, the number of databases is large. If the consistency checking operation is performed on all the databases, it is obviously impossible to meet the actual business requirements, the flexibility is poor, and the time consumption is also high. Therefore, when performing the database checking operation, the embodiments of the present application can first determine which databases to perform the consistency checking operation according to the IP address carried in the database consistency checking request, that is, determine the IP address list of the target database.
[0076] In addition, since the business in some business scenarios is usually uninterrupted, for example, transaction business, transaction data can be generated at any time, so the database server is also in real-time operation, resulting in a very large amount of data generated by the database. If all the data is checked for consistency, there will also be problems such as high time consumption and low efficiency. Therefore, the embodiment of the application can determine which data in a time range to perform a consistency check operation according to the time information such as transaction creation time and transaction batch number carried in the database consistency check request, that is, to determine the check range, and then the efficiency and real-time performance of the database consistency check can be improved through multiple segmented check operations.
[0077] Based on the determined IP address of the target database and the check range, a corresponding data statistics file can be generated, that is, through the data statistics file, it can be determined which data in which database in which time range to perform which statistical operation.
[0078] In an embodiment of the application, the database consistency check request includes a data center identifier, and the determination of the IP address of the target database according to the database consistency check request includes: determining a target data center and at least one set of sub-databases contained in the target data center according to the data center identifier, wherein the sub-databases are constructed based on the master-slave relationship between databases; and obtaining the IP addresses of all databases contained in each sub-database as the IP addresses of the target databases of each sub-database.
[0079] As mentioned earlier, in the distributed database scenario, the data center mainly adopts the master-slave mode for database deployment, and one master database and multiple standby databases can constitute a set of sub-databases. The data between the master-slave databases in a set of sub-databases should be kept synchronized and consistent, so the consistency check of the embodiment of the application can be regarded as an operation performed in the sub-database dimension.
[0080] A data center usually has multiple sets of sub-databases deployed to ensure the high availability of the entire business system. Based on this, the embodiment of the application can carry a data center identifier when triggering a database consistency check request, and then the consistency check of all databases under a data center can be realized. Specifically, the target data center and the sub-databases contained in the target data center can be determined according to the data center identifier, and then the IP addresses of all databases contained in each set of sub-databases are obtained as the IP addresses of the target databases of each set of sub-databases, so as to subsequently perform consistency check on the databases in each set of sub-databases respectively.
[0081] In an embodiment of the present application, each sub-library includes a master database and a standby database, and the IP addresses of all databases included in each sub-library are acquired as the IP addresses of the target databases of each sub-library, including: acquiring the IP address of the master database in each sub-library; acquiring the IP address of the standby database in each sub-library according to the IP address of the master database in each sub-library; and taking the IP addresses of the master database and the standby database in each sub-library as the IP addresses of the target databases of each sub-library.
[0082] In acquiring the IP addresses of all databases in each sub-library, the IP address of the master database of each sub-library can be determined first, and then the IP address of the standby database corresponding to the IP address of the master database in each sub-library can be acquired according to the IP address of the master database, and then the IP address of the master database and the IP address of the standby database in each sub-library can be taken as the IP addresses of the target databases of the sub-library.
[0083] Of course, in addition to the above acquisition method, those skilled in the art can also directly acquire the IP addresses of all databases in each sub-library under the data center from the preset configuration information resource library. How to acquire the IP address can be flexibly set according to actual needs, and is not limited here.
[0084] In an embodiment of the present application, the database consistency check request includes the IP address of at least one database, and the IP address of the target database is determined according to the database consistency check request, including: determining the sub-library where each database is located according to the IP address of each database; and acquiring the IP addresses of all databases in each sub-library as the IP addresses of the target databases of each sub-library.
[0085] In addition to being able to perform consistency check on all databases under one data center, a user can also perform consistency check operation on only one or several specific databases to meet different verification needs of actual business scenarios. For example, the database consistency check request can carry the IP address of one or more databases. Since the database consistency check is performed in the dimension of sub-library, the sub-library where each database is located can be determined according to the IP address of each database, and then the IP address of other databases in each sub-library except the database can be acquired, or the IP addresses of all databases can be directly acquired as the IP addresses of the target databases of each sub-library.
[0086] For example, assuming that the database consistency check request carries the IP address of database A1, the IP address of database A1 can be used to determine that database A1 is located in sub-database 01, and the IP address of database A1 can be used to further obtain the IP addresses of other databases in sub-database 01, such as database A2, database A3, and database A4. Then, the IP addresses of database A1, database A2, database A3, and database A4 are used as the IP addresses of the target databases of sub-database 01, so as to subsequently perform consistency check on the data in database A1, database A2, database A3, and database A4.
[0087] In an embodiment of the present application, the sending of the data statistics file to the machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistics file comprises: sending the data statistics file to the machines where the target databases under the same sub-database are located through SCP remote command, so that the machines where the target databases under the same sub-database are located perform data statistics according to the data statistics file respectively; and receiving the data statistics results returned by the machines where the target databases under the same sub-database are located.
[0088] The embodiment of the present application can use SCP (Secure copy) remote command to send the data statistics file to the machines where the target databases are located. SCP remote command is a command for remotely copying files, and can realize data transmission between local and remote. Of course, those skilled in the art can also use other communication commands to perform data transmission according to actual conditions, which are not listed here.
[0089] The embodiment of the present application can send the data statistics file to the machines where all the target databases under the same sub-database are located through SCP remote command, so that the machines where the target databases in the same sub-database are located can perform data statistics according to the data statistics file respectively, and then the data statistics results of all the target databases under the same sub-database can be obtained.
[0090] It should be noted that in actual application scenarios, the verification requirements of users can be different for different data centers or different sub-libraries. For example, some sub-libraries can only verify data in the last two days, and other sub-libraries need to verify data in the last three days, and so on. This results in that there can be multiple data statistics files generated for different sub-libraries, for example, the data statistics files x1, x2, x3, etc. When the data statistics files are delivered, they can be delivered according to the dimensions of the sub-libraries, for example, the data statistics file x1 is delivered to all databases in the sub-library 01, the data statistics file x2 is delivered to all databases in the sub-library 02, and the data statistics file x3 is delivered to all databases in the sub-library 03, and so on, so that the databases in each sub-library perform corresponding data statistics operations according to the received data statistics files.
[0091] In an embodiment of the present application, the consistency verification of each target database according to the data statistics results returned by the machines where the target databases are located includes: comparing the data statistics results returned by the target databases under the same sub-library with each other; if the comparison is consistent, a database consistency verification result of passing the verification is obtained; if the comparison is inconsistent, a database consistency verification result of failing the verification is obtained.
[0092] After obtaining the data statistics results returned by the machines where the target databases are located, the data statistics results returned by each target database under the same sub-library can be compared with each other in the dimension of the sub-library. If the comparison is consistent, it means that the consistency verification passes; if the comparison is inconsistent, it means that the consistency verification fails, and further determination of abnormal data is needed to avoid affecting the accuracy of business processing.
[0093] In order to facilitate the understanding of the embodiments of the present application, an example of data statistics results is provided as shown in Table 1. As can be seen from Table 1, in the two statistics dimensions of the total number of data tables and the size of data tables, the statistics results of each data table in the master database A1 and the standby databases A2, A3 and A4 are the same, so it can be considered that the consistency verification result of all databases in the sub-library 01 is passing the verification.
[0094] Table 1
[0095]
[0096] In an embodiment of the present application, after the data statistics file is sent to the machines where the target databases are located, the method further includes: receiving process log files returned by each target database;
[0097] The process log files and the database consistency verification result are stored in a preset verification database.
[0098] In order to facilitate subsequent management of the data statistics process of each target database and exception troubleshooting, the embodiment of the present application can also obtain the process log files returned by the target databases after sending the data statistics file to the machines where the target databases are located. The process log file can be understood as a file recording the entire process of the statistical operation performed by each target database according to the received data statistics file.
[0099] The process log files returned by the target databases and the database consistency check results are stored in the preset check database as a basis for subsequent review. In addition, in order to save storage space, the retention time of the process log files and the database consistency check results can be flexibly set according to actual conditions. For example, the retention time can be set to 5 days, and the process log files and the database consistency check results generated 5 days ago are cleaned up after 5 days, so as to save storage space by cleaning up expired files in a timely manner.
[0100] In an embodiment of the present application, after performing consistency check on the target databases according to the data statistics results returned by the machines where the target databases are located and obtaining the database consistency check results, the method further comprises: if the database consistency check result is a check failure, obtaining the process log files of the target databases; determining the abnormal target database and the abnormal data according to the process log files of the target databases.
[0101] When the obtained database consistency check result is a check failure result, it indicates that the data statistics results of one or more databases in the database group are not completely consistent. On the one hand, it may be a problem in data synchronization, and on the other hand, it may be a problem in data statistics.
[0102] In order to locate the problem in a timely manner, the process log files of each target database under the database group can be obtained. The data statistics process of each target database can be restored through the process log file, and the cause of the exception can be quickly determined. Of course, if it is found through the process log file that the data statistics process of each target database is not a problem, it can be considered that there is a problem in data synchronization, and the target database can be checked for synchronization relationship and the like.
[0103] For example, if the total number of data tables of the data table a12 in the primary database A1, the data table a32 in the standby database A3 and the data table a42 in the standby database A4 is 2000, and the total number of data tables of the data table a22 in the standby database A2 is 1900, it can be determined that the standby database A2 is an abnormal target database, and thus the standby database A2 can be further checked to determine whether a problem occurs in the synchronization stage or the statistics stage, so as to timely perform fault processing on the standby database A2.
[0104] In an embodiment of the present application, the method further comprises: providing a front-end page; and the receiving of the database consistency check request comprises: receiving the database consistency check request through the front-end page.
[0105] In order to realize the visualization of the database check process, the front-end page is further provided in the embodiments of the present application, on which the user can trigger the database consistency check request by inputting or selecting the check parameters.
[0106] In addition, the database consistency check result can be displayed on the front-end page, which can specifically include the result of passing the database consistency check or the result of failing the database consistency check. For the result of failing the database consistency check, the target database failing the check and the specific inconsistent statistics can be specifically displayed, so that the user can intuitively and timely check the database consistency check result, and the user experience is improved.
[0107] In order to facilitate the understanding of the embodiments of the present application, as shown in Figure 2 A database check flowchart in the embodiments of the present application is provided. First, a database consistency check request is received, and then the check parameters in the database consistency check request are verified for legality. If the verification for legality fails, a prompt information is output. If the verification for legality passes, it is determined whether the check parameters carried in the database consistency check request are IDC identifiers or IP addresses. If the check parameters are IDC identifiers, the IP addresses of all primary databases under the IDC identifiers are determined, the IP addresses of all standby databases in the sub-database where each primary database is located are obtained according to the IP addresses of the primary databases, and the IP addresses of the primary databases and all standby databases in each sub-database are taken as the IP addresses of the target databases of the sub-database. If the check parameters carried in the database consistency check request are IP addresses, the IP addresses of all other databases in the sub-database where the database is located are directly obtained, and the IP address of the database and the IP addresses of all other databases are taken as the IP addresses of the target databases of the sub-database.
[0108] After obtaining the IP addresses of the target databases, a data statistics file is generated in combination with the check range carried in the database consistency check request, and then the data statistics file is sent to the machines where the target databases are located by SCP remote command, so that the machines where the target databases are located can perform data statistics according to the corresponding data statistics file and obtain data statistics results and process log files.
[0109] According to the data statistics results returned by the machines where the target databases are located, the database consistency check results are output by mutual checking in the dimension of the sub-databases, and the database consistency check results and the process log files are stored in a preset check database for subsequent viewing.
[0110] The database check process of the present application realizes automatic checking of the data consistency of multiple databases based on the comparison logic required by the business, and displays the consistency check results to the user, thereby improving the user experience while meeting the basic check function. In addition, the present application can support the setting of the target databases to be checked and the check range, regardless of the number of databases, and has high operation flexibility, can check multiple sets of sub-databases in multiple data centers concurrently, and has higher check efficiency.
[0111] The present application also provides a database check device 300 applied to a check server, as shown in the figure, a structure diagram of a database check device in the present application is provided, the device 300 comprises a first receiving unit 310, a generating unit 320, a sending unit 330 and a check unit 340, wherein:
[0112] The first receiving unit 310 is configured to receive a database consistency check request, wherein the database consistency check request is a request for checking the consistency of data in multiple target databases.
[0113] The generating unit 320 is configured to generate a data statistics file according to the database consistency check request.
[0114] The sending unit 330 is configured to send the data statistics file to the machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistics file.
[0115] The check unit 340 is configured to check the consistency of the target databases according to the data statistics results returned by the machines where the target databases are located, and obtain database consistency check results.
[0116] In an embodiment of the present application, the first receiving unit 310 is specifically configured to: verify the database consistency check request; if the verification is passed, perform the step of generating a data statistics file according to the database consistency check request; and if the verification is not passed, output a prompt information.
[0117] In an embodiment of the present application, the generating unit 320 is specifically configured to: determine an IP address of a target database and a check range according to the database consistency check request; and generate the data statistics file according to the IP address of the target database and the check range.
[0118] In an embodiment of the present application, the generating unit 320 is specifically configured to: determine a target data center and at least one set of sub-databases contained in the target data center according to the data center identifier, wherein the sub-databases are constructed based on a master-slave relationship between databases; and obtain IP addresses of all databases contained in each sub-database as the IP addresses of target databases of each sub-database.
[0119] In an embodiment of the present application, each sub-database includes a master database and a standby database, and the generating unit 320 is specifically configured to: obtain the IP address of the master database in each sub-database; obtain the IP address of the standby database in each sub-database according to the IP address of the master database in each sub-database; and take the IP addresses of the master database and the standby database in each sub-database as the IP addresses of the target databases of each sub-database.
[0120] In an embodiment of the present application, the database consistency check request includes the IP addresses of at least one database, and the generating unit 320 is specifically configured to: determine the sub-database where each database is located according to the IP address of each database; and obtain the IP addresses of all databases in each sub-database as the IP addresses of the target databases of each sub-database.
[0121] In an embodiment of the present application, the sending unit 330 is specifically configured to: send the data statistics file to a machine where the target databases under the same sub-database are located through an SCP remote command, so that the machine where the target databases under the same sub-database are located respectively performs data statistics according to the data statistics file; and receive data statistics results returned by the machine where the target databases under the same sub-database are located.
[0122] In an embodiment of the present application, the checking unit 340 is specifically configured to: compare the data statistics results returned by the target databases under the same sub-database with each other; if the comparison is consistent, obtain a database consistency check result of passing the check; and if the comparison is inconsistent, obtain a database consistency check result of failing the check.
[0123] In an embodiment of the present application, the apparatus further comprises a second receiving unit configured to receive the process log files returned by each target database; and a storage unit configured to store the process log files and the database consistency check result into a preset check database.
[0124] In an embodiment of the present application, the apparatus further comprises an obtaining unit configured to, if the database consistency check result is a check failure, obtain the process log files of each target database; and a determining unit configured to determine the abnormal target database and the abnormal data according to the process log files of each target database.
[0125] In an embodiment of the present application, the apparatus further comprises a providing unit configured to provide a front-end page; and the first receiving unit 310 is specifically configured to receive the database consistency check request through the front-end page.
[0126] It can be understood that the above-mentioned database check apparatus can realize each step of the database data check method performed by the check server in the foregoing embodiments, and the related explanations about the database data check method are all applicable to the database check apparatus, which will not be repeated here.
[0127] Figure 4 is a structural schematic diagram of an electronic device according to an embodiment of the present application. Please refer to Figure 4 At the hardware level, the electronic device comprises a processor, and optionally further comprises an internal bus, a network interface, and a memory. The memory can include a memory such as a high-speed random access memory (RAM), and can also include a non-volatile memory such as at least one disk memory. Of course, the electronic device can also include other hardware required by the business.
[0128] The processor, the network interface, and the memory can be connected to each other through the internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 In the figure, only one bidirectional arrow is used to represent the bus, but it does not mean that there is only one bus or only one type of bus.
[0129] The memory is configured to store a program. Specifically, the program can include program code including computer operation instructions. The memory can include an internal memory and a non-volatile memory, and provide instructions and data for the processor.
[0130] The processor reads the corresponding computer program from the non-volatile memory into the internal memory and then runs, and forms the database consistency checking device at a logical level. The processor executes the program stored in the memory, and is specifically configured to perform the following operations:
[0131] receive a database consistency checking request, wherein the database consistency checking request refers to a request for consistency checking of data in a plurality of target databases;
[0132] generate a data statistics file according to the database consistency checking request;
[0133] send the data statistics file to a machine where each target database is located, so that the machine where each target database is located performs data statistics according to the data statistics file;
[0134] perform consistency checking on each target database according to a data statistics result returned by the machine where each target database is located, and obtain a database consistency checking result.
[0135] The above as described in the present application Figure 1The method performed by the database checking device disclosed in the embodiments shown can be applied to a processor or implemented by the processor. The processor can be an integrated circuit chip with processing capability. In the implementation process, each step of the above method can be completed by integrated logic circuits in the hardware of the processor or instructions in the form of software. The processor mentioned above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; or a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. Each method, step and logic block disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium in the storage is read by the processor, and the hardware thereof is combined to complete the steps of the above method.
[0136] The electronic device can also execute the method performed by the database checking device in the database checking device, and implement the functions of the database checking device in the database checking device. The embodiments of the present application will not be repeated here. Figure 1 The electronic device can also execute the method performed by the database checking device in the database checking device, and implement the functions of the database checking device in the database checking device. The embodiments of the present application will not be repeated here. Figure 1 The electronic device can also execute the method performed by the database checking device in the database checking device, and implement the functions of the database checking device in the database checking device. The embodiments of the present application will not be repeated here.
[0137] The embodiments of the present application also propose a computer readable storage medium storing one or more programs, the one or more programs including instructions that, when executed by an electronic device including a plurality of application programs, can enable the electronic device to execute the method performed by the database checking device in the embodiments shown, and specifically to execute: Figure 1 The electronic device can also execute the method performed by the database checking device in the database checking device, and implement the functions of the database checking device in the database checking device. The embodiments of the present application will not be repeated here.
[0138] receiving a database consistency checking request, wherein the database consistency checking request is a request for consistency checking of data in a plurality of target databases;
[0139] generating a data statistics file according to the database consistency checking request;
[0140] The data statistics file is sent to the machine where the target database is located, so that the machine where the target database is located performs data statistics according to the data statistics file;
[0141] The consistency of the target databases is checked according to the data statistics result returned by the machine where the target database is located, and a database consistency checking result is obtained.
[0142] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.
[0143] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system), and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the flow Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in one or more blocks.
[0144] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including instruction apparatus, which implements the flow Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in one or more blocks.
[0145] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide a process for implementing the flow Figure 1 one or more flows and / or blocks an apparatus that performs the functions specified in one or more blocks.
[0146] In one typical arrangement, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0147] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) having a common memory storage port. The memory is an example of computer readable media.
[0148] Computer readable media includes permanent and non-permanent, moveable and non- moveable media that can be implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disks (DVDs) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that is accessible to a computing device. According to the definition provided herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.
[0149] It is also important to note that the terms "comprises", "comprising", or other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0150] Those skilled in the art will appreciate that embodiments of the present application can be devised for a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer readable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.
[0151] The above merely provides an example of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application should be included in the scope of claims of the present application.
Claims
1. A database verification method, performed by a verification server, wherein, The method comprises: receiving a database consistency check request, wherein the database consistency check request is a request for consistency check of data in multiple target databases; generating a data statistics file according to the database consistency check request; sending the data statistics file to machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistics file; performing consistency check on the target databases according to data statistics results returned by the machines where the target databases are located, to obtain a database consistency check result; the data statistics file is a check strategy defined in advance at a business logic level, and the data statistics file comprises at least one of a dimension of data statistics and a manner of data statistics; the sending of the data statistics file to the machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistics file comprises: sending the data statistics file to machines where target databases under a same sub-database are located through an SCP remote command, so that the machines where the target databases under the same sub-database are located perform data statistics according to the data statistics file respectively; receiving data statistics results returned by the machines where the target databases under the same sub-database are located.
2. The method of claim 1, wherein, the generation of the data statistics file according to the database consistency check request comprises: determining IP addresses and check ranges of the target databases according to the database consistency check request; generating the data statistics file according to the IP addresses of the target databases and the check ranges.
3. The method of claim 2, wherein, the database consistency check request comprises a data center identifier, and the determination of the IP addresses of the target databases according to the database consistency check request comprises: determining a target data center and at least one set of sub-databases contained in the target data center according to the data center identifier, wherein the sub-databases are constructed based on a master-slave relationship between databases; obtaining IP addresses of all databases contained in each sub-database as the IP addresses of the target databases of the sub-databases.
4. The method of claim 3, wherein, each sub-database comprises a master database and a standby database, and the obtaining of the IP addresses of all databases contained in each sub-database as the IP addresses of the target databases of the sub-databases comprises: obtaining IP addresses of the master databases in the sub-databases; obtaining IP addresses of the standby databases in the sub-databases according to the IP addresses of the master databases in the sub-databases; obtaining IP addresses of the standby databases in the sub-databases according to the IP addresses of the master databases in the sub-databases; 5. The method of claim 2, wherein, obtaining the IP addresses of the master databases and the standby databases in the sub-databases as the IP addresses of the target databases of the sub-databases. the database consistency check request comprises IP addresses of at least one database, and the determination of the IP addresses of the target databases according to the database consistency check request comprises: determining sub-databases where the databases are located according to the IP addresses of the databases; 6. The method of claim 1, wherein, obtaining IP addresses of all databases in each sub-database as the IP addresses of the target databases of the sub-databases. the consistency check on the target databases according to the data statistics results returned by the machines where the target databases are located, to obtain a database consistency check result comprises: The data statistical results returned by the target databases under the same sub-library are compared with each other; If the comparison is consistent, a database consistency check result of passing the check is obtained; If the comparison is inconsistent, a database consistency check result of failing the check is obtained.
7. The method of claim 1, wherein, After the data statistical file is sent to the machines where the target databases are located, the method further comprises: receiving process log files returned by the target databases; storing the process log files and the database consistency check result into a preset check database.
8. The method of claim 1, wherein, After the consistency of the target databases is checked according to the data statistical results returned by the machines where the target databases are located, and a database consistency check result is obtained, the method further comprises: If the database consistency check result is a result of failing the check, process log files of the target databases are obtained; determining an abnormal target database and abnormal data according to the process log files of the target databases.
9. A database verification apparatus applied to a verification server, wherein, The apparatus comprises: a first receiving unit configured to receive a database consistency check request, wherein the database consistency check request is a request for checking the consistency of data in a plurality of target databases; a generating unit configured to generate a data statistical file according to the database consistency check request; a sending unit configured to send the data statistical file to the machines where the target databases are located, so that the machines where the target databases are located perform data statistics according to the data statistical file; a checking unit configured to check the consistency of the target databases according to data statistical results returned by the machines where the target databases are located, and obtain a database consistency check result; The data statistical file is a check strategy defined in advance at a business logic level, and the data statistical file comprises at least one of a dimension of data statistics and a manner of data statistics. The sending unit is specifically configured to: send the data statistical file to the machines where the target databases under the same sub-library are located through an SCP remote command, so that the machines where the target databases under the same sub-library are located perform data statistics according to the data statistical file respectively; receive data statistical results returned by the machines where the target databases under the same sub-library are located.
Citation Information
Patent Citations
Method and system for monitoring data consistency between plurality of databases
CN101625686A
Data verification method and data verification system based on database synchronization
CN111339200A