Dual-write technology transformation method, device and medium based on MySQL data source
By adopting a dual-write technology based on MySQL data sources, the data source is dynamically configured and Spring AOP is used to implement dual-write operations for Oracle and MySQL. This solves the problems of large modifications and high risks when replacing Oracle, and realizes a low-cost and controllable database replacement solution, ensuring business stability and data comparison integrity.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN BANK CO LTD
- Filing Date
- 2022-11-07
- Publication Date
- 2026-07-14
AI Technical Summary
Replacing an Oracle database with an existing one involves significant modifications, high risks and costs, and cannot effectively compare changes in business data, which can easily lead to business incidents.
The approach employs a dual-write technique based on a MySQL data source. By dynamically configuring the data source, Spring AOP is used to implement dual-write or dual-read operations. The aspect logic determines the parallel verification type and implements dual-write operations for both Oracle and MySQL. The implementation of Sequence in the data source is switched, and dual-write operations for log tables and reports are controlled. Dual-read operations for dictionary tables and dual-write/read operations for temporary tables are also implemented.
It reduces the risks and costs of Oracle replacement, ensures full scenario coverage through dual-write data comparison, avoids business problems, maintains business process stability, has low code intrusion, is easy to switch, simple to clean up, has high reusability, and low cost.
Smart Images

Figure CN115630128B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information processing technology, specifically to a method for modifying MySQL data source using dual-write technology, a computer device, and a non-volatile computer-readable storage medium. Background Technology
[0002] Currently, as banking operations become increasingly sophisticated and complex, data plays an increasingly crucial role in business processing. Previously, most banks used Oracle (Oracle Database, also known as Oracle RDBMS, a relational database management system) for data storage and management. However, with the development of the industry and database technology, many shortcomings of Oracle have become apparent. Oracle is too expensive, requiring substantial licensing fees. Furthermore, Oracle's code is not open source, resulting in significant annual service fees. Moreover, some business operations are too small to require such a heavyweight database. Therefore, replacing Oracle with other solutions has become a necessary project for many companies to reduce costs.
[0003] The current technology for replacing Oracle is to modify the original business code and add new data DAO methods to the business code. This implementation scheme involves too much modification, does not comply with the open / closed principle of code development, is too risky, and cannot compare the changes in business data before and after Oracle is replaced, which can easily lead to business accidents.
[0004] Therefore, existing technologies still need to be improved and enhanced. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a method for modifying MySQL-based dual-write technology, computer equipment, and non-volatile computer-readable storage medium that can be used in financial technology or other related fields, aiming to solve the problems of large modifications, high risks, and high costs when Oracle is replaced in the prior art.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] A method for modifying MySQL data sources using dual-write technology, wherein the method includes the following steps:
[0008] S10, Dynamically configure MySQL data sources;
[0009] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0010] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0011] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0012] S50, Switching between different data sources for Sequence implementation;
[0013] S60. Enable dual writing to the log table and reports;
[0014] S70. Implement dual reading of the dictionary table;
[0015] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0016] In a further technical solution, the dual-write technology modification method based on MySQL data source, wherein in step S30, if Oracle and MySQL are verified in parallel, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic is executed to realize the dual-write operation of Oracle first and then MySQL.
[0017] In a further technical solution, the dual-write technology transformation method based on MySQL data source, in step S30, if it is a parallel verification for production, then MySQLDao is obtained through OracleDao. After obtaining MySQLDao, the corresponding Dao logic is executed, and OracleDao logic is executed at the same time, realizing the dual-write operation of MySQL first and then Oracle.
[0018] In a further technical solution, the dual-write technology transformation method based on MySQL data source, wherein in step S40, if it is a verification process of parallel verification and production parallel verification, the execution status of MySQLDao is verified; if it is a verification process of formal production, it is determined whether MySQLDao exists. If it exists, a MySQLDao instance is injected through Spring proxy; if it does not exist, OracleDao is injected.
[0019] In a further technical solution, the dual-write technology modification method based on MySQL data source includes verifying the execution status of MySQLDao, which includes loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness.
[0020] In a further technical solution, the dual-write technology transformation method based on MySQL data source, wherein in step S10, the data source is configured through an Apollo or Spring-config configuration management platform.
[0021] In a further technical solution, the dual-write technology transformation method based on MySQL data source, wherein step S60 is controlled by Aop dual-write and Apollo configuration switch.
[0022] In a further technical solution, the dual-write technology transformation method based on MySQL data source, wherein in step S70, the dictionary table synchronizes the data written to Oracle to MySQL and then reads the MySQL table through the Apollo configuration switch; and in step S80, the dual-write read to MySQL or dual-write read to Oracle is controlled through the Apollo configuration switch.
[0023] A computer device, wherein the computer device includes at least one processor; and,
[0024] A memory communicatively connected to the at least one processor; wherein,
[0025] The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, it can achieve the following:
[0026] S10, Dynamically configure MySQL data sources;
[0027] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0028] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0029] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0030] S50, Switching between different data sources for Sequence implementation;
[0031] S60. Enable dual writing to the log table and reports;
[0032] S70. Implement dual reading of the dictionary table;
[0033] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0034] In a further technical solution, in the computer device, in step S30, if Oracle and MySQL are verified in parallel, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic is executed to realize the dual write operation of Oracle first and then MySQL.
[0035] In a further technical solution, the computer equipment, in step S30, if it is a parallel verification for production, obtains MySQLDao through OracleDao, executes the corresponding Dao logic after obtaining MySQLDao, and executes OracleDao logic at the same time, realizing a dual write operation of MySQL first and then Oracle.
[0036] In a further technical solution, the computer equipment, in step S40, if it is a verification process of parallel verification and production parallel verification, then the execution status of MySQLDao is verified; if it is a formal production verification process, then it is determined whether MySQLDao exists. If it exists, then the MySQLDao instance is injected through Spring proxy; if it does not exist, then OracleDao is injected.
[0037] In a further technical solution, the computer device wherein the execution status of MySQLDao is verified includes loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness.
[0038] In a further technical solution, the computer equipment, in step S10, configures the data source through an Apollo or Spring-config configuration management platform.
[0039] In a further technical solution, the computer device, in step S60, is controlled by Aop dual writing and by the Apollo configuration switch.
[0040] In a further technical solution, the computer device, in step S70, controls the dictionary table to synchronize data written to Oracle to MySQL and then read the MySQL table through the Apollo configuration switch; in step S80, controls dual-write read to MySQL or dual-write read to Oracle through the Apollo configuration switch.
[0041] A non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, which, when executed by at least one processor, can perform:
[0042] S10, Dynamically configure MySQL data sources;
[0043] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0044] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0045] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0046] S50, Switching between different data sources for Sequence implementation;
[0047] S60. Enable dual writing to the log table and reports;
[0048] S70. Implement dual reading of the dictionary table;
[0049] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0050] In a further technical solution, the non-volatile computer-readable storage medium, wherein in step S30, if Oracle and MySQL are verified in parallel, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic is executed to achieve a dual write operation of Oracle first and then MySQL.
[0051] In a further technical solution, the non-volatile computer-readable storage medium, in step S30, if it is a parallel verification for production, obtains MySQLDao through OracleDao, executes the corresponding Dao logic after obtaining MySQLDao, and executes OracleDao logic at the same time, realizing a dual write operation of MySQL first and then Oracle.
[0052] In a further technical solution, the non-volatile computer-readable storage medium, wherein in step S40, if it is a verification process of parallel verification and production parallel verification, then the execution status of MySQLDao is verified; if it is a formal production verification process, then it is determined whether MySQLDao exists. If it exists, then the MySQLDao instance is injected through the Spring proxy; if it does not exist, then OracleDao is injected.
[0053] In a further technical solution, the non-volatile computer-readable storage medium, wherein the verification of the execution status of MySQLDao includes loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness.
[0054] In a further technical solution, the non-volatile computer-readable storage medium, wherein in step S10, the data source is configured through an Apollo or Spring-config configuration management platform.
[0055] In a further technical solution, the non-volatile computer-readable storage medium, wherein step S60 is controlled by Aop dual writing and Apollo configuration switch.
[0056] In a further technical solution, the non-volatile computer-readable storage medium, wherein in step S70, the dictionary table synchronizes the data written to Oracle to MySQL and then reads the MySQL table through the Apollo configuration switch; in step S80, the dual-write read MySQL or dual-write read Oracle is controlled through the Apollo configuration switch.
[0057] Compared to existing technologies, this invention provides a method, device, and medium for modifying dual-write technology based on a MySQL data source. The method includes: dynamically configuring the MySQL data source; adding a MySQL aspect in the DAO layer and creating an annotation to implement dual-write or dual-read operations via Spring AOP; determining the type of parallel verification in the aspect logic and implementing dual-write operations for Oracle and MySQL; determining the type of verification process in the Spring framework logic and performing operations according to the corresponding verification process type; switching different data source implementations for Sequences; implementing dual-write operations for log tables and reports; implementing dual-read operations for dictionary tables; and implementing dual-write reads of temporary tables from Oracle or dual-write reads of MySQL. This invention solves the problems of significant modifications, high risks, and high costs associated with replacing Oracle in existing technologies. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 This is a flowchart illustrating the dual-write technology modification method based on MySQL data source provided in an embodiment of the present invention.
[0060] Figure 2 This is a schematic diagram illustrating the implementation of Sequence in an embodiment of the present invention.
[0061] Figure 3 This is a schematic diagram illustrating the process of implementing dual writing of the log table according to an embodiment of the present invention.
[0062] Figure 4 This is a schematic diagram illustrating the process of implementing dual report writing in an embodiment of the present invention.
[0063] Figure 5 This is a schematic diagram illustrating the process of implementing dual reading of a dictionary table according to an embodiment of the present invention.
[0064] Figure 6 This is a flowchart illustrating the implementation of temporary table dual-write read in Oracle, as provided in an embodiment of the present invention.
[0065] Figure 7 This is a flowchart illustrating the implementation of dual-write read of a temporary table in MySQL, as provided in an embodiment of the present invention.
[0066] Figure 8 This is a schematic diagram of the hardware structure of the computer device provided in an embodiment of the present invention. Detailed Implementation
[0067] To make the objectives, technical solutions, and effects of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0068] In the description of this invention, the terms "comprising," "including," "having," and "containing" are all open-ended terms, meaning that they include but are not limited to. The terms "one embodiment," "one specific embodiment," "some embodiments," and "for example," etc., refer to specific features, structures, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. The order of steps involved in the various embodiments is used to illustrate the implementation of this application, and the order of steps is not limited and can be adjusted appropriately as needed.
[0069] Various non-limiting embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0070] Please see Figure 1This invention provides a method for modifying MySQL data source using dual-write technology, wherein the method includes the following steps:
[0071] S10, Dynamically configure MySQL data sources;
[0072] Specifically, in this embodiment, it can be implemented using other mature configuration management platforms on the market, such as Apollo or Spring-config.
[0073] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0074] Specifically, in this embodiment, dual write or dual read is implemented through Spring AOP, which ensures that all code modifications are performed within the AOP code, thus decoupling it from the actual business code.
[0075] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0076] Specifically, in this embodiment, in the aspect logic, if it is parallel verification of Oracle and MySQL, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed to achieve a dual write operation of Oracle first and then MySQL. In the aspect logic, if it is parallel verification for production deployment, the MySQLDao is obtained through the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed, and the OracleDao logic is executed at the same time to achieve a dual write operation of MySQL first and then Oracle.
[0077] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0078] Specifically, in this embodiment, within the Spring framework logic, if it is a parallel verification and production parallel verification process, the execution status of MySQLDao is verified, including loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness; if it is a formal production deployment, it is determined whether MySQLDao exists, and then a MySQLDao instance is injected through the Spring proxy; if it does not exist, OracleDao is injected.
[0079] S50, Switching between different data sources for Sequence implementation;
[0080] Specifically, in this embodiment, please refer to Figure 2Different data sources can be switched using a switch to achieve the implementation of Sequence.
[0081] S60. Enable dual writing to the log table and reports;
[0082] Specifically, in this embodiment, please refer to Figure 3 and Figure 4 The Apollp configuration switches include a write Oracle switch and a write MySQL switch. Through Aop's dual write capability and the control of the Apollo configuration switches, dual writes to log tables and reports can be achieved.
[0083] S70. Implement dual reading of the dictionary table;
[0084] Specifically, in this embodiment, please refer to Figure 5 The dictionary table synchronizes the data written to Oracle to MySQL, and then reads the MySQL table to achieve dual reads of the dictionary table.
[0085] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0086] Specifically, in this embodiment, please refer to Figure 6 and Figure 7 For some business temporary tables, that is, tables whose lifecycle is at the transaction level and do not require historical data, Apollo configuration switches can be used to control dual write-read MySQL or dual write-read Oracle, thereby achieving the purpose of primary and secondary traffic verification and rollback.
[0087] As can be seen from the above method embodiments, the dual-write technology transformation method based on MySQL data source provided by the present invention can replace Oracle. The method of the present invention has controllable risks, and the scenario coverage can be achieved through dual-write data comparison in the later stage, avoiding business problems caused by the replacement of Oracle. The changes are small and the code is minimally invasive, which can maintain the stability of the original business process code as much as possible, and only necessary modifications are required. Switching is convenient, and the switching of dual-write, primary and secondary traffic, rollback, etc. can be controlled by switches, which facilitates verification. Cleanup is convenient. After successfully replacing Oracle, the old code and temporary code are easy to clean up, and the amount of business code modification is minimal. The reusability is high and the cost is low. Multiple applications can be transformed to replace Oracle through a single code.
[0088] It should be understood that although this application provides the method operation steps as described in the embodiments or flowcharts, conventional or non-inventive labor may include more or fewer operation steps, and these operation steps are not necessarily executed sequentially in the order of the embodiments or flowcharts. The order of steps listed in the embodiments or flowcharts is merely one possible execution order among many steps and does not represent the only execution order. Moreover, at least some steps in the embodiments or flowcharts may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but may be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but may be performed alternately, concurrently, or synchronously with other steps or at least a portion of the sub-steps or stages of other steps.
[0089] Based on the above embodiments, please refer to Figure 8 Another embodiment of the present invention also provides a computer device, wherein the computer device 10 includes:
[0090] Memory 120 and one or more processors 110, Figure 8 The following description uses a processor 110 as an example. The processor 110 and the memory 120 can be connected via a communication bus or other means. Figure 8 Taking the example of China and Israel being connected via a communication bus.
[0091] Processor 110 performs various control logic functions of computer device 10. It can be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), microcontroller, ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Furthermore, processor 110 can also be any conventional processor, microprocessor, or state machine. Processor 110 can also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration.
[0092] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the computer program corresponding to the dual-write technology modification method based on the MySQL data source in this embodiment of the invention. The processor 110 executes various functional applications and data processing of the computer device 10 by running the non-volatile software programs, instructions, and units stored in the memory 120, thereby implementing the dual-write technology modification method based on the MySQL data source in the above method embodiment.
[0093] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store application programs required for operating the device and at least one function; and the data storage area may store data created based on the use of the computer device 10. Furthermore, the memory 120 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include memory remotely located relative to the processor 110, and these remote memories may be connected to the computer device 10 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0094] One or more units are stored in memory 120, and when executed by one or more processors 110, they can achieve the following:
[0095] S10, Dynamically configure MySQL data sources;
[0096] Specifically, in this embodiment, it can be implemented using other mature configuration management platforms on the market, such as Apollo or Spring-config.
[0097] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0098] Specifically, in this embodiment, dual write or dual read is implemented through Spring AOP, which ensures that all code modifications are performed within the AOP code, thus decoupling it from the actual business code.
[0099] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0100] Specifically, in this embodiment, in the aspect logic, if it is parallel verification of Oracle and MySQL, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed to achieve a dual write operation of Oracle first and then MySQL. In the aspect logic, if it is parallel verification for production deployment, the MySQLDao is obtained through the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed, and the OracleDao logic is executed at the same time to achieve a dual write operation of MySQL first and then Oracle.
[0101] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0102] Specifically, in this embodiment, within the Spring framework logic, if it is a parallel verification and production parallel verification process, the execution status of MySQLDao is verified, including loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness; if it is a formal production deployment, it is determined whether MySQLDao exists, and then a MySQLDao instance is injected through the Spring proxy; if it does not exist, OracleDao is injected.
[0103] S50, Switching between different data sources for Sequence implementation;
[0104] Specifically, in this embodiment, please refer to Figure 2 Different data sources can be switched using a switch to achieve the implementation of Sequence.
[0105] S60. Enable dual writing to the log table and reports;
[0106] Specifically, in this embodiment, please refer to Figure 3 and Figure 4 The Apollp configuration switches include a write Oracle switch and a write MySQL switch. Through Aop's dual write capability and the control of the Apollo configuration switches, dual writes to log tables and reports can be achieved.
[0107] S70. Implement dual reading of the dictionary table;
[0108] Specifically, in this embodiment, please refer to Figure 5 The dictionary table synchronizes the data written to Oracle to MySQL, and then reads the MySQL table to achieve dual reads of the dictionary table.
[0109] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0110] Specifically, in this embodiment, please refer to Figure 6 and Figure 7 For some business temporary tables, that is, tables whose lifecycle is at the transaction level and do not require historical data, Apollo configuration switches can be used to control dual write-read MySQL or dual write-read Oracle, thereby achieving the purpose of primary and secondary traffic verification and rollback.
[0111] As can be seen from the above examples of computer equipment, the computer equipment provided by this invention can replace Oracle. The risks of the computer equipment of this invention are controllable, and full scenario coverage can be achieved through dual-write data comparison in the later stage, avoiding business problems caused by the replacement of Oracle. The modifications are minor, the code is minimally invasive, and the stability of the original business process code can be maintained as much as possible, with no unnecessary modifications. Switching is convenient, and dual-write, primary and secondary traffic, rollback, etc. can be switched through a switch, which facilitates verification. Cleanup is convenient, and after successfully replacing Oracle, the old code and temporary code are easy to clean up, and the amount of business code modification is minimal. It has a high reusability and low cost, and multiple applications can be transformed to replace Oracle through a single code.
[0112] Those skilled in the art will understand that Figure 8 The hardware structure diagram shown is only a schematic diagram of a part of the structure related to the present invention and does not constitute a limitation on the computer device on which the present invention is applied. The specific computer device may include more components than shown in the figure, or combine some components, or have different component arrangements.
[0113] Based on the above embodiments, the present invention also provides a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and the computer program, when executed by at least one processor, can perform:
[0114] S10, Dynamically configure MySQL data sources;
[0115] Specifically, in this embodiment, it can be implemented using other mature configuration management platforms on the market, such as Apollo or Spring-config.
[0116] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0117] Specifically, in this embodiment, dual write or dual read is implemented through Spring AOP, which ensures that all code modifications are performed within the AOP code, thus decoupling it from the actual business code.
[0118] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0119] Specifically, in this embodiment, in the aspect logic, if it is parallel verification of Oracle and MySQL, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed to achieve a dual write operation of Oracle first and then MySQL. In the aspect logic, if it is parallel verification for production deployment, the MySQLDao is obtained through the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed, and the OracleDao logic is executed at the same time to achieve a dual write operation of MySQL first and then Oracle.
[0120] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0121] Specifically, in this embodiment, within the Spring framework logic, if it is a parallel verification and production parallel verification process, the execution status of MySQLDao is verified, including loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness; if it is a formal production deployment, it is determined whether MySQLDao exists, and then a MySQLDao instance is injected through the Spring proxy; if it does not exist, OracleDao is injected.
[0122] S50, Switching between different data sources for Sequence implementation;
[0123] Specifically, in this embodiment, please refer to Figure 2 Different data sources can be switched using a switch to achieve the implementation of Sequence.
[0124] S60. Enable dual writing to the log table and reports;
[0125] Specifically, in this embodiment, please refer to Figure 3 and Figure 4 The Apollp configuration switches include a write Oracle switch and a write MySQL switch. Through Aop's dual write capability and the control of the Apollo configuration switches, dual writes to log tables and reports can be achieved.
[0126] S70. Implement dual reading of the dictionary table;
[0127] Specifically, in this embodiment, please refer to Figure 5 The dictionary table synchronizes the data written to Oracle to MySQL, and then reads the MySQL table to achieve dual reads of the dictionary table.
[0128] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0129] Specifically, in this embodiment, please refer to Figure 6 and Figure 7 For some business temporary tables, that is, tables whose lifecycle is at the transaction level and do not require historical data, Apollo configuration switches can be used to control dual write-read MySQL or dual write-read Oracle, thereby achieving the purpose of primary and secondary traffic verification and rollback.
[0130] As can be seen from the above embodiments of non-volatile computer-readable storage media, the non-volatile computer-readable storage media provided by the present invention can replace Oracle. The risks of the non-volatile computer-readable storage media of the present invention are controllable. In the later stage, full coverage of scenarios can be achieved through dual-write data comparison, avoiding business problems caused by the replacement of Oracle. The modifications are small and the code is minimally invasive, which can maintain the stability of the original business process code as much as possible, and avoid unnecessary modifications. Switching is convenient, and dual-write, primary and secondary traffic, rollback, etc. can be switched through a switch, which is convenient for verification. Cleanup is convenient. After successfully replacing Oracle, the old code and temporary code are easy to clean up, and the amount of business code modification is minimal. It has a high reusability and low cost. Multiple applications can be transformed to replace Oracle through a single code.
[0131] As an example, non-volatile storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchronous ink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The memory components or memories disclosed in the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0132] Another embodiment of the present invention provides a computer program product comprising a computer program stored on a non-volatile computer-readable storage medium, the computer program including program instructions that, when executed by a processor, can perform:
[0133] S10, Dynamically configure MySQL data sources;
[0134] Specifically, in this embodiment, it can be implemented using other mature configuration management platforms on the market, such as Apollo or Spring-config.
[0135] S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP;
[0136] Specifically, in this embodiment, dual write or dual read is implemented through Spring AOP, which ensures that all code modifications are performed within the AOP code, thus decoupling it from the actual business code.
[0137] S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL;
[0138] Specifically, in this embodiment, in the aspect logic, if it is parallel verification of Oracle and MySQL, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed to achieve a dual write operation of Oracle first and then MySQL. In the aspect logic, if it is parallel verification for production deployment, the MySQLDao is obtained through the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic can be executed, and the OracleDao logic is executed at the same time to achieve a dual write operation of MySQL first and then Oracle.
[0139] S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type;
[0140] Specifically, in this embodiment, within the Spring framework logic, if it is a parallel verification and production parallel verification process, the execution status of MySQLDao is verified, including loading omission alarms, total loaded data verification, and gray-scale environment verification of correctness; if it is a formal production deployment, it is determined whether MySQLDao exists, and then a MySQLDao instance is injected through the Spring proxy; if it does not exist, OracleDao is injected.
[0141] S50, Switching between different data sources for Sequence implementation;
[0142] Specifically, in this embodiment, please refer to Figure 2 Different data sources can be switched using a switch to achieve the implementation of Sequence.
[0143] S60. Enable dual writing to the log table and reports;
[0144] Specifically, in this embodiment, please refer to Figure 3 and Figure 4 The Apollp configuration switches include a write Oracle switch and a write MySQL switch. Through Aop's dual write capability and the control of the Apollo configuration switches, dual writes to log tables and reports can be achieved.
[0145] S70. Implement dual reading of the dictionary table;
[0146] Specifically, in this embodiment, please refer to Figure 5 The dictionary table synchronizes the data written to Oracle to MySQL, and then reads the MySQL table to achieve dual reads of the dictionary table.
[0147] S80. Implement dual-write reads on temporary tables in Oracle or MySQL.
[0148] Specifically, in this embodiment, please refer to Figure 6 and Figure 7 For some business temporary tables, that is, tables whose lifecycle is at the transaction level and do not require historical data, Apollo configuration switches can be used to control dual write-read MySQL or dual write-read Oracle, thereby achieving the purpose of primary and secondary traffic verification and rollback.
[0149] As can be seen from the above examples of computer program products, the computer program product provided by this invention can replace Oracle. The risks of the computer program product of this invention are controllable. In the later stage, full coverage of scenarios can be achieved through dual-write data comparison, avoiding business problems caused by the replacement of Oracle. The modifications are small and the code is minimally invasive, which can maintain the stability of the original business process code as much as possible, and only necessary modifications are required. Switching is convenient, and dual-write, primary and secondary traffic, rollback, etc. can be switched through a switch, which facilitates verification. Cleanup is convenient. After successfully replacing Oracle, the old code and temporary code are easy to clean up, and the amount of business code modification is minimal. It has a high reusability and low cost. Multiple applications can be transformed to replace Oracle through a single code.
[0150] The embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0151] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general-purpose hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can exist in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0152] Among other things, conditional language such as “can,” “may,” “may,” or “may,” unless otherwise specifically stated or otherwise understood as in the context in which they are used, is generally intended to convey that a particular implementation may include (but not others) certain features, elements, and / or operations. Therefore, such conditional language is also generally intended to imply that features, elements, and / or operations are necessary for one or more implementations in any way, or that one or more implementations must include logic for determining, with or without input or prompting, whether such features, elements, and / or operations are included or will be performed in any particular implementation.
[0153] The contents already described herein in this specification and accompanying drawings include examples of methods for modifying MySQL data sources using dual-write technology, computer devices, and non-volatile computer-readable storage media. It is certainly not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of this disclosure, but it will be appreciated that many other combinations and substitutions of the disclosed features are possible. Therefore, it will be apparent that various modifications can be made to this disclosure without departing from the scope or spirit of this disclosure, but all such various modifications should fall within the scope of the appended claims. Furthermore, or in alternatives, other embodiments of this disclosure may become apparent from consideration of this specification and accompanying drawings and from practice of this disclosure as presented herein. It is intended that the examples presented in this specification and accompanying drawings be considered illustrative rather than restrictive in all respects. Although specific terminology is used herein, it is used in a general and descriptive sense and is not intended for limiting purposes.
Claims
1. A method for modifying MySQL data source using dual-write technology, characterized in that, The method includes the following steps: S10, Dynamically configure MySQL data sources; S20. Add a MySQL aspect to the Dao layer and create an annotation to implement dual write or dual read operations through Spring AOP; S30. Determine the type of parallel verification in the aspect logic and implement dual write operations for Oracle and MySQL; S40. In the Spring framework logic, determine the type of the verification process and perform operations according to the corresponding verification process type; S50, Switching between different data sources for Sequence implementation; S60. Enable dual writing to the log table and reports; S70. Implement dual reading of the dictionary table; S80. Implement dual-write read / write operations on temporary tables in Oracle or MySQL. In step S20, a MySQL aspect is added to the Dao layer, and an annotation is created to implement dual write or dual read through Spring AOP, ensuring that all code modifications are made in the AOP code and decoupled from the actual business code; In step S30, if Oracle and MySQL are verified in parallel, the OracleDao logic is executed, and then the MySQLDao is obtained based on the OracleDao. After obtaining the MySQLDao, the corresponding Dao logic is executed to achieve the dual write operation of Oracle first and then MySQL. In step S30, if it is a parallel verification for production, the MySQLDao is obtained through OracleDao. After obtaining the MySQLDao, the corresponding Dao logic is executed, and the OracleDao logic is executed at the same time to realize the dual write operation of MySQL first and then Oracle. In step S60, all operations are controlled by Aop dual-write and Apollo configuration switches, which include write Oracle switch and write MySQL switch.
2. The method for modifying MySQL data source based on dual-write technology according to claim 1, characterized in that, In step S40, if it is a verification process of parallel verification and production parallel verification, the execution status of MySQLDao is verified; if it is a verification process of formal production, it is determined whether MySQLDao exists. If it exists, the MySQLDao instance is injected through Spring proxy; if it does not exist, OracleDao is injected.
3. The method for modifying MySQL data source based on dual-write technology according to claim 2, characterized in that, Verification of MySQLDao's execution includes checking for missing load alerts, verifying total loaded data, and verifying correctness in a gray-scale environment.
4. The method for modifying MySQL data source based on dual-write technology according to claim 1, characterized in that, In step S10, the data source is configured through the Apollo or Spring-config configuration management platform.
5. The method for modifying MySQL data source based on dual-write technology according to claim 1, characterized in that, In step S70, the dictionary table synchronizes the data written to Oracle to MySQL and then reads the MySQL table through the Apollo configuration switch; in step S80, the Apollo configuration switch controls the dual-write read to MySQL or dual-write read to Oracle.
6. A computer device, characterized in that, The computer device includes at least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. When the computer program is executed by the at least one processor, it can implement the dual-write technology modification method based on the MySQL data source as described in any one of claims 1-5.
7. A non-volatile computer-readable storage medium, characterized in that, The non-volatile computer-readable storage medium stores a computer program, which, when executed by at least one processor, can implement the dual-write technology modification method based on a MySQL data source as described in any one of claims 1-5.