Private cloud-to-public cloud database total synchronization method
Through the full synchronization of the database of the private cloud to the public cloud, three-time verification and filtering processes of table names, global column names and single table column names are used to solve the synchronization problems caused by network fluctuations and the complex synchronization process caused by table structure differences, and realizes the Higher synchronization accuracy.
Patent Information
- Application Number
- CN202411494727.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-18
AI Technical Summary
During the transmission process, due to large network fluctuations in the network, problems occur in real-time data synchronization occur, and due to differences in table structure, the synchronization process is complicated.
A three-time verification and filtering process based on table name, global column name and single table column name is adopted to eliminate unrelated columns during transmission, avoid filtering on the network in the cloud, and improve synchronization accuracy.
Reduces the risk of transmission errors, improves synchronization accuracy, and avoids filtering errors caused by re-ranking in multiple tables.
Smart Images

Figure CN119474201A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database synchronization, and in particular to a method for fully synchronizing a private cloud with a public cloud database. Background Art
[0002] Database synchronization is an ongoing process of keeping the same record types between two or more systems. The core purpose of database synchronization is to maintain data consistency and accuracy. Through the synchronization mechanism, data between different systems or databases can be kept up to date and consistent to avoid data conflicts and errors. In some business systems, it often involves the process of synchronizing data from a locally deployed cloud platform, called a private cloud, to a remotely deployed cloud platform, called a public cloud.
[0003] In the prior art, there are technical solutions applied to database synchronization in private cloud systems. For example, Chinese patent CN202110255623.3 discloses a method and device for private cloud information synchronization, which relates to the field of cloud computing technology, and further to the field of cloud network technology. The specific implementation scheme is: first, an information synchronization request sent by the first control node is received, and the information synchronization request includes a synchronization type and a synchronization identifier, and then based on the synchronization type and the synchronization identifier, the target number of synchronization information is determined, and finally based on the target number of synchronization information, a new synchronization identifier and a new synchronization type are determined, and the target number of synchronization information, the new synchronization identifier and the new synchronization type are sent to the first control node. Information synchronization is implemented in batches, and only the target number of information is synchronized each time, so that the request response of the information synchronization initiator will not cause a timeout, and can avoid blocking other coroutines.
[0004] However, in the actual implementation process, the inventors found that since the transmission process between the private cloud system and the public cloud system often involves the transmission process across multiple levels of gateways, the network fluctuations are large, which often leads to problems with real-time data synchronization and transmission errors. In addition, considering that the tables and columns designed by the private cloud side according to business requirements are different from the tables and columns designed by the public cloud for storage requirements, the synchronization process has become more complicated. Summary of the invention
[0005] In view of the above problems existing in the prior art, a method for full synchronization of a private cloud database with a public cloud is now provided.
[0006] The specific technical solutions are as follows:
[0007] A method for fully synchronizing a private cloud database with a public cloud, comprising:
[0008] Step S1: acquiring a table name set and a corresponding table name filtering rule from a first database, and processing the table name set according to the table name filtering rule to obtain table structure information to be synchronized;
[0009] Step S2: obtaining a global column name filtering rule and a single table column name filtering rule, and processing the table structure information according to the global column name filtering rule and the single table column name filtering rule to obtain the table structure information to be synchronized;
[0010] Step S3: pre-delete the second database according to the table structure information to be synchronized, and then perform full synchronization on the single table of the second database and the first database according to the table structure information to be synchronized.
[0011] On the other hand, the step S1 comprises:
[0012] Step S11: acquiring a table name set and the table name filtering rule from the first database;
[0013] The table name filtering rules include database table blacklist rules and / or database table whitelist rules;
[0014] Step S12: filtering the data table information contained in the table name set according to the database table whitelist rule and the database table blacklist rule in turn to obtain a filtered data table;
[0015] Step S13: extracting table structures from the screened data tables respectively to construct the table structure information.
[0016] On the other hand, the step S12 comprises:
[0017] Step S121: determining whether the database whitelist rule is configured in the table name filtering rule;
[0018] If yes, go to step S122:
[0019] If not, go to step S123;
[0020] Step S122: screening the data table information according to the database whitelist rule to remove database tables that do not exist in the database whitelist rule, and then turning to step S124;
[0021] Step S123: screening the data table information according to the database table blacklist rule to remove the database table recorded in the database table blacklist rule, and then turning to step S124;
[0022] Step S124: outputting the retained database table as the filtered database table.
[0023] On the other hand, in step S12, when the database table whitelist rule and the database table blacklist rule have the same database table, the database table is retained.
[0024] On the other hand, the step S2 comprises:
[0025] Step S21: obtaining the global column name filtering rule and the single table column name filtering rule;
[0026] Step S22: filtering the global column names contained in the table structure information using a global column name filtering rule to generate global column name filtering table structure information;
[0027] Step S23: filtering the single table column name of each database table in the global column name filtering table structure information using the single table column name filtering rule to generate the table structure information to be synchronized.
[0028] On the other hand, the step S22 comprises:
[0029] Step S221: determining whether a global column name whitelist rule is configured in the global column name filtering rule;
[0030] If yes, go to step S222;
[0031] If not, go to step S223;
[0032] Step S222: screening the global column names according to the global column name whitelist rule to remove the global column names that do not exist in the global column name whitelist rule, and then turning to step S224;
[0033] Step S223: screening the global column names according to the global column name blacklist rule to remove the global column names recorded in the global column name blacklist rule, and then turning to step S224;
[0034] Step S224: outputting the retained global column name as the global column name filtering table structure information.
[0035] On the other hand, the step S23 comprises:
[0036] Step S231: for each of the database tables, determining whether a single-table column name whitelist rule is configured in the single-table column name filtering rule;
[0037] If yes, go to step S232;
[0038] If not, go to step S233;
[0039] Step S232: screening the single-table column names according to the single-table column name whitelist rule to remove the single-table column names that do not exist in the single-table column name whitelist rule, and then turning to step S234;
[0040] Step S233: screening the single-table column names according to the single-table column name blacklist rule to remove the single-table column names recorded in the single-table column name blacklist rule, and then turning to step S234;
[0041] Step S234: Generate the table structure information to be synchronized according to the reserved single table column name.
[0042] On the other hand, the step S3 comprises:
[0043] Step S31: deleting the columns in the second database corresponding to the first database according to the table structure information to be synchronized;
[0044] Step S32: traverse the table structure information to be synchronized row by row, and select corresponding rows in the first database for synchronization according to the table structure information to be synchronized, until the synchronization is completed.
[0045] On the other hand, after executing step S31 and before executing step S32, the method further includes:
[0046] Step A31: Determine whether the total number of rows of the table structure information to be synchronized is greater than a preset threshold, and perform batch synchronization if the total number of rows is greater than the preset threshold.
[0047] On the other hand, during the process of executing the step S1 to the step S3, a transaction log is generated according to the table structure information, the table structure information to be synchronized and the synchronization result.
[0048] The above technical solution has the following advantages or beneficial effects:
[0049] In view of the problem in the prior art that the process of synchronizing private clouds to public clouds is greatly affected by network fluctuations, this solution introduces a three-step verification and filtering process based on table names, global column names, and single table column names, which eliminates irrelevant columns during the transmission process and avoids the problem of high network dependence on direct transmission for filtering in the cloud. It is also easy to configure synchronization information, and there will be no errors when there are multiple tables with duplicate names, thereby improving the accuracy of synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The embodiments of the present invention will be described more fully with reference to the attached drawings, which are provided for illustration and description only and are not intended to limit the scope of the present invention.
[0051] Figure 1 It is an overall schematic diagram of an embodiment of the present invention;
[0052] Figure 2 This is a schematic diagram of step S1 in an embodiment of the present invention;
[0053] Figure 3 This is a schematic diagram of step S12 in an embodiment of the present invention;
[0054] Figure 4 This is a schematic diagram of step S2 in an embodiment of the present invention;
[0055] Figure 5 This is a schematic diagram of step S22 in an embodiment of the present invention;
[0056] Figure 6 This is a schematic diagram of step S23 in an embodiment of the present invention;
[0057] Figure 7 This is a schematic diagram of step S3 in an embodiment of the present invention;
[0058] Figure 8 Schematic diagram of step A31 in an embodiment of the present invention DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0061] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.
[0062] The present invention comprises:
[0063] A method for fully synchronizing a private cloud database with a public cloud database, such as Figure 1 As shown, including:
[0064] Step S1: obtaining a table name set and a corresponding table name filtering rule from a first database, and processing the table name set according to the table name filtering rule to obtain table structure information to be synchronized;
[0065] Step S2: obtaining global column name filtering rules and single table column name filtering rules, and processing the table structure information according to the global column name filtering rules and the single table column name filtering rules to obtain the table structure information to be synchronized;
[0066] Step S3: pre-delete the second database according to the table structure information to be synchronized, and then perform full synchronization of the single table of the second database and the first database according to the table structure information to be synchronized.
[0067] Specifically, in response to the problem in the prior art that the synchronization process from private cloud to public cloud is greatly affected by network fluctuations, this solution introduces a three-time verification and filtering process based on table name, global column name and single table column name, which eliminates irrelevant columns in the transmission process and then transmits them to the public cloud side, avoiding the problem of overall database transmission and processing in the cloud with a high dependence on the network, and reducing the risk of transmission errors.
[0068] At the same time, since the table name filtering rules, global column name filtering rules and single table column name filtering rules are set separately, the filtering range is carried out from large to small, which avoids the problem in the prior art that when filtering database transmission data, the table name and column name must be specified at the same time, the configuration length is long and the filtering efficiency is low. It also avoids the problem of filtering errors when there are duplicate columns in multiple tables, thereby improving the accuracy of synchronization.
[0069] During the implementation process, the above-mentioned database full synchronization method is configured as a software embodiment in a private cloud system to realize the synchronization process from the private cloud to the public cloud. The private cloud refers to the cloud platform server deployed locally by the user, and the public cloud is a cloud platform server deployed on an external network relative to the local network. The private cloud and the public cloud are connected through the Internet and data is transmitted.
[0070] Among them, the first database is a database system configured in a private cloud system, which includes at least one database, each database contains at least one database table, and each database table contains multiple columns. The second database is a database system configured in a public cloud system, which includes at least one database, each database contains at least one database table, and each database table contains multiple columns, but the tables and columns contained may be different from those of the first database, and only a partial mapping relationship exists. Table name filtering rules, global column name filtering rules, and single table column name filtering rules are filtering rules designed for database tables, global columns across multiple database tables, and single columns in a single database table, and may include whitelists and blacklists, etc., and at least include blacklists.
[0071] In one embodiment, Figure 2 As shown, step S1 includes:
[0072] Step S11: obtaining a table name set and table name filtering rules from the first database;
[0073] Table name filtering rules include database table blacklist rules and / or database table whitelist rules;
[0074] Step S12: filtering the data table information contained in the table name set according to the database table whitelist rule and the database table blacklist rule in turn to obtain a filtered data table;
[0075] Step S13: extracting table structures from the screened data tables respectively to construct table structure information.
[0076] Specifically, to achieve a better screening process, in this embodiment, a database table blacklist rule and / or a database table whitelist rule are allocated to the database table, wherein at least the database table blacklist rule is configured.
[0077] Then, in the first screening process, the data table information contained in the table name set is screened according to the database table whitelist rules and database table blacklist rules to obtain the screened data table as the object to be synchronized in the subsequent synchronization process. For the retained screened data tables, the table structure information of each screened data table is read separately, and then added to the overall table structure information for caching.
[0078] In one embodiment, Figure 3 As shown, step S12 includes:
[0079] Step S121: Determine whether a database whitelist rule is configured in the table name filtering rule;
[0080] If yes, go to step S122:
[0081] If not, go to step S123;
[0082] Step S122: Screening the data table information according to the database whitelist rule to remove the database table that does not exist in the database whitelist rule, and then turning to step S124;
[0083] Step S123: Screening the data table information according to the database table blacklist rule to remove the database table recorded in the database table blacklist rule, and then turning to step S124;
[0084] Step S124: outputting the retained database table as the filtered database table.
[0085] Specifically, in order to achieve a better screening effect, in this embodiment, the above-mentioned sorting and comparison rules are set for the database whitelist rule and the database blacklist rule of the database table. Specifically, before starting the discrimination, different priorities are first configured for the database whitelist rule and the database blacklist rule, and the priority of the database whitelist rule is higher than that of the database blacklist rule.
[0086] At the beginning of the screening, first determine whether there is a database whitelist rule. If so, read the database whitelist rule first. The database whitelist rule configures the database tables that need to be synchronized. Then select the database tables that need to be retained according to the database whitelist rule, and remove the database tables that are not recorded in the database whitelist rule.
[0087] Correspondingly, if it is determined that there is no database whitelist rule, it indicates that the database blacklist rule is currently selected for configuration, and the database blacklist rule configures a database table that does not need to be synchronized. Then the recorded database table is removed according to the database blacklist rule.
[0088] Finally, the remaining database table is used as the filtered database table.
[0089] Accordingly, since the priority of the database whitelist rule is preconfigured to be higher than the priority of the database blacklist rule, in step S12, when the database table whitelist rule and the database table blacklist rule have the same database table, the database table is retained.
[0090] In one embodiment, Figure 4 As shown, step S2 includes:
[0091] Step S21: Obtain global column name filtering rules and single table column name filtering rules;
[0092] Step S22: filtering the global column names contained in the table structure information using the global column name filtering rule to generate global column name filtering table structure information;
[0093] Step S23: The single table column name of each database table in the global column name filtering table structure information is filtered using the single table column name filtering rule to generate the table structure information to be synchronized.
[0094] Specifically, in order to address the problem in the prior art that when filtering database transmission data, the table name and column name must be specified at the same time, the configuration length is long and thus leads to low screening efficiency, in this embodiment, global column name filtering rules and single table column name filtering rules configured for each database table are set respectively.
[0095] Among them, the global column name filtering rules include the columns that need to be removed or retained in multiple database tables. According to the filtering rules, they can be divided into global column name whitelist rules and global column name blacklist rules. Generally, at least the global column name blacklist rules are configured.
[0096] The single-table column name filtering rules include the columns that need to be removed or retained, which are configured for each filtered database. According to the filtering rules, they can be divided into single-table column name whitelist rules and single-table column name blacklist rules. Generally, at least the single-table column name blacklist rules are configured.
[0097] Since there may be duplicate column names in multiple database tables, during the screening process, a method is designed to pre-screen the global column names through global column name filtering rules to determine the global column names to be retained or removed, and then screen through single-table column name filtering rules to determine the single-table column names to be retained or removed, achieving a better screening effect, as follows:
[0098] In one embodiment, Figure 5 As shown, step S22 includes:
[0099] Step S221: determining whether a global column name whitelist rule is configured in the global column name filtering rule;
[0100] If yes, go to step S222;
[0101] If not, go to step S223;
[0102] Step S222: Filter the global column names according to the global column name whitelist rule to remove the global column names that do not exist in the global column name whitelist rule, and then turn to step S224;
[0103] Step S223: Filter the global column names according to the global column name blacklist rule to remove the global column names recorded in the global column name blacklist rule, and then turn to step S224;
[0104] Step S224: output the retained global column names as global column name screening table structure information.
[0105] Specifically, in order to achieve a better screening effect, in this embodiment, the above-mentioned sorting and comparison rules are set for the global column name whitelist rule and the global column name blacklist rule of the global column name. Specifically, before starting the judgment, different priorities are first configured for the global column name whitelist rule and the global column name blacklist rule, and the priority of the global column name whitelist rule is higher than that of the global column name blacklist rule.
[0106] At the beginning of the screening, first determine whether there is a global column name whitelist rule. If so, read the global column name whitelist rule first. The global column names that need to be synchronized are configured in the global column name whitelist rule. Then select the global column names that need to be retained according to the global column name whitelist rule, and remove the global column names that are not recorded in the global column name whitelist rule.
[0107] Correspondingly, if it is determined that there is no global column name whitelist rule, it indicates that the global column name blacklist rule is currently selected for configuration, and the global column name that does not need to be synchronized is configured in the global column name blacklist rule. Then the global column name of the record is removed according to the global column name blacklist rule.
[0108] Finally, the retained global column names are used as the retained global column names, and then the column names included in the table structure information are modified according to the global column names to form the global column name filtering table structure information.
[0109] Accordingly, since the priority of the global column name whitelist rule is preconfigured to be higher than the priority of the global column name blacklist rule, in step S22, when the global column name whitelist rule and the global column name blacklist rule have the same global column name, the global column name is retained.
[0110] In one embodiment, Figure 6 As shown, step S23 includes:
[0111] Step S231: for each database table, determine whether a single table column name whitelist rule is configured in the single table column name filtering rule;
[0112] If yes, go to step S232;
[0113] If not, go to step S233;
[0114] Step S232: Screen the single-table column names according to the single-table column name whitelist rule to remove the single-table column names that do not exist in the single-table column name whitelist rule, and then turn to step S234;
[0115] Step S233: Screen the single-table column names according to the single-table column name blacklist rule to remove the single-table column names recorded in the single-table column name blacklist rule, and then turn to step S234;
[0116] Step S234: Generate table structure information to be synchronized according to the reserved single table column names.
[0117] Specifically, in order to achieve a better screening effect, in this embodiment, the above-mentioned sorting and comparison rules are set for the single-table column name whitelist rule and the single-table column name blacklist rule configured for the column name of each database table. Specifically, before starting the judgment, different priorities are first configured for the single-table column name whitelist rule and the single-table column name blacklist rule, and the priority of the single-table column name whitelist rule is higher than that of the single-table column name blacklist rule.
[0118] At the beginning of the screening, first determine whether there is a single-table column name whitelist rule. If so, read the single-table column name whitelist rule first. The single-table column name whitelist rule is configured with the single-table column names that need to be synchronized. Then select the single-table column names that need to be retained according to the single-table column name whitelist rule, and remove the single-table column names that are not recorded in the single-table column name whitelist rule.
[0119] Correspondingly, if it is determined that there is no single-table column name whitelist rule, it indicates that the single-table column name blacklist rule is currently selected for configuration, and the single-table column name blacklist rule is configured with single-table column names that do not need to be synchronized. Then the recorded single-table column names are removed according to the single-table column name blacklist rule.
[0120] Finally, the retained single table column names are used as the retained single table column names, and then the column names included in the table structure information are modified according to the part of the single table column names to form the table structure information to be synchronized.
[0121] Accordingly, since the priority of the single table column name whitelist rule is pre-configured to be higher than the priority of the single table column name blacklist rule, in step S23, when the single table column name whitelist rule and the single table column name blacklist rule have the same single table column name, the single table column name is retained.
[0122] In one embodiment, Figure 7 As shown, step S3 includes:
[0123] Step S31: deleting the rows in the second database corresponding to the first database according to the table structure information to be synchronized;
[0124] Step S32: traverse the table structure information to be synchronized row by row, and select corresponding rows in the first database for synchronization according to the table structure information to be synchronized, until the synchronization is completed.
[0125] Specifically, after constructing the table structure information to be synchronized, the data that needs to be synchronized from the first database to the second database can be determined. Considering that part of the data in the second database has been pre-synchronized, after constructing the table structure information to be synchronized, first delete the rows corresponding to the first database that already exist in the second database according to the table structure information to be synchronized. Then, traverse the table structure information to be synchronized row by row, and for the currently specified row, execute the DML statement select in the first database to select the row, and automatically execute the corresponding DML statement insert into in the second database to insert it. Repeat this step until the synchronization is completed.
[0126] In one embodiment, Figure 8 As shown, after executing step S31 and before executing step S32, the following steps are also included:
[0127] Step A31: Determine whether the total number of rows of the table structure information to be synchronized is greater than a preset threshold, and perform batch synchronization if it is greater than the preset threshold.
[0128] Specifically, in order to achieve better synchronization accuracy and avoid errors caused by too much data in a single synchronization, in this embodiment, after pre-deletion, first: determine whether the total number of rows of the table structure information to be synchronized is greater than the preset threshold, and if it is not greater than the preset threshold, the synchronization operation can be performed normally. If it is greater than the preset threshold, the table structure information to be synchronized is split to obtain at least two groups of table structure information to be synchronized arranged in sequence, so that the total number of rows of each group of table structure information to be synchronized is not greater than the preset threshold, and then synchronization is performed successively.
[0129] In one embodiment, during the process of executing step S1 to step S3, a transaction log is generated according to the table structure information, the table structure information to be synchronized, and the synchronization result.
[0130] Specifically, in order to achieve a better synchronization effect, in this embodiment, during the execution of step S1, after the table structure information is extracted for the first database, the synchronization log of the table is first opened for the multiple database tables screened in the first database. In step S2, during the process of column name screening, the content recorded in the synchronization log is modified according to the screening results of the column names. Finally, during the synchronization process, when the execution step is completed, the database transaction of each table is submitted, and the synchronization results and synchronization time logs are recorded at the same time, and finally integrated and output into a log file saved in the specified path.
[0131] Those skilled in the art will appreciate that various aspects of the present invention, or possible implementations of various aspects, may be specifically implemented as systems, methods, or computer program products. Therefore, various aspects of the present invention, or possible implementations of various aspects, may take the form of complete hardware embodiments, complete software embodiments (including firmware, resident software, etc.), or embodiments of combined software and hardware aspects, all collectively referred to herein as "circuits," "modules," or "systems." In addition, various aspects of the present invention, or possible implementations of various aspects, may take the form of computer program products, which refer to computer instructions stored in a memory.
[0132] The memory may be a computer-readable signal medium or a computer-readable storage medium. Computer-readable storage media include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or apparatuses, or any suitable combination of the foregoing, such as random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable read-only memory (CD-ROM).
[0133] The processor in the computer reads the computer instructions stored in the memory, so that the processor can execute the functional actions specified in each step or the combination of steps in the flowchart; and generate a device for implementing the functional actions specified in each block or the combination of blocks in the block diagram.
[0134] It should be understood that the processor in the computer can be understood as one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components implemented to execute the aforementioned computer instructions.
[0135] Computer instructions can be executed completely on the user's local computer, partially on the user's local computer, as a separate software package, partially on the user's local computer and partially on a remote computer, or completely on a remote computer or server. It should also be noted that in some alternative embodiments, the functions noted in each step in the flow chart or each block in the block diagram may not occur in the order noted in the figure. For example, depending on the functions involved, two steps or two blocks shown in succession may actually be executed roughly simultaneously, or these blocks may sometimes be executed in reverse order.
[0136] The above are only preferred embodiments of the present invention, and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the description and illustrations of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for full synchronization of a private cloud database with a public cloud, characterized in that: include: Step S1: acquiring a table name set and a corresponding table name filtering rule from a first database, and processing the table name set according to the table name filtering rule to obtain table structure information to be synchronized; Step S2: obtaining a global column name filtering rule and a single table column name filtering rule, and processing the table structure information according to the global column name filtering rule and the single table column name filtering rule to obtain the table structure information to be synchronized; Step S3: pre-delete the second database according to the table structure information to be synchronized, and then perform full synchronization on the single table of the second database and the first database according to the table structure information to be synchronized.
2. The method for full database synchronization according to claim 1, characterized in that: The step S1 comprises: Step S11: acquiring a table name set and the table name filtering rule from the first database; The table name filtering rules include database table blacklist rules and / or database table whitelist rules; Step S12: filtering the data table information contained in the table name set according to the database table whitelist rule and the database table blacklist rule in turn to obtain a filtered data table; Step S13: extracting table structures from the screened data tables respectively to construct the table structure information.
3. The method for full database synchronization according to claim 2, characterized in that: The step S12 comprises: Step S121: determining whether the database whitelist rule is configured in the table name filtering rule; If yes, go to step S122: If not, go to step S123; Step S122: screening the data table information according to the database whitelist rule to remove database tables that do not exist in the database whitelist rule, and then turning to step S124; Step S123: screening the data table information according to the database table blacklist rule to remove the database table recorded in the database table blacklist rule, and then turning to step S124; Step S124: outputting the retained database table as the filtered database table.
4. The method for full database synchronization according to claim 3, characterized in that: In the step S12, when the database table whitelist rule and the database table blacklist rule have the same database table, the database table is retained.
5. The method for full database synchronization according to claim 1, characterized in that: The step S2 comprises: Step S21: obtaining the global column name filtering rule and the single table column name filtering rule; Step S22: filtering the global column names contained in the table structure information using a global column name filtering rule to generate global column name filtering table structure information; Step S23: filtering the single table column name of each database table in the global column name filtering table structure information using the single table column name filtering rule to generate the table structure information to be synchronized.
6. The method for full database synchronization according to claim 5, characterized in that: The step S22 comprises: Step S221: determining whether a global column name whitelist rule is configured in the global column name filtering rule; If yes, go to step S222; If not, go to step S223; Step S222: screening the global column names according to the global column name whitelist rule to remove the global column names that do not exist in the global column name whitelist rule, and then turning to step S224; Step S223: screening the global column names according to the global column name blacklist rule to remove the global column names recorded in the global column name blacklist rule, and then turning to step S224; Step S224: outputting the retained global column name as the global column name filtering table structure information.
7. The method for full database synchronization according to claim 5, characterized in that: The step S23 comprises: Step S231: for each of the database tables, determining whether a single-table column name whitelist rule is configured in the single-table column name filtering rule; If yes, go to step S232; If not, go to step S233; Step S232: screening the single-table column names according to the single-table column name whitelist rule to remove the single-table column names that do not exist in the single-table column name whitelist rule, and then turning to step S234; Step S233: screening the single-table column names according to the single-table column name blacklist rule to remove the single-table column names recorded in the single-table column name blacklist rule, and then turning to step S234; Step S234: Generate the table structure information to be synchronized according to the reserved single table column name.
8. The method for full database synchronization according to claim 1, characterized in that: The step S3 comprises: Step S31: deleting the columns in the second database corresponding to the first database according to the table structure information to be synchronized; Step S32: traverse the table structure information to be synchronized row by row, and select corresponding rows in the first database for synchronization according to the table structure information to be synchronized, until the synchronization is completed.
9. The method for full database synchronization according to claim 8, characterized in that: After executing step S31 and before executing step S32, the method further includes: Step A31: Determine whether the total number of rows of the table structure information to be synchronized is greater than a preset threshold, and perform batch synchronization if the total number of rows is greater than the preset threshold.
10. The method for full database synchronization according to claim 1, characterized in that: In the process of executing the step S1 to the step S3, a transaction log is generated according to the table structure information, the table structure information to be synchronized and the synchronization result.
Citation Information
Patent Citations
Private cloud information synchronization method and device
CN113014656B