Database switching method and device
By performing data structure verification and integrity verification on the target database, and generating and executing processing statements and operation statements, the complexity of database migration is solved, the migration success rate is improved, and business continuity is ensured.
Patent Information
- Application Number
- CN202410713853.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-10
AI Technical Summary
The database migration process is complicated, making it difficult to ensure successful migration and affecting normal business development.
By performing data structure verification and integrity verification on the target database, generating processing statements and operation statements, executing redo logs, and executing operation statements in the target database to ensure successful data migration.
This effectively improves the probability of successful database migration and ensures the normal development of business.
Smart Images

Figure CN118626468A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of big data technology, and in particular to a database switching method and device. Background Art
[0002] Data is the core of the database and the foundation of business continuity and development. In recent years, with the continuous development of information construction, the amount of data in many application system databases has increased exponentially to a very large level. For reasons such as data operation costs, database migration may be required. The database migration process is complex and involves many steps. It is difficult to ensure the successful migration of the database, which affects the normal development of the business. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a database switching method and device, which can improve the probability of successful database migration and ensure the normal development of business.
[0004] In a first aspect, an embodiment of the present invention provides a database switching method, comprising: performing a data structure check on a target database against a source database; in response to the target database failing the data structure check, determining an object to be processed in the target database; generating a processing statement corresponding to the object to be processed, and executing the processing statement in the target database; collecting a redo log of the source database, generating an operation statement corresponding to the redo log, and executing the operation statement in the target database; performing an integrity check on the target database against the source database; in response to the target database passing the integrity check, switching a business application from the source database to the target database.
[0005] Optionally, performing data structure verification on the target database for the source database includes: determining a plurality of source database objects from the source database, the source database objects including: data tables, indexes, views, users, triggers and functions; for each of the source database objects: determining whether there is a target database object matching the source database object in the target database; in response to the presence of a plurality of the target database objects in the target database, determining whether the target database object passes the data structure verification; wherein the target database objects correspond one-to-one to the source database objects.
[0006] Optionally, after determining whether there is a target database object matching the source database object in the target database, the method further includes: in response to the target database not having a target database object corresponding to the current source database object, determining that the target database fails to pass the data structure verification; and determining the object to be processed in the target database includes: determining the target database object corresponding to the current source database object as the object to be processed.
[0007] Optionally, generating a processing statement corresponding to the object to be processed includes: obtaining definition information of the current source database object; generating a processing statement corresponding to the object to be processed according to the definition information of the current source database object; wherein the processing statement includes: a construction statement or a modification statement.
[0008] Optionally, before the integrity check of the target database against the source database is performed, the step also includes: obtaining traffic information of the business application in multiple statistical time periods; determining a switching time period from the multiple statistical time periods based on the traffic information of the multiple statistical time periods; and executing the step of performing the integrity check of the target database against the source database in response to the current time reaching the switching time period.
[0009] Optionally, after switching the business application from the source-side database to the target-side database, the method further includes: collecting incremental logs of the source-side database; and synchronizing incremental data of the target-side database using the incremental logs.
[0010] Optionally, after switching the business application from the source-side database to the target-side database, it also includes: performing business process verification on the target-side database for the business application; in response to the target-side database failing the business process verification, switching the business application from the target-side database back to the source-side database.
[0011] In a second aspect, an embodiment of the present invention provides a database switching device, comprising: a first verification module, used to perform a data structure verification on a target database for a source database; a first execution module, used to determine an object to be processed in the target database in response to the target database failing the data structure verification; generate a processing statement corresponding to the object to be processed, and execute the processing statement in the target database; a second execution module, used to collect a redo log of the source database, generate an operation statement corresponding to the redo log, and execute the operation statement in the target database; a second verification module, used to perform an integrity verification on the target database for the source database; an application switching module, used to switch a business application from the source database to the target database in response to the target database passing the integrity verification.
[0012] Optionally, the first verification module is specifically used to: determine multiple source database objects from the source database, the source database objects including: data tables, indexes, views, users, triggers and functions; for each source database object: determine whether there is a target database object matching the source database object in the target database; in response to the existence of multiple target database objects in the target database, determine whether the target database object passes the data structure verification; wherein the target database objects correspond one-to-one to the source database objects.
[0013] Optionally, the first verification module is specifically used to: in response to the target database not having a target database object corresponding to the current source database object, determine that the target database fails to pass the data structure verification; and determine the target database object corresponding to the current source database object as the object to be processed.
[0014] Optionally, the first verification module is specifically used to: obtain definition information of the current source database object; generate a processing statement corresponding to the object to be processed according to the definition information of the current source database object; wherein the processing statement includes: a construction statement or a modification statement.
[0015] Optionally, the second verification module is specifically used to: obtain the traffic information of the business application in multiple statistical time periods; determine a switching period from the multiple statistical time periods based on the traffic information of the multiple statistical time periods; in response to the current time reaching the switching period, execute the step of performing integrity verification on the target database against the source database.
[0016] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any of the above embodiments.
[0018] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which implements the method described in any of the above embodiments when executed by a processor.
[0019] An embodiment of the above invention has the following advantages or beneficial effects: performing a data structure check on the target database against the source database. If the target database fails the data structure check, executing a processing statement for the object to be processed in the target database so that the target database passes the data structure check. Collecting the redo log of the source database, and executing the redo log operation statement in the target database to complete the data migration. When the target database passes the integrity check, switching the business application from the source database to the target database. The scheme of the embodiment of the present invention can effectively improve the probability of successful database migration and ensure the normal development of the business by performing data structure check and integrity check on the target database.
[0020] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention. Figure 1 It is a flowchart of a database switching method provided by the first embodiment of the present invention.
[0022] Figure 2 It is a flowchart of a database switching method provided by the second embodiment of the present invention.
[0023] Figure 3 It is a flowchart of a database switching method provided by the third embodiment of the present invention.
[0024] Figure 4 It is a flowchart of a database switching method provided by the fourth embodiment of the present invention.
[0025] Figure 5It is a schematic diagram of a risk control flow of database switching provided by the fourth embodiment of the present invention.
[0026] Figure 6 It is a structural schematic diagram of a database switching device provided by an embodiment of the present invention.
[0027] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0029] The acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0030] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0031] Figure 1 is a flowchart of a database switching method provided by the first embodiment of the present invention, such as Figure 1 As shown, the method includes: Step 101: Perform a data structure check on the target database against the source database.
[0032] Data structure verification is used to verify the database objects in the target database and the source database to determine whether the target database objects in the target database are compatible with the source database objects in the source database. Database objects may include: data tables, indexes, views, users, triggers, and functions.
[0033] Different database objects have different ways of data structure verification. For a data table, there is a target table in the target database and a source data table in the source database. Data structure verification includes: whether the table names of the target table and the source data table are the same; whether the definition information of the target table and the source data table matches; whether the target table can also support the execution statements that the source data table can support. The execution statements are used to perform operations such as adding, deleting, modifying, and checking.
[0034] For indexes, there is a target index in the target database and a source index in the source database. The data structure verification includes: whether the index name of the target index is the same as that of the source data index; whether the definition information of the target index matches that of the source index; and whether the target index can also support the query statements that the source index can support and has the same or better query performance.
[0035] Step 102: In response to the target database failing to pass the data structure verification, determining an object to be processed in the target database; generating a processing statement corresponding to the object to be processed, and executing the processing statement in the target database.
[0036] For each source database object in the source database, there is a target database object matching the source database object in the target database, and it is determined that the target database passes the data structure verification.
[0037] For a source database object in the source database, if there is no target database object matching the source database object in the target database, it is determined that the target database fails the data structure verification. The object to be processed in the target database corresponds to the source database object.
[0038] A processing statement is generated according to the definition information of the source database object, and the processing statement is executed in the target database, so that the object to be processed in the target database can be compatible with the source database object in the source database.
[0039] The processing statement can be a build statement or a modify statement. If there is no object to be processed in the target database with the same object type and name as the source database object, the processing statement is a build statement. If there is an object to be processed in the target database with the same object type and name as the source database object, the processing statement is a modify statement.
[0040] Step 103: Collect the redo logs of the source database, generate operation statements corresponding to the redo logs, and execute the operation statements in the target database.
[0041] The redo log is a low-level log that contains all transaction information and physical operation information of the database. By monitoring and tracking the redo log, database replication, backup, troubleshooting, etc. can be achieved.
[0042] Collect the redo logs of the source database, generate the operation statements corresponding to the redo logs, and execute the operation statements in the target database, so as to copy the data in the source database to the target database in batches.
[0043] Step 104: Perform an integrity check on the target database against the source database.
[0044] Integrity check can be set according to specific needs. Integrity check is used to check whether all data in the source database is imported into the target database, or whether the data difference between the target database and the source database is within the preset range. For example, for a data table, you can compare the size of the data to determine whether the data in the table has been completely imported into the target database.
[0045] If the target database passes the integrity check, step 105 is executed. If the target database fails the integrity check, incremental import from the source database to the target database may be executed, or a prompt message indicating that the target database fails the integrity check may be generated.
[0046] Step 105: In response to the target database passing the integrity check, the business application is switched from the source database to the target database.
[0047] After switching the business application from the source database to the target database, it also includes: verifying the business process of the business application on the target database; in response to the target database failing the business process verification, switching the business application from the target database back to the source database. The database migration process is complex and problems are inevitable. After switching the business application from the source database to the target database, verify the business process of the business application on the target database. The business process verification can be based on a pre-written test script. If the target database fails the business process verification, switch the business application from the target database back to the source database to avoid causing greater impact on the production system.
[0048] In the scheme of the embodiment of the present invention, a data structure check is performed on the target database with respect to the source database. If the target database fails the data structure check, a processing statement for the object to be processed is executed in the target database so that the target database passes the data structure check. The redo log of the source database is collected, and the redo log operation statement is executed in the target database to complete the data migration. When the target database passes the integrity check, the business application is switched from the source database to the target database. The scheme of the embodiment of the present invention can effectively improve the probability of successful database migration and ensure the normal development of the business by performing data structure check and integrity check on the target database.
[0049] In one embodiment of the present invention, after switching the business application from the source database to the target database, it also includes: collecting incremental logs of the source database; using the incremental logs, synchronizing incremental data of the target database. In the process of switching the business application from the source database to the target database, some data may enter the source database. Incremental data synchronization is performed on the target database to further ensure that data is not lost.
[0050] Figure 2 FIG. 1 is a flow chart of a database switching method provided by the second embodiment of the present invention. Figure 2 As shown, the method includes: Step 201: multiple source database objects are determined from a source database, where the source database objects include: data tables, indexes, views, users, triggers, and functions.
[0051] Step 202: for each source database object: determine whether there is a target database object matching the source database object in the target database.
[0052] In response to the presence of multiple target database objects in the target database, it is determined that the target database objects pass the data structure verification; wherein the target database objects correspond to the source database objects one by one. For each source database object in the source database, there is a target database object matching the source database object in the target database, and it is determined that the target database passes the data structure verification.
[0053] For a data table, there is a target table in the target database and a source data table in the source database. The matching between the target table and the source data table includes: the table name of the target table is the same as that of the source data table; the target table and the source data table have the same table structure; the data that can be inserted into the source data table can also be inserted into the target table; the target table can also support the execution statements that the source data table can support, and the execution statements are used to perform operations such as addition, deletion, modification, and query.
[0054] For indexes, there is a target index in the target database and a source index in the source database. The target index and the source index match in the following ways: the target index and the source index have the same index name; the definition information of the target index and the source index match; the target index can also support the query statements that the source index can support and has the same or better query performance.
[0055] Step 203: In response to the target database not having a target database object corresponding to the current source database object, determining that the target database fails to pass the data structure verification.
[0056] Step 204: determine the target database object corresponding to the current source database object as the object to be processed; generate a processing statement corresponding to the object to be processed, and execute the processing statement in the target database.
[0057] Obtain definition information of the current source database object; generate a processing statement corresponding to the object to be processed according to the definition information of the current source database object; wherein the processing statement includes: a construction statement or a modification statement.
[0058] If there is no object to be processed in the target database with the same object type and name as the source database object, the processing statement is a construction statement. According to the syntax of the target database, the definition information of the current source database object is rewritten to generate a processing statement corresponding to the object to be processed. The processing statement is used to construct the object to be processed in the target database.
[0059] If there is an object to be processed in the target database that has the same object type and name as the source database object, but the object to be processed cannot support the execution statements that the source data object can support, then the processing statement is a modification statement, which is used to modify the object to be processed in the target database so that the object to be processed and the source data object can support the same execution statements.
[0060] For example, the target database uses MySQL, the source database uses Oracle, and the target data table has the same name as the source data table. There is a field x in the target data table, and the field type of the field x is int. There is also a field x in the source data table, and the field type of the field x is float. Decimal data can be inserted into the field x of the source data table, but cannot be inserted into the field of the target data table. Therefore, the target data table is determined as the object to be processed, and a processing statement is generated. The execution statement is used to change the field type of the field x in the target data table to float.
[0061] Step 205: Collect the redo logs of the source database, generate operation statements corresponding to the redo logs, and execute the operation statements in the target database.
[0062] Step 206: Perform an integrity check on the target database against the source database.
[0063] Step 207: In response to the target database passing the integrity check, the business application is switched from the source database to the target database.
[0064] In the solution of the embodiment of the present invention, multiple source database objects are determined from the source database, and data result verification is performed on each source database object to determine whether the target database passes the data structure verification. If the target database fails the data structure verification, a processing statement corresponding to the object to be processed is generated, and the processing statement is executed in the target database, so that for each source database object in the source database, there is a target database object matching the source database object in the target database. The occurrence of database migration failures and the like can be reduced, and various applications in the production environment can be better supported.
[0065] Figure 3 is a flowchart of a database switching method provided by the third embodiment of the present invention, such as Figure 3 As shown, the method includes: Step 301: Obtain traffic information of business applications in multiple statistical time periods.
[0066] The statistical period can be set according to specific needs. For example, if the duration of the statistical period is 1 hour, 0:00-1:00, 1:00-2:00, 2:00-3:00, 3:00-4:00, etc. can be set as a statistical period. If the duration of the statistical period is 4 hours, 0:00-4:00, 4:00-8:00, 8:00-12:00, etc. can be set as a statistical period.
[0067] Step 302: Determine a switching period from among the multiple statistical periods according to the flow information of the multiple statistical periods.
[0068] The statistical period with the smallest flow rate may be determined as the switching period, and any statistical period with flow information less than a preset flow rate may also be determined as the switching period.
[0069] Step 303: Perform a data structure check on the target database against the source database.
[0070] Step 304: In response to the target database failing to pass the data structure verification, determining an object to be processed in the target database; generating a processing statement corresponding to the object to be processed, and executing the processing statement in the target database.
[0071] Step 305: Collect the redo logs of the source database, generate operation statements corresponding to the redo logs, and execute the operation statements in the target database.
[0072] Collect the redo logs of the source database, generate the operation statements corresponding to the redo logs, and execute the operation statements in the target database, so that the logs in the source database can be copied to the target database.
[0073] After the operation statement is executed in the target database, the current time is obtained at fixed intervals. If the current time reaches the switching period, step 306 is executed. If the current time does not reach the switching period, the incremental log of the source database is collected; the incremental data of the target database is synchronized using the incremental log. By continuously synchronizing the incremental data, the data in the target database is closer to the data in the source database.
[0074] Step 306: In response to the current time reaching the switching period, the target database is subjected to an integrity check against the source database.
[0075] Step 307: In response to the target database passing the integrity check, the business application is switched from the source database to the target database.
[0076] In the solution of the embodiment of the present invention, a switching period is determined from multiple statistical periods according to the flow information of multiple statistical periods. When the current time reaches the switching period, the target database is checked for integrity against the source database, and the business application is switched from the source database to the target database. By setting the switching period, the impact of database migration on the production system can be reduced, and the probability of database switching anomalies and the like can be reduced.
[0077] The implementation process of the solution of the embodiment of the present invention is simple and uncomplicated. The user only needs to simply deploy the execution program and open the database permissions. Compared with the components that come with the traditional database, it does not require excessive operations and does not incur additional cost consumption. Figure 4 FIG. 4 is a flow chart of a database switching method provided by a fourth embodiment of the present invention. Figure 4 As shown, the method includes: Step 01: Set the configuration information of the source database, enable the source database to flush the disk regularly according to the set log period, and enable the redo log of the source database.
[0078] Step 02: Publish the business configuration to the working node. The working node makes corresponding preparations and environment verification based on the business configuration.
[0079] Perform a data structure check on the target database against the source database. If there is any incompatibility between database objects, the user can be informed to make adjustments.
[0080] Step 03: Collect and process the redo logs of the source database.
[0081] Step 04: Parse the collected logs and generate table creation statements, batch insert statements, batch update statements, etc. for batch writing data.
[0082] Step 05: The user sets the target configuration as needed. Based on the target configuration, the target database executes the table creation statements, batch insert statements, batch update statements, etc. generated in step 04 in batches.
[0083] Figure 5 FIG. 4 is a flow chart of risk control of database switching provided by the fourth embodiment of the present invention. Figure 5 As shown, the scheme design of the embodiment of the present invention takes into account the actual production safety and provides a complete set of fault handling and response strategies to ensure that the risks during and before and after the implementation are controllable. In the evaluation stage, data volume surveys, data result evaluations, network communication evaluations, implementation platform performance evaluations, etc. are carried out to ensure the smooth progress of the migration process. In the implementation stage, plans such as trial runs that fail and data comparisons are carried out to ensure that the impact on the production system is minimal. In the verification stage, application background data switching verification, key application business process verification, stability verification, etc. are carried out to ensure that the target database after the switch can normally support various applications in the production environment.
[0084] Figure 6 FIG. 1 is a schematic diagram of a database switching device provided by an embodiment of the present invention. Figure 6 As shown, the device includes: a first verification module 601, which is used to perform a data structure verification on the target database for the source database; a first execution module 602, which is used to determine the object to be processed in the target database in response to the target database failing the data structure verification; generate a processing statement corresponding to the object to be processed, and execute the processing statement in the target database; a second execution module 603, which is used to collect the redo log of the source database, generate an operation statement corresponding to the redo log, and execute the operation statement in the target database; a second verification module 604, which is used to perform an integrity verification on the target database for the source database; an application switching module 605, which is used to switch the business application from the source database to the target database in response to the target database passing the integrity verification.
[0085] Optionally, the first verification module 601 is specifically used to: determine multiple source database objects from the source database, the source database objects including: data tables, indexes, views, users, triggers and functions; for each source database object: determine whether there is a target database object matching the source database object in the target database; in response to the presence of multiple target database objects in the target database, determine that the target database object passes the data structure verification; wherein the target database object corresponds one-to-one to the source database object.
[0086] Optionally, the second execution module 603 is specifically used to: in response to the target database not having a target database object corresponding to the current source database object, determine that the target database fails to pass the data structure verification; and determine the target database object corresponding to the current source database object as the object to be processed.
[0087] Optionally, the second execution module 603 is specifically used to: obtain definition information of the current source database object; generate a processing statement corresponding to the object to be processed according to the definition information of the current source database object; wherein the processing statement includes: a construction statement or a modification statement.
[0088] Optionally, the second verification module 604 is specifically used to: obtain traffic information of business applications in multiple statistical time periods; determine a switching period from multiple statistical time periods based on the traffic information of multiple statistical time periods; in response to the current time reaching the switching period, execute the step of performing integrity verification on the target database against the source database.
[0089] Optionally, it also includes: an incremental synchronization module, which is used to collect incremental logs of the source database; and use the incremental logs to synchronize incremental data of the target database.
[0090] Optionally, the incremental synchronization module is further used to: perform business process verification on the target database for the business application; in response to the target database failing the business process verification, switch the business application from the target database back to the source database.
[0091] An embodiment of the present invention provides an electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.
[0092] An embodiment of the present invention provides a computer program product, including a computer program. When the computer program is executed by a processor, the database switching method in the embodiment of the present invention is implemented.
[0093] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0094] like Figure 7As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0095] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0096] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0097] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0098] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0099] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, they may be described as: a file acquisition module, an information determination module, a result determination module, a filling module, and a file generation module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the file acquisition module may also be described as "a module that receives a file generation request and obtains a template file corresponding to the file generation request."
[0100] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: Verify the data structure of the target database against that of the source database; In response to the target-side database failing to pass the data structure check, determining an object to be processed in the target-side database; generating a processing statement corresponding to the object to be processed, and executing the processing statement in the target-side database; Collecting redo logs of the source database, generating operation statements corresponding to the redo logs, and executing the operation statements in the target database; Performing an integrity check on the target database against the source database; In response to the target-side database passing the integrity check, the business application is switched from the source-side database to the target-side database.
[0101] According to the technical solution of the embodiment of the present invention, the data structure of the target database is verified against the source database. If the target database fails the data structure verification, the processing statement for the object to be processed is executed in the target database so that the target database passes the data structure verification. The redo log of the source database is collected, and the redo log operation statement is executed in the target database to complete the data migration. When the target database passes the integrity verification, the business application is switched from the source database to the target database. The solution of the embodiment of the present invention can effectively improve the probability of successful database migration and ensure the normal development of the business by performing data structure verification and integrity verification on the target database.
[0102] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A database switching method, It is characterized in that include: Verify the data structure of the target database against that of the source database; In response to the target-side database failing to pass the data structure check, determining an object to be processed in the target-side database; Generate a processing statement corresponding to the object to be processed, and execute the processing statement in the target database; Collecting redo logs of the source database, generating operation statements corresponding to the redo logs, and executing the operation statements in the target database; Performing an integrity check on the target database against the source database; In response to the target-side database passing the integrity check, the business application is switched from the source-side database to the target-side database.
2. The method according to claim 1, It is characterized in that The data structure verification of the target database against the source database includes: Determine a plurality of source database objects from the source database, wherein the source database objects include: data tables, indexes, views, users, triggers, and functions; For each of the source database objects: determining whether there is a target database object matching the source database object in the target database; In response to the existence of a plurality of the target database objects in the target database, it is determined that the target database object passes the data structure verification; wherein the target database object corresponds one-to-one to the source database object.
3. The method according to claim 2, It is characterized in that After determining whether there is a target database object matching the source database object in the target database, the method further includes: In response to the target database object corresponding to the current source database object not existing in the target database, determining that the target database fails the data structure verification; The determining of the to-be-processed object in the target-side database includes: The target database object corresponding to the current source database object is determined as the object to be processed.
4. The method according to claim 3, It is characterized in that The generating a processing statement corresponding to the object to be processed includes: Obtaining definition information of the current source database object; According to the definition information of the current source database object, a processing statement corresponding to the object to be processed is generated; wherein the processing statement includes: a construction statement or a modification statement.
5. The method according to claim 1, It is characterized in that Before the target database is subjected to integrity check on the source database, the method further includes: Obtaining traffic information of the business application in multiple statistical time periods; Determine a switching period from the plurality of statistical periods according to the flow information of the plurality of statistical periods; In response to the current time reaching the switching period, the step of performing integrity verification on the target database against the source database is performed.
6. The method according to claim 5, It is characterized in that After the business application is switched from the source database to the target database, the method further includes: Collecting incremental logs of the source database; The incremental log is used to synchronize the incremental data of the target database.
7. The method according to claim 5, It is characterized in that After the business application is switched from the source database to the target database, the method further includes: Performing business process verification on the target database for the business application; In response to the target-side database failing the business process verification, the business application is switched from the target-side database back to the source-side database.
8. A database switching device, It is characterized in that include: A first verification module is used to verify the data structure of the target database against the source database; A first execution module, configured to determine an object to be processed in the target-side database in response to the target-side database failing to pass the data structure check; Generate a processing statement corresponding to the object to be processed, and execute the processing statement in the target database; A second execution module is used to collect redo logs of the source database, generate operation statements corresponding to the redo logs, and execute the operation statements in the target database; A second verification module, used to perform integrity verification on the target database against the source database; The application switching module is used to switch the business application from the source database to the target database in response to the target database passing the integrity check.
9. The device according to claim 8, It is characterized in that The first verification module is specifically used for: Determine a plurality of source database objects from the source database, wherein the source database objects include: data tables, indexes, views, users, triggers, and functions; For each of the source database objects: determining whether there is a target database object matching the source database object in the target database; In response to the existence of a plurality of the target database objects in the target database, it is determined that the target database object passes the data structure verification; wherein the target database object corresponds one-to-one to the source database object.
10. The device according to claim 9, It is characterized in that The second execution module is specifically used for: In response to the target database not having a target database object corresponding to the current source database object, determining that the target database fails data structure verification; The target database object corresponding to the current source database object is determined as the object to be processed.
11. The device according to claim 10, It is characterized in that The second execution module is specifically used for: Obtaining definition information of the current source database object; According to the definition information of the current source database object, a processing statement corresponding to the object to be processed is generated; wherein the processing statement includes: a construction statement or a modification statement.
12. The device according to claim 8, It is characterized in that The second verification module is specifically used for: Obtaining traffic information of the business application in multiple statistical time periods; Determine a switching period from the plurality of statistical periods according to the flow information of the plurality of statistical periods; In response to the current time reaching the switching period, the step of performing integrity verification on the target database against the source database is performed.
13. An electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
14. A computer readable medium having a computer program stored thereon, Features When the program is executed by a processor, the method described in any one of claims 1 to 7 is implemented.
15. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data migration system and method
CN107122360A
Database performance determination method and device, electronic equipment and storage medium
CN115269352A
Database migration method, database migration system, and database migration program
JP2021140430A
System for achieving non-interruptive data reconstruction
US20160085836A1
