Verification method, device and equipment with updatable character set

By determining a standby database in the database cluster that has not performed data updates, creating a replicated table or a new database to verify data consistency, the business interruption problem caused by character set changes in the prior art is solved, and uninterrupted data consistency verification is achieved.

CN120234331APending Publication Date: 2025-07-01NETSUNION CLEARING CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311865784.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

When changing the database character set, the prior art needs to pause the current service to verify data consistency, resulting in a long service interruption time.

Method used

In the database cluster, determine a standby database that has not been updated based on the current business data as the target database. By creating a replica table or a new database in the target database, verify whether the character set of the original data table can be updated to the target character set to ensure data consistency.

Benefits of technology

It realizes that when the current service is not interrupted, the data consistency before and after the database character set changes is verified, avoids business interruption and improves operational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234331A_ABST
    Figure CN120234331A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a character set updatable verification method, device and equipment, and relates to the technical field of databases, data verification and the like. The method comprises the steps that a target database is determined in a database cluster; wherein the original character set of the target database is to be updated as the target character set, and the target database is a standby database which does not execute data updating according to the current service; aiming at each original data table in the target database, determining a target data table according to the target character set and the original data table, and judging whether the character set of the original data table can be updated to the target character set or not according to the target data table; wherein the character set of the target data table is a target character set; when it is determined that the character set of each original data table can be updated to the target character set, it is determined that the original character set of the target database can be updated to the target character set. The method is used for avoiding current service interruption and verifying data consistency before and after character set change.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to technical fields such as databases and data verification, and in particular, to a verification method, apparatus, and device with an updatable character set. Background Art

[0002] The character set of a database refers to the encoding method used to represent characters in a computer. Currently, it is usually necessary to change the character set of the database to meet the business requirements of writing emojis and rare Chinese characters into the database according to the current business.

[0003] During the process of changing the character set of the database, communication needs to verify the data consistency before and after the character set change. In the related art, the methods for verifying the data consistency before and after the character set change include: first suspending the current business, and then verifying the data consistency before and after the character set change.

[0004] In the above process, suspending the current business to verify the data consistency before and after the character set change results in a relatively long interruption time of the current business. Summary of the Invention

[0005] The embodiments of the present application provide a verification method, apparatus, and device with an updatable character set, which are used to avoid interruption of the current business and achieve verification of the data consistency before and after the character set change.

[0006] In a first aspect, the embodiments of the present application provide a verification method with an updatable character set, including:

[0007] Determine a target database in the database cluster; wherein, the original character set of the target database is to be updated to a target character set, and the target database is a standby database that has not performed data update according to the current business;

[0008] For each original data table in the target database, determine a target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set;

[0009] When it is determined that the character sets of all the original data tables can be updated to the target character set, determine that the original character set of the target database can be updated to the target character set.

[0010] In a possible implementation manner, determining a target database in the database cluster includes:

[0011] Obtain the topology structure of the database cluster;

[0012] According to the topology structure, determine at least one candidate database in the database cluster;

[0013] Determine a standby database in the at least one candidate database where a high-availability HA service is not deployed;

[0014] Determine the standby database that is selected by the selection input operation and where a high-availability HA service is not deployed as the target database.

[0015] In a possible implementation manner, determining at least one candidate database in the database cluster according to the topology structure includes:

[0016] Obtain the read-write status of each standby database in the database cluster according to the topology structure;

[0017] Determine the standby database with a read-only status as the at least one candidate database.

[0018] In a possible implementation manner, determining a target data table according to the target character set and the original data table includes:

[0019] Control the disconnection of the link between the target database and the primary database corresponding to the target database;

[0020] Judge whether the target character set is compatible with the original character set;

[0021] If it is compatible, create a replication table corresponding to the original data table, update the character set of the replication table to the target character set, and determine the replication table with the updated character set as the target data table;

[0022] If it is not compatible, determine the data table corresponding to the original data table in a pre-created new database as the target data table; wherein, the character set of the new database is the target character set.

[0023] In a possible implementation manner, obtaining the new database includes:

[0024] Create a database instance with the target character set;

[0025] Import each original data table into the database instance;

[0026] Establish a link between the database instance and the database management device to obtain the new database.

[0027] In a possible implementation manner, judging whether the character set of the original data table can be updated to the target character set according to the target data table includes:

[0028] Determine whether the first Structured Query Language (SQL) file of the original data table and the second SQL file of the target data table are the same;

[0029] If they are the same, obtain the reference data table corresponding to the original data table from the primary database corresponding to the target database. When it is determined that the table contents of the reference data table and the target data table are the same, determine that the character set of the original data table can be updated to the target character set.

[0030] In a possible implementation manner, determining that the table contents of the reference data table and the target data table are the same includes:

[0031] For each primary key of the reference data table, determine whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table. If the first row of data and the second row of data corresponding to the primary key are the same, determine that the row data corresponding to the primary key is the same;

[0032] If the row data of each primary key is the same, determine that the table contents of the reference data table and the target data table are the same.

[0033] In a possible implementation manner, determining whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table includes:

[0034] When the first row of data and the second row of data are different, determine whether the update time of the first row of data is later than the obtained time of the target data table;

[0035] If the update time is later than the obtained time, determine that the first row of data and the second row of data are the same.

[0036] In a second aspect, an embodiment of the present application provides a verification device for updatable character sets, including:

[0037] A determination module, configured to determine a target database in a database cluster; wherein, the original character set of the target database is to be updated to a target character set, and the target database is a standby database that has not updated data according to the current service;

[0038] The determination module is further configured to, for each original data table in the target database, determine a target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set;

[0039] The determining module is further configured to determine that the original character set of the target database can be updated to the target character set when it is determined that the character sets of the original data tables can all be updated to the target character set.

[0040] In a possible implementation manner, the determining module is specifically configured to:

[0041] Obtain the topology structure of the database cluster;

[0042] According to the topology structure, determine at least one candidate database in the database cluster;

[0043] Determine a standby database in the at least one candidate database that does not deploy a high-availability (HA) service;

[0044] Determine the standby database that is selected by the selection input operation and does not deploy a high-availability (HA) service as the target database.

[0045] In a possible implementation manner, the determining module is specifically configured to:

[0046] According to the topology structure, obtain the read-write status of each standby database in the database cluster;

[0047] Determine the standby database with a read-only status as the at least one candidate database.

[0048] In a possible implementation manner, the determining module is specifically configured to:

[0049] Control the disconnection of the link between the target database and the primary database corresponding to the target database;

[0050] Judge whether the target character set is compatible with the original character set;

[0051] If it is compatible, create a replication table corresponding to the original data table, update the character set of the replication table to the target character set, and determine the replication table with the updated character set as the target data table;

[0052] If it is not compatible, determine the data table corresponding to the original data table in a pre-created new database as the target data table; wherein, the character set of the new database is the target character set.

[0053] In a possible implementation manner, the determining module is specifically configured to:

[0054] Create a database instance with the target character set;

[0055] Import the original data tables into the database instance;

[0056] Establish a link between the database instance and the database management device to obtain the new database.

[0057] In a possible implementation, the determining module is specifically configured to:

[0058] Determine whether the first Structured Query Language (SQL) file of the original data table is the same as the second SQL file of the target data table;

[0059] If they are the same, obtain the reference data table corresponding to the original data table from the main database corresponding to the target database. When it is determined that the table contents of the reference data table and the target data table are the same, determine that the character set of the original data table can be updated to the target character set.

[0060] In a possible implementation, the determining module is specifically configured to:

[0061] For each primary key of the reference data table, determine whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table. If the first row of data and the second row of data corresponding to the primary key are the same, determine that the row data corresponding to the primary key is the same;

[0062] If the row data of each primary key is the same, determine that the table contents of the reference data table and the target data table are the same.

[0063] In a possible implementation, the determining module is specifically configured to:

[0064] When the first row of data and the second row of data are different, determine whether the update time of the first row of data is later than the obtained time of the target data table;

[0065] If the update time is later than the obtained time, determine that the first row of data and the second row of data are the same.

[0066] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor, and a transceiver;

[0067] Wherein, the memory stores computer program instructions;

[0068] The processor executes the computer program instructions stored in the memory to implement the method according to any one of the first aspect.

[0069] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of the first aspect.

[0070] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program which, when executed by a processor, implements the method according to any one of the first aspect.

[0071] An embodiment of the present application provides a verification method, device and equipment for an updatable character set. In this method, a target database is determined in a database cluster. The target database is a standby database that has not updated data according to the current service. For each original data table in the target database, a target data table is determined according to the target character set and the original data table, and whether the character set of the original data table can be updated to the target character set is judged according to the target data table. When it is determined that the character sets of all original data tables can be updated to the target character set, it is determined that the original character set of the target database can be updated to the target character set, realizing the verification of data consistency before and after the character set change of the target database without interrupting the current service. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] In order to more clearly illustrate the technical solutions in the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0073] Figure 1 is a schematic diagram of an application scenario provided by an embodiment of the present application;

[0074] Figure 2 is one of the schematic structural diagrams of the verification method for an updatable character set provided by an embodiment of the present application;

[0075] Figure 3 is the second of the schematic structural diagrams of the verification method for an updatable character set provided by an embodiment of the present application;

[0076] Figure 4 is a schematic flowchart of determining a target data table provided by an embodiment of the present application;

[0077] Figure 5 is a schematic structural diagram of the verification device for an updatable character set provided by an embodiment of the present application;

[0078] Figure 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

[0079] Through the above drawings, the clear embodiments of the present application have been shown, and there will be more detailed descriptions later. These drawings and text descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0080] Exemplary embodiments will be described in detail herein, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0081] It should be noted that in this document, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article, or device. Without further limitation, an element defined by the phrase "including one..." does not exclude the presence of additional identical elements in the process, method, article, or device including that element.

[0082] First, relevant terms related to the present application will be described.

[0083] Latin1 (or ISO-8859-1) is a character set that uses 1 byte to represent a character.

[0084] UTF8 (or UTF8MB3) is a character set that uses 1 to 3 bytes to represent a character.

[0085] UTF8MB3 is a character set that uses 1 to 4 bytes to represent a character, and utf8mb4 is compatible with utf8mb3.

[0086] The primary database is used to handle read and write operations corresponding to the business.

[0087] The standby database serves as a backup of the primary database and is used to provide data recovery and disaster recovery capabilities in case of a primary database failure.

[0088] Data synchronization between the primary database and the corresponding standby database is performed through asynchronous replication technology.

[0089] Data synchronization between primary databases is performed through synchronous replication technology.

[0090] During the process of changing the database character set, it is usually necessary to verify the data consistency before and after the character set change. In the related art, the methods for verifying the data consistency before and after the character set change include: first suspending the current business, and then verifying the data consistency before and after the character set change. In the related art, suspending the current business to verify the data consistency before and after the character set change results in a relatively long business interruption time.

[0091] To avoid interrupting the current business, the present application provides a verification method for an updatable character set. In this method, first determine the target database, where the target database is a standby database that has not performed data updates according to the current business, and then verify the data consistency before and after the character set change of the target database, so as to achieve the purpose of verifying the data consistency before and after the character set change of the database without interrupting the current business.

[0092] Next, in combination with Figure 1 , the application scenario of the verification method for an updatable character set provided by the present application will be described.

[0093] Figure 1 is a schematic diagram of the application scenario provided by an embodiment of the present application. As Figure 1 shown, the database cluster includes: database sub-clusters corresponding to multiple computer rooms. The multiple computer rooms include a main computer room and at least one non-main computer room. Figure 1 is described by taking 1 main computer room and 2 non-main computer rooms as an example.

[0094] Each database sub-cluster includes a primary database and at least one standby database. Figure 1 is described by taking 2 standby databases included in each database sub-cluster as an example. At least one of the standby databases includes a standby database deployed with a Highly Available (HA) service.

[0095] The primary database in the main computer room is the database that performs read and write operations according to the current business.

[0096] The primary database in the non-main computer room is the primary database that performs data updates according to the data synchronization of the primary database in the main computer room.

[0097] In the database cluster, data synchronization is performed between the primary databases through synchronous replication technology to ensure the data consistency between the primary databases.

[0098] For example, data synchronization is performed between primary database A and primary database B through synchronous replication technology, and data synchronization is performed between primary database B and primary database C through synchronous replication technology.

[0099] In the database sub - cluster, data synchronization is performed between the primary database and the standby database through asynchronous replication technology to ensure data consistency between the primary database and the standby database.

[0100] For example, data synchronization is performed between primary database A and standby databases A1 and A2 through asynchronous replication technology, between primary database B and standby databases B1 and B2 through asynchronous replication technology, and between primary database C and standby databases C1 and C2 through asynchronous replication technology.

[0101] HA services can be deployed in the standby database. The deployed HA services are used to enable the standby database to promptly switch to the primary database in the event of an exception in the corresponding primary database. For example, HA services are deployed in standby database B1, and in the event of an exception in primary database B, standby database B1 can promptly switch to the primary database.

[0102] The links between the standby databases without deployed HA services and the corresponding primary databases can be disconnected. For example, the link between standby database A2 and primary database A can be disconnected, the link between standby database B2 and primary database B can be disconnected, and the link between standby database C2 and primary database C can be disconnected.

[0103] The standby database without deployed HA services can serve as the target database in this application for verifying data consistency before and after character set change.

[0104] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above - mentioned technical problems. These several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of this application in conjunction with the accompanying drawings.

[0105] Figure 2 is one of the structural schematic diagrams of the character - set updatable verification method provided by the embodiments of this application. As Figure 2 shown, the method includes:

[0106] S201. Determine the target database in the database cluster; wherein, the original character set of the target database is to be updated to the target character set, and the target database is a standby database that has not performed data updates according to the current business.

[0107] Optionally, the execution subject of the character - set updatable verification method provided by this application can be an electronic device or a character - set updatable verification device set on the electronic device, and this device can be implemented through the combination of software and / or hardware. The electronic device can communicate with each database in the database cluster.

[0108] The original character set can be Latin1 or UTF8.

[0109] The target character set can be UTF8 or UTF8MB4.

[0110] The original character set is different from the target character set.

[0111] For example, the original character set is Latin1, and the target character set is UTF8 or UTF8MB4.

[0112] For example, the original character set is UTF8, and the target character set is UTF8MB4.

[0113] The target database can be Figure 1 Standby databases A2, B2 or C2 in

[0114] S202. For each original data table in the target database, determine the target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set.

[0115] When the data in the target data table is consistent with the data in the original data table, it is determined that the character set of the original data table can be updated to the target character set.

[0116] The data consistency between the target data table and the original data table includes:

[0117] The Structured Query Language (SQL) file of the target data table is the same as the SQL file of the original data table;

[0118] The table content of the target data table is the same as the table content of the original data table.

[0119] The table content is the table data queried according to the primary key.

[0120] When the data in the target data table is inconsistent with the data in the original data table, it is determined that the character set of the original data table cannot be updated to the target character set.

[0121] S203. When it is determined that the character sets of all original data tables can be updated to the target character set, it is determined that the original character set of the target database can be updated to the target character set.

[0122] Optionally, when it is determined that the original character set of the target database can be updated to the target character set, a reminder message is displayed to prompt that the original character set can be updated to the target character set.

[0123] In the character set updateable verification method provided by the embodiments of the present application, a target database is determined in a database cluster. The target database is a standby database that has not updated data according to the current business. For each original data table in the target database, a target data table is determined according to the target character set and the original data table, and whether the character set of the original data table can be updated to the target character set is judged according to the target data table. When it is determined that the character sets of all the original data tables can be updated to the target character set, it is determined that the original character set of the target database can be updated to the target character set, so as to verify the data consistency before and after the character set change of the target database without interrupting the current business, and avoid interrupting the current business.

[0124] Based on the above embodiments, the following will combine Figure 3 to describe in detail the character set updateable verification method provided by the embodiments of the present application.

[0125] Figure 3 is the second structural schematic diagram of the character set updateable verification method provided by the embodiments of the present application. As Figure 3 shown, the method includes:

[0126] S301. Obtain the topology structure of the database cluster.

[0127] According to the address information (IP) of the master database in the main computer room, in a preset tool, execute the command pt-slave-findIP to obtain the topology structure of the database cluster. The preset tool is a tool developed by a crawler (python) and Django.

[0128] S302. Determine at least one candidate database in the database cluster according to the topology structure.

[0129] Optionally, S302 can be implemented in the following manner 11, manner 12 or manner 13.

[0130] Manner 11. Obtain the read-write status of each standby database in the database cluster according to the topology structure;

[0131] Determine the standby databases with the read-write status of read-only as at least one candidate database.

[0132] Optionally, each standby database in the database cluster can be all the standby databases in the main computer room and all the standby databases in the non-main computer room, or all the standby databases in the non-main computer room.

[0133] For example, in Figure 1On the basis that all standby databases in the database cluster are all standby databases in the main computer room and all standby databases in non-main computer rooms, each standby database in the database cluster is standby databases A1, A2, B1, B2, C1, and C2.

[0134] For example, on the basis of Figure 1 when each standby database in the database cluster is all standby databases in non-main computer rooms, each standby database in the database cluster is standby databases B1, B2, C1, and C2.

[0135] According to the topology structure, obtain the read-write status of each standby database in the database cluster, including:

[0136] According to the topology structure, for each standby database, execute the command "show variables like '%read_only%'" to obtain the read-write status of the standby database.

[0137] Method 12: For each standby database in all non-main computer rooms in the database cluster: According to the topology structure, execute the command "show variables like '%read_only%'" to obtain the read-write status of the standby database; when the read-write status is the read-only state, determine that the read-write status of the standby database is the read-only state, and when the read-write status is the non-read-only state, display the first reminder message, and the first reminder message reminds the database administrator to intervene in the investigation to ensure that the read-write status of the standby database is the read-only state;

[0138] Determine all standby databases in all non-main computer rooms with the read-write status being the read-only state as at least one candidate database.

[0139] Method 13: For each database in all non-main computer rooms in the database cluster: According to the topology structure, execute the command "show variables like '%read_only%'" to obtain the read-write status of the database; when the read-write status is the read-only state, determine that the read-write status of the database is the read-only state, and when the read-write status is the non-read-only state, display the first reminder message, and the first reminder message reminds the database administrator to intervene in the investigation to ensure that the read-write status of the database is the read-only state;

[0140] Determine all databases in all non-main computer rooms with the read-write status being the read-only state as at least one candidate database.

[0141] S303. Determine the standby databases without the high-availability HA service deployed among at least one candidate database.

[0142] Optionally, for each candidate database, execute the command "ps -ef|grep HA" in the preset tool to determine the standby database for deploying the high-availability (HA) service.

[0143] Determine the standby databases other than the standby database for deploying the high-availability (HA) service in at least one candidate database as the standby databases without deploying the high-availability (HA) service.

[0144] S304. Determine the target database as the standby database that is selected by the selection input operation and does not deploy the high-availability (HA) service.

[0145] Optionally, the electronic device may display the standby databases without deploying the high-availability (HA) service and the selection boxes corresponding to the standby databases without deploying the high-availability (HA) service, and determine the standby database corresponding to the selected selection box in the selection input operation as the target database.

[0146] For example, on the basis of Method 11, the standby databases A2, B2, or C2 in Figure 1 may be determined as the target database.

[0147] For example, on the basis of Method 12 or Method 13, the standby databases B2 or C2 in Figure 1 may be determined as the target database.

[0148] S305. For each original data table in the target database, determine the target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set.

[0149] S306. When it is determined that the character sets of all original data tables can be updated to the target character set, determine that the original character set of the target database can be updated to the target character set.

[0150] Specifically, the execution methods of S305 and S306 are the same as those of S202 and S203, and the execution processes of S305 and S306 will not be elaborated here.

[0151] On the basis of the above embodiments, the following Figure 4 shown method may be used to determine the target data table according to the target character set and the original data table.

[0152] Figure 4 is a schematic flowchart of the process for determining the target data table provided by the embodiment of the present application. As Figure 4 shown, the method includes:

[0153] S401. Control the disconnection of the link between the target database and the master database corresponding to the target database.

[0154] In the preset tool, the link between the target database and the master database corresponding to the target database is disconnected by executing the command "stop slave".

[0155] S402. Determine whether the target character set is compatible with the original character set.

[0156] If so, execute S403.

[0157] Otherwise, execute S404.

[0158] Optionally, S402 includes:

[0159] Search for a character set that is compatible with the original character set in the character set compatibility mapping table, which includes multiple first character sets and second character sets that are compatible with the first character sets. The original character set is included in the multiple first character sets;

[0160] When the target character set is included in the character set that is compatible with the original character set, determine that the target character set is compatible with the original character set;

[0161] When the target character set is not included in the character set that is compatible with the original character set, determine that the target character set is not compatible with the original character set.

[0162] S403. Create a replication table corresponding to the original data table, update the character set of the replication table to the target character set, and determine the replication table with the updated character set as the target data table.

[0163] Among them, creating a replication table corresponding to the original data table includes: creating an empty table identical to the original data table; inserting the original data table into the empty table to obtain the replication table.

[0164] Optionally, creating an empty table identical to the original data table can be achieved by using the following command: create table table_name_bak like table_name;

[0165] Optionally, inserting the original data table into the empty table to obtain the replication table can be achieved by using the following command: insert into table_name_bak select * from table_name.

[0166] Optionally, for example, if the target character set is utf8mb4, updating the character set of the replication table to the target character set can be achieved by using the following command: alter table table_name_bak convert to character set utf8mb4.

[0167] S404. Determine the data table corresponding to the original data table in the pre-created new database as the target data table, where the character set of the new database is the target character set.

[0168] In a possible implementation, obtaining the new database includes:

[0169] Create a database instance with the target character set;

[0170] Import each original data table into the database instance;

[0171] Establish a link between the database instance and the database management device to obtain the new database.

[0172] Establish a link between the database instance and the database management device so that the authorization usage information of the new database is the same as that of the target database, so that the electronic device can perform relevant processing on the new database.

[0173] In this application, the main database corresponding to the target database can update data according to the current business. Therefore, controlling the disconnection of the link between the target database and the main database corresponding to the target database can prevent the main database from synchronizing data to the target database and avoid errors in the data consistency verification of the target data before and after the character set change caused by the synchronized data.

[0174] In a possible implementation, judging whether the character set of the original data table can be updated to the target character set according to the target data table includes:

[0175] Judge whether the first SQL file of the original data table is the same as the second SQL file of the target data table;

[0176] If the first SQL file is the same as the second SQL file, obtain the reference data table corresponding to the original data table from the main database corresponding to the target database. When it is determined that the table contents of the reference data table and the target data table are the same, determine that the character set of the original data table can be updated to the target character set.

[0177] Optionally, each data table has its own corresponding table identifier; the reference data table corresponding to the original data table can be obtained from the main database corresponding to the target database according to the table identifier of the original data table, and the table identifier of the original data table is the same as that of the reference data table.

[0178] If the first SQL file is not the same as the second SQL file, display a second reminder message indicating that there are different characters before and after the character set conversion. The second reminder message is used to remind the database administrator to intervene and troubleshoot to eliminate the different characters and ensure that the first SQL file is the same as the second SQL file.

[0179] In a possible implementation, determining that the table contents of the reference data table and the target data table are the same includes: for each primary key of the reference data table, determining whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table;

[0180] If the first row of data and the second row of data corresponding to the primary key are the same, it is determined that the row data corresponding to the primary key is the same; if the row data of each primary key is the same, it is determined that the table contents of the reference data table and the target data table are the same.

[0181] If the first row of data and the second row of data corresponding to the primary key are not the same, a third reminder message is displayed, and the third reminder message is used to indicate that the row data corresponding to the primary key is not the same. The third reminder message is used to remind the database administrator to intervene in the investigation to eliminate the different row data and ensure that the first row of data and the second row of data corresponding to the primary key are the same.

[0182] In a possible implementation, determining whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table includes:

[0183] When the first row of data and the second row of data are different, determining whether the update time of the first row of data is later than the acquisition time of the target data table;

[0184] If the update time is later than the acquisition time, it is determined that the first row of data and the second row of data are the same.

[0185] For example, when the target character set is compatible with the original character set, the acquisition time of the target data table can be the time of creating an empty table, or the time of obtaining a replicated table, etc.

[0186] For example, when the target character set is not compatible with the original character set, the acquisition time of the target data table can be the time of completing the creation of a new database.

[0187] In the related art, the method for verifying data consistency before and after character set change includes: verifying data consistency before and after character set change without interrupting the current service. Since the current service is not interrupted, it is impossible to distinguish historical data and newly added data in the database, resulting in failure to verify data consistency before and after character set change.

[0188] In the embodiments of the present application, when the first row of data and the second row of data are different, determining whether the update time of the first row of data is later than the acquisition time of the target data table, and if the update time is later than the acquisition time, determining that the first row of data and the second row of data are the same can prevent the problem of incorrect verification of data consistency before and after character set change caused by the row data being newly added data, and improve the accuracy of verifying data consistency before and after character set change.

[0189] Figure 5 This is a schematic structural diagram of a verification device with an updatable character set provided by an embodiment of the present application. As Figure 5 shown, the verification device 10 with an updatable character set includes:

[0190] A determination module 101, configured to determine a target database in a database cluster; wherein, the original character set of the target database is to be updated to a target character set, and the target database is a standby database that has not updated data according to the current business;

[0191] The determination module 101 is further configured to, for each original data table in the target database, determine a target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set;

[0192] The determination module 101 is further configured to, when determining that the character sets of all the original data tables can be updated to the target character set, determine that the original character set of the target database can be updated to the target character set.

[0193] The verification device with an updatable character set provided by the embodiment of the present application can execute the technical solutions shown in the above method embodiments, and its implementation principle and beneficial effects are similar, which will not be elaborated here.

[0194] In a possible implementation manner, the determination module 101 is specifically configured to:

[0195] Obtain the topological structure of the database cluster;

[0196] According to the topological structure, determine at least one candidate database in the database cluster;

[0197] Determine a standby database in the at least one candidate database that does not deploy a high-availability (HA) service;

[0198] Determine the standby database that is selected by the selection input operation and does not deploy an HA service as the target database.

[0199] In a possible implementation manner, the determination module 101 is specifically configured to:

[0200] According to the topological structure, obtain the read-write status of each standby database in the database cluster;

[0201] Determine the standby database with a read-only status as the at least one candidate database.

[0202] In a possible implementation manner, the determination module 101 is specifically configured to:

[0203] Control the disconnection of the link between the target database and the primary database corresponding to the target database;

[0204] Determine whether the target character set is compatible with the original character set;

[0205] If they are compatible, create a copy table corresponding to the original data table, update the character set of the copy table to the target character set, and determine the copy table with the updated character set as the target data table;

[0206] If they are not compatible, determine the data table corresponding to the original data table in the pre-created new database as the target data table; wherein, the character set of the new database is the target character set.

[0207] In a possible implementation manner, the determining module 101 is specifically configured to:

[0208] Create a database instance with the target character set;

[0209] Import each original data table into the database instance;

[0210] Establish a link between the database instance and the database management device to obtain a new database.

[0211] In a possible implementation manner, the determining module 101 is specifically configured to:

[0212] Determine whether the first Structured Query Language (SQL) file of the original data table is the same as the second SQL file of the target data table;

[0213] If they are the same, obtain the reference data table corresponding to the original data table from the main database corresponding to the target database, and when it is determined that the table contents of the reference data table and the target data table are the same, determine that the character set of the original data table can be updated to the target character set.

[0214] In a possible implementation manner, the determining module 101 is specifically configured to:

[0215] For each primary key of the reference data table, determine whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table. If the first row of data and the second row of data corresponding to the primary key are the same, determine that the row of data corresponding to the primary key is the same;

[0216] If the row of data for each primary key is the same, determine that the table contents of the reference data table and the target data table are the same.

[0217] In a possible implementation manner, the determining module 101 is specifically configured to:

[0218] When the first row of data and the second row of data are different, determine whether the update time of the first row of data is later than the obtained time of the target data table;

[0219] If the update time is later than the acquisition time, it is determined that the first row of data is the same as the second row of data.

[0220] The character set updatable verification device provided by the embodiments of the present application is used to execute the technical solutions shown in the above method embodiments. The implementation principles and beneficial effects are similar and will not be elaborated here.

[0221] Figure 6 It is a schematic structural diagram of the electronic device provided by the embodiments of the present application. As Figure 6 shown, the electronic device 20 may include: a memory 201, a processor 202, and a transceiver 203.

[0222] The memory 201 is used to store program instructions.

[0223] The processor 202 is used to execute the program instructions stored in the memory, so as to enable the electronic device to execute the above method.

[0224] The transceiver 203 may include: a transmitter and / or a receiver. The transmitter may also be referred to as a sender, a transmitter, a sending port, or a sending interface, etc. The receiver may also be referred to as a receiver, a receiving port, or a receiving interface, etc. Exemplarily, the memory 201, the processor 202, and the transceiver 203 are interconnected with each other through a bus 204.

[0225] All or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a readable memory. When the program is executed, it executes the steps including the above method embodiments; and the foregoing memory (storage medium) includes: read-only memory (ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape, floppy disk, optical disc, and any combination thereof.

[0226] The embodiments of the present application provide a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the methods of the above method embodiments.

[0227] The embodiments of the present application also provide a computer program product, including a computer program, which when executed by a processor, can implement the methods shown in the above method embodiments.

[0228] These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device realizes the processFigure 1 one process or multiple processes and / or blocks Figure 1 the functions specified in one block or multiple blocks.

[0229] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or multiple processes and / or the functions specified in one block or multiple blocks.

[0230] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these changes and modifications.

[0231] In the present application, the term "including" and its variants may refer to non-limiting inclusion; the term "or" and its variants may refer to "and / or". In the present application, terms such as "first" and "second" are used to distinguish similar objects and do not necessarily have to describe a specific order or sequence. In the present application, "multiple" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

Claims

1. A verification method with updatable character set, characterized in that, Including: Determine a target database in a database cluster; wherein, the original character set of the target database is to be updated to a target character set, and the target database is a standby database that has not performed data updates according to the current business; For each original data table in the target database, determine a target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set; When it is determined that the character sets of all the original data tables can be updated to the target character set, determine that the original character set of the target database can be updated to the target character set.

2. The method according to claim 1, characterized in that, Determine a target database in a database cluster, including: Obtain the topology structure of the database cluster; Determine at least one candidate database in the database cluster according to the topology structure; Determine a standby database in the at least one candidate database that does not deploy a high-availability (HA) service; Determine the standby database that is selected by a selection input operation and does not deploy an HA service as the target database.

3. The method according to claim 2, wherein Determine at least one candidate database in the database cluster according to the topology structure, including: Obtain the read-write status of each standby database in the database cluster according to the topology structure; Determine the standby databases with a read-only status as the at least one candidate database.

4. The method according to any one of claims 1 to 3, characterized in that Determine a target data table according to the target character set and the original data table, including: Control the disconnection of the link between the target database and the primary database corresponding to the target database; Judge whether the target character set is compatible with the original character set; If it is compatible, create a replication table corresponding to the original data table, update the character set of the replication table to the target character set, and determine the replication table with the updated character set as the target data table; If it is not compatible, determine the data table corresponding to the original data table in a pre-created new database as the target data table; wherein, the character set of the new database is the target character set.

5. The method according to claim 4, wherein Obtain the new database, including: Create a database instance with the target character set; Import the original data tables into the database instance; Establish a link between the database instance and a database management device to obtain the new database.

6. The method according to any one of claims 1 to 5, characterized in that Determine whether the character set of the original data table can be updated to the target character set according to the target data table, including: Judge whether the first Structured Query Language (SQL) file of the original data table is the same as the second SQL file of the target data table; If they are the same, obtain a reference data table corresponding to the original data table from the primary database corresponding to the target database, and when it is determined that the table content of the reference data table is the same as that of the target data table, determine that the character set of the original data table can be updated to the target character set.

7. The method according to claim 6, wherein Determine that the table content of the reference data table is the same as that of the target data table, including: For each primary key of the reference data table, determine whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table. If the first row of data and the second row of data corresponding to the primary key are the same, determine that the row data corresponding to the primary key is the same; If the row data of each primary key is the same, determine that the table contents of the reference data table and the target data table are the same.

8. The method according to claim 7, wherein Determining whether the first row of data corresponding to the primary key in the reference data table is the same as the second row of data corresponding to the primary key in the target data table includes: When the first row of data and the second row of data are different, determine whether the update time of the first row of data is later than the acquisition time of the target data table; If the update time is later than the acquisition time, determine that the first row of data and the second row of data are the same.

9. A verification device with an updatable character set, characterized in that, including: A determination module for determining a target database in a database cluster; wherein, the original character set of the target database is to be updated to a target character set, and the target database is a standby database that has not updated data according to the current business; The determination module is further configured to, for each original data table in the target database, determine a target data table according to the target character set and the original data table, and determine whether the character set of the original data table can be updated to the target character set according to the target data table; wherein, the character set of the target data table is the target character set; The determination module is further configured to determine that the original character set of the target database can be updated to the target character set when it is determined that the character sets of all the original data tables can be updated to the target character set.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when the computer-executable instructions are executed by a processor.