CN116266178A - Database verification method and device - Google Patents
Database verification method and device Download PDFInfo
- Publication number
- CN116266178A CN116266178A CN202111549739.4A CN202111549739A CN116266178A CN 116266178 A CN116266178 A CN 116266178A CN 202111549739 A CN202111549739 A CN 202111549739A CN 116266178 A CN116266178 A CN 116266178A
- Authority
- CN
- China
- Prior art keywords
- database
- target
- sub
- data
- verification
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/215—Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application discloses a database verification method and device, wherein the method is executed by a verification server and comprises the following steps: receiving a database consistency check request, wherein the database consistency check request refers to a request for carrying out consistency check on data in a plurality of target databases; generating a data statistics file according to the database consistency check request; transmitting the data statistics file to the machine where each target database is located, so that the machine where each target database is located carries out data statistics according to the data statistics file; and carrying out consistency verification on each target database according to the data statistical result returned by the machine where each target database is located, and obtaining a database consistency verification result. According to the method and the device, the automatic verification of the data consistency of the databases is realized, the verification efficiency and the flexibility are higher, the verification result can help related personnel to discover inconsistent data as soon as possible and solve the inconsistent data in time, and the influence on actual business is reduced.
Description
Technical Field
The present disclosure relates to the field of database technologies, and in particular, to a method and an apparatus for verifying a database.
Background
The application of databases is very wide today, most business systems have high safety and high reliability requirements on the databases, especially related scenes such as financial business, and the requirements on the safety of data in the databases are higher.
In order to ensure that data is not lost, the database is mainly deployed in a main-standby mode in the scene of the distributed database, and in the actual operation and maintenance work of the database, the reliability of the database can be improved and the safety of the data can be ensured to the greatest extent by ensuring the data consistency between the main-standby databases.
At present, the consistency check of the database is usually a physical-layer check, for example, each table data in the main database and the standby database is compared in a Checksum table mode, however, the mode is easy to cause larger influence on online transaction, and the online transaction cannot be usually performed on line or only in a service low peak period, so that the application scene is greatly limited, and the consistency check of the database is not efficient.
Disclosure of Invention
The embodiment of the application provides a database verification method and device, so as to improve the database consistency verification efficiency.
The embodiment of the application adopts the following technical scheme:
In a first aspect, an embodiment of the present application provides a database verification method, performed by a verification server, where the method includes:
receiving a database consistency check request, wherein the database consistency check request refers to a request for carrying out consistency check on data in a plurality of target databases;
generating a data statistics file according to the database consistency verification request;
the data statistics file is sent to the machine where each target database is located, so that the machine where each target database is located carries out data statistics according to the data statistics file;
and carrying out consistency verification on each target database according to the data statistical result returned by the machine where each target database is located, and obtaining a database consistency verification result.
Optionally, the receiving a database consistency check request includes:
verifying the database consistency verification request;
if the verification is passed, executing the step of generating a data statistics file according to the database consistency verification request;
if the verification is not passed, outputting prompt information.
Optionally, the generating the data statistics file according to the database consistency check request includes:
Determining the IP address and the verification range of the target database according to the database consistency verification request;
and generating the data statistics file according to the IP address of the target database and the verification range.
Optionally, the database consistency check request includes a data center identifier, and determining 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 identification, wherein the sub-databases are constructed based on a master-slave relationship between databases;
the IP addresses of all databases contained in each sub-database are obtained and used as the IP addresses of the target databases of each sub-database.
Optionally, each sub-database includes a primary database and a standby database, and the obtaining the IP addresses of all the databases included in each sub-database, as the IP addresses of the target databases of each sub-database, includes:
acquiring the IP address of a main database in each sub-database;
according to the IP address of the main database in each sub-database, the IP address of the standby database in each sub-database is obtained;
and taking the IP address of the main database and the IP address of the standby database in each sub-database as the IP address of the target database of each sub-database.
Optionally, the database consistency check request includes at least one IP address of the database, and determining the IP address of the target database according to the database consistency check request includes:
determining the sub-database where each database is located according to the IP address of each database;
and acquiring the IP addresses of all databases in each sub-database as the IP addresses of the target databases of each sub-database.
Optionally, the sending 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 includes:
sending the data statistics file to a machine where a target database under the same sub-database is located through an SCP remote command, so that the machine where the target database under the same sub-database is located respectively carries out data statistics according to the data statistics file;
and receiving a data statistical result returned by the machine where the target database is located under the same sub-database.
Optionally, the consistency check is performed on each target database according to the data statistics result returned by the machine where each target database is located, so as to obtain a database consistency check result:
Comparing the data statistics results returned by the target databases under the same sub-database with each other;
if the comparison is consistent, a database consistency check result passing the check is obtained;
and if the comparison is inconsistent, obtaining a database consistency check result which is not checked.
Optionally, after sending the data statistics file to the machine on which each target database resides, the method further comprises:
receiving a process log file returned by each target database;
and storing the consistency check result of the process log file and the database into a preset check database.
Optionally, after performing consistency verification 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 verification result, the method further includes:
if the database consistency check result is that the check is not passed, acquiring a process log file of each target database;
and determining an abnormal target database and abnormal data according to the process log files of each target database.
Optionally, the method further comprises:
providing a front page;
the receiving a database consistency check request includes:
And receiving the database consistency check request through the front-end page.
In a second aspect, an embodiment of the present application further provides a database verification device, which is applied to a verification server, where the device is configured to implement any one of the foregoing methods.
In a third aspect, embodiments of the present application further provide an electronic device, including:
a processor; and
a memory arranged to store computer executable instructions which, when executed, cause the processor to perform any of the methods described hereinbefore.
In a fourth aspect, embodiments of the present application also provide a computer-readable storage medium storing one or more programs that, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform any of the methods described above.
The above-mentioned at least one technical scheme that this application embodiment adopted can reach following beneficial effect: the database verification method can be executed by a verification server which is arranged independently, and when the database is verified, a database consistency verification request is received firstly, wherein the database consistency verification request refers to a request for carrying out consistency verification on data in a plurality of target databases; then generating a data statistics file according to the database consistency check request; then, the data statistics file is sent to the machine where each target database is located, so that the machine where each target database is located carries out data statistics according to the data statistics file; and finally, carrying out consistency verification on each target database according to the data statistical result returned by the machine where each target database is located, and obtaining a database consistency verification result. The database verification method can realize automatic verification of the data consistency of a plurality of databases, has higher verification efficiency and flexibility, and can help database management staff or business staff to find inconsistent data as soon as possible and solve the inconsistent data in time, thereby reducing the influence on actual business and ensuring high availability and high safety of the databases.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a schematic flow chart of a database verification method in an embodiment of the present application;
FIG. 2 is a schematic diagram of a database verification process according to an embodiment of the present application;
FIG. 3 is a schematic structural diagram of a database verification device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
For the purposes, technical solutions and advantages of the present application, the technical solutions of the present application will be clearly and completely described below with reference to specific embodiments of the present application and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The following describes in detail the technical solutions provided by the embodiments of the present application with reference to the accompanying drawings.
As shown in fig. 1, a flowchart of a database verification method in the embodiment of the present application is provided, where the method includes at least steps S110 to S140 as follows:
in step S110, a database consistency check request is received, where the database consistency check request refers to a request for consistency check of data in a plurality of target databases.
The database verification method can be executed by the independently deployed verification servers, namely, the database verification operation is uniformly executed by utilizing the servers which are independent of the database servers, and compared with the mode of directly carrying out data consistency verification on the database servers, the database verification method has the advantages that the invasion degree of the database servers is lower, occupied resources of the database servers are fewer, and the influence on actual business can be reduced.
When the database is verified, a database consistency verification request is received first, wherein the database consistency verification request refers to a request for carrying out consistency verification on data in a plurality of target databases, and specifically can be a data consistency verification request between the main databases and the standby databases.
The database consistency verification request can be actively triggered by a user, and is automatically triggered according to preset verification frequency, and particularly how to trigger, the database consistency verification request can be flexibly set by a person skilled in the art according to actual requirements, and the database consistency verification request is not particularly limited.
Step S120, generating a data statistics file according to the database consistency check request.
Considering that under the actual service scene, the situation that data are inconsistent between the main database and the standby database is less, if the database verification method of the physical layer is only adopted to verify the data in all database tables, the IO load required to be occupied will be very high, the time consumption is long, and when the database server is in the service peak period, the consistency verification operation of the physical layer cannot be executed at high frequency, so that the database consistency verification efficiency is low, and the real-time performance is poor.
Based on this, after receiving the database consistency verification request, the embodiment of the present application may generate a database statistics file according to a specific verification parameter carried in the request, where the database statistics file may be regarded as a verification policy of a service logic layer defined in advance, and may specifically include a dimension of data statistics, a statistical manner, and so on, for example, may count the number of data strips, the data size, the service status, and so on in each data table. Of course, how to configure the information contained in the database statistics file is specifically, and those skilled in the art can flexibly adjust the information according to actual service requirements, which is not specifically limited herein.
And step S130, the data statistics file is sent 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.
After the data statistics file is generated, the data statistics file is respectively sent to the machine where each target database is located, so that each target database can count data according to the statistics dimension, the statistics mode and the like contained in the data statistics file, and a data statistics result is obtained.
And step S140, carrying out consistency verification on each target database according to the data statistics results returned by the machine where each target database is located, and obtaining database consistency verification results.
And carrying out consistency check on the data of each database according to the data statistical result returned by the machine where each target database is located, so as to obtain the database consistency check result. For the data statistics results of each target database obtained based on the database statistics file, as long as the data statistics results accord with service logic, the consistency of service requirements can be ensured, and compared with a verification mode of a physical layer, the process has faster execution efficiency and basically has no influence on online service.
The database verification method can realize automatic verification of the data consistency of a plurality of databases, has higher verification efficiency and flexibility, and can help database management staff or business staff to find inconsistent data as soon as possible and solve the inconsistent data in time, thereby reducing the influence on actual business and ensuring high availability and high safety of the databases.
In one embodiment of the present application, the receiving a database consistency check request includes: verifying the database consistency verification request; if the verification is passed, executing the step of generating a data statistics file according to the database consistency verification request; if the verification is not passed, outputting prompt information.
In order to ensure the successful proceeding of the subsequent database verification process, after receiving the database consistency verification request triggered by the user, the embodiment of the application can also perform validity verification on the parameters in the database consistency verification request, for example, whether the format of the parameters carried in the request accords with the preset parameter format, whether the parameter type accords with the service requirement, and the like. If the validity verification is passed, the subsequent steps can be executed, and if the verification is not passed, the user can be reminded to reinitiate the database consistency verification request in a mode of outputting prompt information.
In one embodiment of the present application, the generating the data statistics file according to the database consistency check request includes: determining the IP address and the verification range of the target database according to the database consistency verification request; and generating the data statistics file according to the IP address of the target database and the verification range.
In the distributed database scenario, the number of databases is large, if the consistency check operation on all databases obviously cannot meet the actual service requirement, flexibility is poor, and time consumption is high, so that when the database check operation is executed, the embodiment of the application can determine which databases are executed with the consistency check operation according to the IP addresses carried in the database consistency check request, namely, determine the IP address list of the target database.
In addition, since the business under some business scenarios is usually performed without interruption, for example, the transaction business may generate transaction data at any moment, so that the database server is also in real-time operation, resulting in huge data volume generated by the database, and if the consistency check is performed on all the data, the problems of high time consumption, low efficiency and the like are also existed. Therefore, the embodiment of the application can determine whether to execute the consistency check operation on the data in the time range according to the time information carried in the database consistency check request, such as the transaction creation time, the transaction batch number and the like, namely, the check range is determined, and further, the efficiency of database consistency check and the real-time performance of the check can be improved through the multi-segmentation check operation.
Based on the determined IP address and the verification range of the target database, a corresponding data statistics file may be generated, i.e. it may be determined from the data statistics file what kind of statistics operation is performed on the data in which databases of which time range.
In one embodiment of the present application, the database consistency check request includes a data center identifier, and determining 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 identification, wherein the sub-databases are constructed based on a master-slave relationship between databases; the IP addresses of all databases contained in each sub-database are obtained and used as the IP addresses of the target databases of each sub-database.
As described above, in the distributed database scenario, the data center mainly adopts the primary-backup mode to deploy the databases, and one primary database and multiple backup databases may form a set of sub-databases, and data between the primary and backup databases in the set of sub-databases should be kept synchronous and consistent, so the consistency check in the embodiment of the present application may be regarded as an operation performed in the dimension of the sub-databases.
A plurality of sets of sub-libraries are usually deployed in one data center, so that the high availability of the whole service system is guaranteed. Based on the above, when the database consistency check request is triggered, the embodiment of the application can carry the data center identifier, so that consistency check can be performed on all databases under one data center. Specifically, the target data center and the sub-databases included in the target data center can be determined according to the data center identification, and then the IP addresses of all the databases included in each set of sub-databases are further obtained and used as the IP addresses of the target databases of each set of sub-databases respectively, so that the follow-up consistency check of the databases in each set of sub-databases is facilitated.
In one embodiment of the present application, each sub-database includes a primary database and a backup database, and the obtaining the IP addresses of all the databases included in each sub-database, as the IP addresses of the target databases of each sub-database, includes: acquiring the IP address of a main database in each sub-database; according to the IP address of the main database in each sub-database, the IP address of the standby database in each sub-database is obtained; and taking the IP address of the main database and the IP address of the standby database in each sub-database as the IP address of the target database of each sub-database.
When the IP addresses of all databases in each sub-database are acquired, the IP addresses of the main databases of the sub-databases can be determined first, then the IP addresses of the standby databases corresponding to the IP addresses of the main databases in each sub-database are acquired according to the IP addresses of the main databases, and then the IP addresses of the main databases and the IP addresses of the standby databases in each sub-database can be used as the IP addresses of the target databases of the sub-databases.
Of course, in addition to the above-mentioned obtaining manner, the person skilled in the art may also directly and uniformly obtain the IP addresses of all databases in each sub-database under the data center from the preset configuration information resource database, and specifically how to obtain the IP addresses, which can be flexibly set by the person skilled in the art according to actual needs, and is not limited herein.
In one embodiment of the present application, the database consistency check request includes at least one IP address of a database, and determining the IP address of the target database according to the database consistency check request includes: determining the sub-database where each database is located according to the IP address of each database; and acquiring the IP addresses of all databases in each sub-database as the IP addresses of the target databases of each sub-database.
Besides the consistency check can be performed on all databases in one data center, a user can also perform the consistency check operation on one or more specific databases, so that different check requirements of actual business scenes are met. For example, the database consistency check request may carry the IP addresses of one or more databases, and since the database consistency check is performed in the dimension of the databases, the database where each database is located may be determined according to the IP address of each database, and then the IP addresses of other databases in each database except the database may be obtained, or the IP addresses of all databases may be directly obtained as the IP address of the target database of each database.
For example, assuming that the database consistency check request carries the IP address of the database A1, it may be determined that the database A1 is located in the database 01 according to the IP address of the database A1, and then the IP addresses of other databases in the database 01, including, for example, the database A2, the database A3 and the database A4, may be further obtained, and then the IP address of the database A1, the IP address of the database A2, the IP address of the database A3 and the IP address of the database A4 are used as the IP address of the target database of the database 01, so as to facilitate the subsequent consistency check of the data in the database A1, the database A2, the database A3 and the database A4.
In one embodiment of the present application, the 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 includes: sending the data statistics file to a machine where a target database under the same sub-database is located through an SCP remote command, so that the machine where the target database under the same sub-database is located respectively carries out data statistics according to the data statistics file; and receiving a data statistical result returned by the machine where the target database is located under the same sub-database.
When the data statistics file is sent to the machine where the target database is located, the embodiment of the application can be realized by utilizing SCP (Secure copy) remote command, wherein the SCP remote command is a command for remotely copying the file, and data transmission between the local and the remote can be realized. Of course, those skilled in the art may also use other communication commands to perform data transmission according to the actual situation, which is not illustrated herein.
According to the embodiment of the application, the SCP remote command can be used for sending the data statistics file to the machines where all the target databases under the same sub-database are located, so that the machines where the target databases in the same sub-database are located can respectively carry out data statistics according to the data statistics file, and further the data statistics results of all the target databases under the same sub-database can be obtained.
For the above embodiments, it should be noted that, in an actual application scenario, the verification requirements of the users may be different for different data centers or different sub-libraries. For example, some sub-banks may only check the data of the last 2 days, while other sub-banks need to check the data of the last 3 days, etc., which results in that for different sub-banks, the generated data statistics files may include a plurality of data statistics files x1, x2, x3, etc., when the data statistics files are issued, the data statistics files x1 may be issued to all the databases in the sub-bank 01, the data statistics files x2 may be issued to all the databases in the sub-bank 02, the data statistics files x3 may be issued to all the databases in the sub-bank 03, etc., so that the databases in the sub-banks perform corresponding data statistics operations according to the received data statistics files, respectively.
In one embodiment of the present application, the consistency check is performed on each target database according to the data statistics result returned by the machine where each target database is located, so as to obtain a database consistency check result: comparing the data statistics results returned by the target databases under the same sub-database with each other; if the comparison is consistent, a database consistency check result passing the check is obtained; and if the comparison is inconsistent, obtaining a database consistency check result which is not checked.
After the data statistics results returned by the machine where each target database is located are obtained, the data statistics results returned by each target database under the same sub-database can be compared with each other in the dimension of the sub-database, if the comparison is consistent, the consistency check is proved to pass, if the comparison is inconsistent, the consistency check is not proved to pass, and abnormal data needs to be further determined so as to avoid affecting the accuracy of service processing.
For the sake of understanding the embodiments of the present application, as shown in the following table 1, an example of a data statistics result is provided, and it can be seen from table 1 that in two statistical dimensions of total number of data tables and size of data tables, the statistics results of each data table in the main database A1 and the standby databases A2, A3 and A4 are the same, so that the consistency check result of all databases in the database 01 can be regarded as verification passing.
TABLE 1
In one embodiment of the present application, after sending the data statistics file to the machine on which each target database resides, the method further comprises: receiving a process log file returned by each target database; and storing the consistency check result of the process log file and the database to a preset check database.
In order to facilitate the management and anomaly investigation of the data statistics process of each target database, after the data statistics file is sent to the machine where each target database is located, the embodiment of the present application may further obtain a process log file returned by each target database, where the process log file may be understood as a file recording the whole process of executing the statistics operation by each target database according to the received data statistics file.
And storing the process log files returned by each target database and the database consistency check results into a preset check database together, and taking the process log files and the database consistency check results as the basis of subsequent reference. In addition, in order to save storage space, the retention time of the process log file and the database consistency check result can be flexibly set according to practical situations, for example, the retention time can be set to be 5 days, and the process log file and the database consistency check result generated before 5 days are cleaned after 5 days, so that the storage space is saved by timely cleaning the expired file.
In one embodiment of the present application, after performing consistency verification 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 verification result, the method further includes: if the database consistency check result is that the check is not passed, acquiring a process log file of each target database; and determining an abnormal target database and abnormal data according to the process log files of each target database.
When the obtained database consistency check result is a result that the check fails, the data statistics result between one or more databases in the sub-database is not completely consistent, which may be that the data synchronization is problematic on one hand, and the data statistics is problematic on the other hand.
In order to locate the problem in time, the process log files of each target database under the sub-database can be obtained, and the data statistics process of each target database can be restored through the process log files, so that the reasons for the occurrence of the abnormality can be rapidly determined. Of course, if the process log file finds that the data statistics process of each target database has no problem, it can be considered that the data synchronization has a problem, and checking operations such as synchronization relation can be performed on the abnormal target databases.
For example, if the total number of data tables obtained by statistics of the data table a12 in the main 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 obtained by statistics 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, so that it can be further checked whether the standby database A2 has a problem in the synchronization stage or the statistics stage, so as to perform fault handling on the standby database A2 in time.
In one embodiment of the present application, the method further comprises: providing a front page; the receiving a database consistency check request includes: and receiving the database consistency check request through the front-end page.
In order to realize visualization of the database verification process, the embodiment of the application also provides a front-end page, and on the front-end page, a user can trigger a database consistency verification request by inputting or selecting a verification parameter.
In addition, the database consistency check result can be displayed on the front page, the database consistency check result can specifically comprise a database consistency check passing result or a database consistency check failing result, and the target database with failed database consistency check and the specific inconsistent statistical content can be specifically displayed for the database consistency check failing result, so that a user can intuitively and timely check the database consistency check result, and the use experience of the user is improved.
In order to facilitate understanding of embodiments of the present application, as shown in fig. 2, a schematic diagram of a database verification flow in an embodiment of the present application is provided. Firstly, receiving a database consistency check request, then carrying out validity verification on check parameters in the database consistency check request, outputting prompt information if the validity verification is not passed, determining whether the check parameters carried in the database consistency check request are IDC identifications or IP addresses if the check parameters are the IDC identifications, determining the IP addresses of all main databases under the data center according to the IDC identifications, acquiring the IP addresses of all standby databases in the sub-databases where each main database is located according to the IP addresses of the main databases, and taking the IP addresses of the main databases and the IP addresses of all standby databases in each sub-database as the IP addresses of target databases of each sub-database. If the verification parameters carried in the database consistency verification request are IP addresses, the IP addresses of all other databases in the database where the database is located are directly obtained, and the IP addresses of the database and the IP addresses of all other databases are used as the IP addresses of the target databases of the database.
After the IP address of each target database is acquired, a data statistics file is required to be generated by combining the verification range carried in the database consistency verification request, and then the database statistics file is issued to the machine where each target database is located through an SCP remote command, so that the machine where each target database is located can carry out data statistics according to the corresponding data statistics file, and a data statistics result and a process log file are obtained.
And according to the data statistics results returned by the machine where each target database is located, checking each other in the dimension of the sub-database, outputting a database consistency check result, and storing the database consistency check result and the process log file into a preset check database so as to facilitate subsequent checking.
The database verification flow is based on the comparison logic of the service requirements, so that the automatic verification of the data consistency of a plurality of databases is realized, the consistency verification result is displayed to the user, and the user experience is improved while the basic verification function is met. In addition, the method and the device can support setting of target databases and checking ranges to be checked, are irrelevant to the quantity of the databases, have high operation flexibility, can check multiple sets of sub-databases in multiple data centers simultaneously, and have higher checking efficiency.
The embodiment of the application also provides a database verification device 300, which is applied to a verification server, as shown in the figure, and provides a schematic structural diagram of the database verification device in the embodiment of the application, where the device 300 includes: a first receiving unit 310, a generating unit 320, a transmitting unit 330 and a checking unit 340, wherein: a first receiving unit 310, a generating unit 320, a transmitting unit 330 and a checking unit 340, wherein:
a first receiving unit 310, configured to receive a database consistency check request, where the database consistency check request refers to a request for performing consistency check on data in a plurality of target databases;
a generating unit 320, configured to generate a data statistics file according to the database consistency check request;
a sending unit 330, configured to 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;
and the verification unit 340 is configured to perform consistency verification on each target database according to the data statistics result returned by the machine where each target database is located, so as to obtain a database consistency verification result.
In one embodiment of the present application, the first receiving unit 310 is specifically configured to: verifying the database consistency verification request; if the verification is passed, executing the step of generating a data statistics file according to the database consistency verification request; if the verification is not passed, outputting prompt information.
In one embodiment of the present application, the generating unit 320 is specifically configured to: determining the IP address and the verification range of the target database according to the database consistency verification request; and generating the data statistics file according to the IP address of the target database and the verification range.
In one embodiment of the present application, the generating unit 320 is specifically configured to: determining a target data center and at least one set of sub-databases contained in the target data center according to the data center identification, wherein the sub-databases are constructed based on a master-slave relationship between databases; the IP addresses of all databases contained in each sub-database are obtained and used as the IP addresses of the target databases of each sub-database.
In one embodiment of the present application, each sub-database includes a primary database and a standby database, and the generating unit 320 is specifically configured to: acquiring the IP address of a main database in each sub-database; according to the IP address of the main database in each sub-database, the IP address of the standby database in each sub-database is obtained; and taking the IP address of the main database and the IP address of the standby database in each sub-database as the IP address of the target database of each sub-database.
In one embodiment of the present application, the database consistency check request includes at least one IP address of the database, and the generating unit 320 is specifically configured to: determining the sub-database where each database is located according to the IP address of each database; and acquiring the IP addresses of all databases in each sub-database as the IP addresses of the target databases of each sub-database.
In one embodiment of the present application, the sending unit 330 is specifically configured to: sending the data statistics file to a machine where a target database under the same sub-database is located through an SCP remote command, so that the machine where the target database under the same sub-database is located respectively carries out data statistics according to the data statistics file; and receiving a data statistical result returned by the machine where the target database is located under the same sub-database.
In one embodiment of the present application, the verification unit 340 is specifically configured to: comparing the data statistics results returned by the target databases under the same sub-database with each other; if the comparison is consistent, a database consistency check result passing the check is obtained; and if the comparison is inconsistent, obtaining a database consistency check result which is not checked.
In one embodiment of the present application, the apparatus further comprises: the second receiving unit is used for receiving the process log files returned by each target database; and the storage unit is used for storing the consistency check result of the process log file and the database into a preset check database.
In one embodiment of the present application, the apparatus further comprises: the acquisition unit is used for acquiring the process log files of each target database if the database consistency check result is that the check is not passed; and the determining unit is used for determining the abnormal target database and abnormal data according to the process log files of the target databases.
In one embodiment of the present application, the apparatus further comprises: the providing unit is used for providing a front-end page; the first receiving unit 310 is specifically configured to: and receiving the database consistency check request through the front-end page.
It can be understood that the database verification device can implement each step of the method for verifying the data of the database executed by the verification server provided in the foregoing embodiment, and the relevant explanation about the method for verifying the data of the database is applicable to the database verification device, which is not repeated herein.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 4, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 4, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form a database verification device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
receiving a database consistency check request, wherein the database consistency check request refers to a request for carrying out consistency check on data in a plurality of target databases;
Generating a data statistics file according to the database consistency verification request;
the data statistics file is sent to the machine where each target database is located, so that the machine where each target database is located carries out data statistics according to the data statistics file;
and carrying out consistency verification on each target database according to the data statistical result returned by the machine where each target database is located, and obtaining a database consistency verification result.
The method performed by the database verification device disclosed in the embodiment shown in fig. 1 of the present application may be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
The electronic device may further execute the method executed by the database verification device in fig. 1, and implement the function of the database verification device in the embodiment shown in fig. 1, which is not described herein again.
The embodiments of the present application also provide a computer-readable storage medium storing one or more programs, where the one or more programs include instructions, which when executed by an electronic device that includes a plurality of application programs, enable the electronic device to perform a method performed by a database verification apparatus in the embodiment shown in fig. 1, and specifically are configured to perform:
receiving a database consistency check request, wherein the database consistency check request refers to a request for carrying out consistency check on data in a plurality of target databases;
generating a data statistics file according to the database consistency verification request;
the data statistics file is sent to the machine where each target database is located, so that the machine where each target database is located carries out data statistics according to the data statistics file;
and carrying out consistency verification on each target database according to the data statistical result returned by the machine where each target database is located, and obtaining a database consistency verification result.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer 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 Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation 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 may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.
Claims (10)
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 refers to a request for carrying out consistency check on data in a plurality of target databases;
generating a data statistics file according to the database consistency verification request;
The data statistics file is sent to the machine where each target database is located, so that the machine where each target database is located carries out data statistics according to the data statistics file;
and carrying out consistency verification on each target database according to the data statistical result returned by the machine where each target database is located, and obtaining a database consistency verification result.
2. The method of claim 1, wherein the generating a data statistics file from the database consistency check request comprises:
determining the IP address and the verification range of the target database according to the database consistency verification request;
and generating the data statistics file according to the IP address of the target database and the verification range.
3. The method of claim 2, wherein the database consistency check request includes a data center identifier, and wherein determining 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 identification, wherein the sub-databases are constructed based on a master-slave relationship between databases;
the IP addresses of all databases contained in each sub-database are obtained and used as the IP addresses of the target databases of each sub-database.
4. The method as claimed in claim 3, wherein each sub-bank includes a main database and a standby database, and the obtaining the IP addresses of all the databases included in each sub-bank as the IP addresses of the target databases of each sub-bank includes:
acquiring the IP address of a main database in each sub-database;
according to the IP address of the main database in each sub-database, the IP address of the standby database in each sub-database is obtained;
and taking the IP address of the main database and the IP address of the standby database in each sub-database as the IP address of the target database of each sub-database.
5. The method of claim 2, wherein the database consistency check request includes at least one IP address of a database, and the determining the IP address of the target database according to the database consistency check request includes:
determining the sub-database where each database is located according to the IP address of each database;
and acquiring the IP addresses of all databases in each sub-database as the IP addresses of the target databases of each sub-database.
6. The method of claim 1, wherein said sending the data statistics file to the machine on which each target database resides, such that the machine on which each target database resides performs data statistics based on the data statistics file, comprises:
Sending the data statistics file to a machine where a target database under the same sub-database is located through an SCP remote command, so that the machine where the target database under the same sub-database is located respectively carries out data statistics according to the data statistics file;
and receiving a data statistical result returned by the machine where the target database is located under the same sub-database.
7. The method of claim 6, wherein the consistency check is performed on each target database according to the data statistics returned by the machine where each target database is located, so as to obtain a database consistency check result:
comparing the data statistics results returned by the target databases under the same sub-database with each other;
if the comparison is consistent, a database consistency check result passing the check is obtained;
and if the comparison is inconsistent, obtaining a database consistency check result which is not checked.
8. The method of claim 1, wherein after sending the data statistics file to the machine on which each target database resides, the method further comprises:
receiving a process log file returned by each target database;
and storing the consistency check result of the process log file and the database into a preset check database.
9. The method of claim 1, wherein after performing a consistency check on each target database according to the data statistics returned by the machine in which each target database is located, obtaining a database consistency check result, the method further comprises:
if the database consistency check result is that the check is not passed, acquiring a process log file of each target database;
and determining an abnormal target database and abnormal data according to the process log files of each target database.
10. Database verification apparatus for use in a verification server, wherein the apparatus is arranged to implement the method of any one of claims 1 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111549739.4A CN116266178A (en) | 2021-12-17 | 2021-12-17 | Database verification method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111549739.4A CN116266178A (en) | 2021-12-17 | 2021-12-17 | Database verification method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116266178A true CN116266178A (en) | 2023-06-20 |
Family
ID=86743526
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111549739.4A Pending CN116266178A (en) | 2021-12-17 | 2021-12-17 | Database verification method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116266178A (en) |
-
2021
- 2021-12-17 CN CN202111549739.4A patent/CN116266178A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110825420A (en) | Configuration parameter updating method, device, equipment and storage medium for distributed cluster | |
CN107273195B (en) | Big data batch processing method and device and computer system | |
CN109308227B (en) | Fault detection control method and related equipment | |
CN111708787A (en) | Multi-center service data management system | |
CN113608692A (en) | Method, system, equipment and medium for verifying data consistency of storage system | |
CN112835885B (en) | Processing method, device and system for distributed form storage | |
CN115756955A (en) | Data backup and data recovery method and device and computer equipment | |
CN110647463A (en) | Method and device for restoring test breakpoint and electronic equipment | |
CN111078468A (en) | Service rollback method and device under micro-service architecture | |
CN117290557A (en) | Data loading method, related device, equipment and readable storage medium | |
CN114676030A (en) | System test method, device, proxy server equipment and storage medium | |
CN114691473A (en) | Test method, test device and electronic equipment | |
CN113282347B (en) | Plug-in operation method, device, equipment and storage medium | |
CN116266178A (en) | Database verification method and device | |
CN113596195B (en) | Public IP address management method, device, main node and storage medium | |
CN114996151A (en) | Interface testing method and device, electronic equipment and readable storage medium | |
CN113568781A (en) | Database error processing method and device and database cluster access system | |
CN110489208B (en) | Virtual machine configuration parameter checking method, system, computer equipment and storage medium | |
CN115686951A (en) | Fault processing method and device for database server | |
CN114510460A (en) | Database system capacity expansion method and device, electronic equipment and storage medium | |
CN107919980B (en) | Evaluation method and device for clustered system | |
CN114625595B (en) | Method, device and system for rechecking dynamic configuration information of service system | |
CN112118294B (en) | Request processing method, device and medium based on server cluster | |
CN113760519B (en) | Distributed transaction processing method, device, system and electronic equipment | |
CN117453153B (en) | File storage method, device, terminal and medium based on flush rule |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |