Universal database flow cutting method and device in service scene
By judging the flow cut conditions and order during the database migration process, combining data snapshots and traffic management, smooth migration and transaction flow cut of the database are achieved, solving the problems of insufficient pilot scope control and insufficient integrity in the existing technology, ensuring that the migration and flow cut process is unaware of by customers.
Patent Information
- Application Number
- CN202410526562.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2025-07-29
AI Technical Summary
In the existing technology, the pilot scope control power is insufficient during the database migration process, and data migration and application flow cutting are discussed separately, which is insufficient integrity, resulting in database migration and transaction flow cutting affecting customer use.
It provides a general database flow cutting method in business scenarios. By judging whether the source database and multiple target databases meet the preset flow cutting conditions, the data is switched to the target database in the preset flow cutting order, including creating a data snapshot, reading the traffic flow rate based on the current data of the target database, and switching data according to the flow cutting order and traffic ratio, and classifying management is carried out in combination with the customer's area.
It realizes the completion of database migration and transaction flow cutting in batches within the limited production time window, ensuring unsensed smooth migration and smooth flow cutting in customers, and reducing the impact through emergency back-cutting plans when encountering problems.
Smart Images

Figure CN120386775A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of databases, and particularly relates to a general-purpose database cutover method and device in a business scenario. Background Art
[0002] At present, with the increasingly complex architecture of scientific and technological information systems, the significant increase in transaction links, and the increasingly complex business scenario logic rules, the upgrade and migration of databases in each application system have become a major problem. Therefore, it is an extremely difficult task for a large-scale system to complete the migration work without affecting customer use. Moreover, in case of problems during the migration process, the imperfect emergency plan will also lead to system problems and affect customer use.
[0003] Specifically, the database cutover methods in the existing technologies have the following deficiencies:
[0004] 1. The scope of the pilot is single, and the control over the pilot scope is insufficient.
[0005] 2. Data migration and application cutover are discussed separately, lacking integrity.
[0006] Considering the above problems comprehensively, there is an urgent need for a general-purpose database migration and cutover method applicable to business scenarios. Summary of the Invention
[0007] The present invention can be used in the technical field of database technology applications in the financial aspect, and can also be used in any field other than the financial field.
[0008] One object of the present invention is to provide a general-purpose database cutover method in a business scenario, which can complete the smooth migration of the database and the stable cutover of transactions without being noticed by customers.
[0009] Another object of the present invention is to provide a general-purpose database cutover device in a business scenario. Still another object of the present invention is to provide an electronic device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned general-purpose database cutover method in a business scenario are implemented. Still another object of the present invention is to provide a readable medium, on which a computer program is stored, and when the computer program is executed by the processor, the steps of the above-mentioned general-purpose database cutover method in a business scenario are implemented.
[0010] To solve the technical problems in the background art of this application, the present invention provides the following technical solutions:
[0011] In the first aspect, the present invention provides a general-purpose database cutover method in a business scenario, including:
[0012] In response to the received database cutover request, determine whether the source database and multiple target databases meet the preset cutover conditions; wherein, the cutover conditions include the read data judgment condition for the source database and the write data judgment condition for the multiple target databases;
[0013] When the source database and the multiple target databases meet the preset cutover conditions, switch the data of the source database to the multiple target databases according to the preset cutover order.
[0014] In some embodiments of the present invention, the switching of the data of the source database to the multiple target databases according to the preset cutover order includes:
[0015] Create a snapshot of the data of the source database; wherein, the snapshot is a snapshot of the full amount of data in the source database;
[0016] Switch the snapshot to the multiple target databases according to the preset cutover order.
[0017] In some embodiments of the present invention, the switching of the snapshot to the multiple target databases according to the preset cutover order includes:
[0018] Select at least one target database according to the current data read traffic of the multiple target databases;
[0019] Generate a traffic ratio according to the current data read traffic of the selected target databases;
[0020] Switch the snapshot to the selected target databases according to the cutover order and the traffic ratio.
[0021] In some embodiments of the present invention, the read data judgment condition includes:
[0022] The relationship between the failure rate in the previous database cutover result of the source database and the first threshold.
[0023] In some embodiments of the present invention, the write data judgment condition includes:
[0024] The relationship between the failure rate in the previous database cutover result of each target database and the second threshold.
[0025] In some embodiments of the present invention, a general database cutover method in a business scenario further includes:
[0026] Classify the data in the source database in the business scenario according to the regions to which the customers belong to generate a classification result.
[0027] In some embodiments of the present invention, the step of switching the data of the source database to the multiple target databases according to a preset cut-off flow order further includes:
[0028] Selecting the data corresponding to the customers in at least one region for switching; wherein, the number of categories of regional customers selected is less than the number of categories of regional customers in the classification result;
[0029] When the data corresponding to the customers in the at least one selected region is switched normally, selecting the data corresponding to the customers in the next region for switching;
[0030] Putting the data of the customers corresponding to the normal data switching into a normal list for use in the next database cut-off flow.
[0031] In some embodiments of the present invention, after selecting the data corresponding to the customers in at least one region for switching, it further includes:
[0032] When the data corresponding to the customers in the at least one selected region is switched abnormally, putting the data of the customers corresponding to the abnormal data switching into an abnormal list for use in the next database cut-off flow.
[0033] In a second aspect, the present invention provides a general-purpose database cut-off flow device in a business scenario, and the device includes:
[0034] A cut-off flow condition judgment module, configured to judge whether the source database and multiple target databases meet the preset cut-off flow conditions in response to a received database cut-off flow request; wherein, the cut-off flow conditions include a read data judgment condition for the source database and a write data judgment condition for the multiple target databases;
[0035] A database cut-off flow module, configured to switch the data of the source database to the multiple target databases according to a preset cut-off flow order when the source database and the multiple target databases meet the preset cut-off flow conditions.
[0036] In some embodiments of the present invention, the database cut-off flow module includes:
[0037] A snapshot creation unit, configured to create a snapshot of the data of the source database; wherein, the snapshot is a snapshot of the full amount of data in the source database;
[0038] A snapshot switching unit, configured to switch the snapshot to the multiple target databases according to a preset cut-off flow order.
[0039] In some embodiments of the present invention, the snapshot switching unit includes:
[0040] A target database selection unit, configured to select at least one target database according to the current data reading traffic of the multiple target databases;
[0041] A traffic ratio generation unit, configured to generate a traffic ratio according to the current data reading traffic of the selected target database;
[0042] A snapshot switching subunit, configured to switch the snapshot to the selected target database according to the flow cutover order and the traffic ratio.
[0043] In some embodiments of the present invention, the read data judgment condition includes:
[0044] The relationship between the failure rate in the previous database flow cutover result of the source database and the first threshold.
[0045] In some embodiments of the present invention, the write data judgment condition includes:
[0046] The relationship between the failure rate in the previous database flow cutover result of each target database and the second threshold.
[0047] In some embodiments of the present invention, a general-purpose database flow cutover device in a business scenario further includes:
[0048] A classification result generation module, configured to classify the data in the source database in the business scenario according to the region to which the customers belong to generate a classification result.
[0049] In some embodiments of the present invention, the database flow cutover module further includes:
[0050] A region selection unit, configured to select the data corresponding to the customers in at least one region for switching; wherein, the number of categories of the customers in the selected region is less than the number of categories of the customers in the region in the classification result;
[0051] A next region selection unit, configured to, when the data corresponding to the customers in the selected at least one region is switched normally, select the data corresponding to the customers in the next region for switching;
[0052] A normal list generation unit, configured to put the data of the customers corresponding to the normal data switching into the normal list for use in the next database flow cutover.
[0053] In some embodiments of the present invention, the database flow cutover module further includes:
[0054] An abnormal list selection unit, configured to, when the data corresponding to the customers in the selected at least one region is switched abnormally, put the data of the customers corresponding to the abnormal data switching into the abnormal list for use in the next database flow cutover.
[0055] In a third aspect, the present invention provides a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of a general database cutover method in a business scenario are implemented.
[0056] In a fourth aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps of a general database cutover method in a business scenario are implemented.
[0057] In a fifth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of a general database cutover method in a business scenario are implemented.
[0058] As can be seen from the above description, the embodiments of the present invention provide a general database cutover method and device in a business scenario. The corresponding method includes: First, in response to a received database cutover request, it is determined whether the source database and multiple target databases meet a preset cutover condition; wherein, the cutover condition includes a read data judgment condition for the source database and a write data judgment condition for the multiple target databases; when it is determined that the source database and the multiple target databases meet the preset cutover condition, the data of the source database is switched to the multiple target databases according to a preset cutover order.
[0059] The general database cutover method and device in a business scenario provided by the present invention can batch complete database migration and transaction cutover within a limited production time window, and can complete database smooth migration and transaction stable cutover without being noticed by customers. In addition, in addition to providing a general database migration and transaction cutover method, the present invention can also urgently avoid risks through an emergency rollback plan when problems occur during migration and cutover, reducing the impact on customers. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0061] Figure 1 Flow schematic of a general database cutover method in a business scenario in the embodiments of the present invention Figure 1 ;
[0062] Figure 2Flow schematic of step 200 of a general-purpose database cutover method in a business scenario in an embodiment of the present invention Figure 1 ;
[0063] Figure 3 Flow schematic diagram of step 202 of a general-purpose database cutover method in a business scenario in an embodiment of the present invention;
[0064] Figure 4 Flow schematic of a general-purpose database cutover method in a business scenario in an embodiment of the present invention Figure 2 ;
[0065] Figure 5 Flow schematic of step 200 of a general-purpose database cutover method in a business scenario in an embodiment of the present invention Figure 2 ;
[0066] Figure 6 Flow schematic of step 200 of a general-purpose database cutover method in a business scenario in an embodiment of the present invention Figure 3 ;
[0067] Figure 7 Flow schematic of a general-purpose database cutover method in a business scenario in an embodiment of the present invention Figure 3 ;
[0068] Figure 8 Block diagram of a general-purpose database cutover system in a business scenario in a specific embodiment of the present invention;
[0069] Figure 9 Flow schematic diagram of a general-purpose database cutover method in a business scenario in a specific embodiment of the present invention;
[0070] Figure 10 Structural schematic of a general-purpose database cutover device in a business scenario in an embodiment of the present invention Figure 1 ;
[0071] Figure 11 Block of database cutover module 20 in an embodiment of the present invention Figure 1 ;
[0072] Figure 12 Block diagram of snapshot switching unit 20b in an embodiment of the present invention;
[0073] Figure 13 Structural schematic of a general-purpose database cutover device in a business scenario in an embodiment of the present invention Figure 2 ;
[0074] Figure 14For the block diagram of the database cut-over module 20 in the embodiments of the present invention Figure 2 ;
[0075] Figure 15 For the block diagram of the database cut-over module 20 in the embodiments of the present invention Figure 3 ;
[0076] Figure 16 The figure is a schematic structural diagram of an electronic device in the embodiments of the present invention. Detailed implementation manners
[0077] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0078] Those skilled in the art should understand that the embodiments of the present invention may be provided as a method, a system, or a computer program product. Therefore, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0079] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above accompanying drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices. Without conflict, the embodiments in this application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the drawings and in combination with the embodiments.
[0080] The acquisition, storage, use, processing, etc. of data in the technical solutions of this application all comply with the relevant regulations of laws and regulations. Specifically:
[0081] The information collected in the technical solution of this application is information and data authorized by the user or fully authorized by all parties. Moreover, for the processing of relevant data such as collection, storage, use, processing, transmission, provision, disclosure, and application, all comply with the relevant laws, regulations, and standards of the relevant countries and regions, necessary confidentiality measures are taken, it does not violate public order and good customs, and a corresponding operation entry is provided for users to choose to authorize or reject.
[0082] Provide a corresponding operation entry for users to choose to agree or reject the automated decision-making result; if the user chooses to reject, then enter the expert decision-making process.
[0083] An embodiment of the present invention provides a specific implementation manner of a general-purpose database traffic switching method in a service scenario. Refer to Figure 1 , and the method specifically includes the following contents:
[0084] Step 100: In response to the received database traffic switching request, determine whether the source database and multiple target databases meet the preset traffic switching conditions; wherein, the traffic switching conditions include the read data judgment condition for the source database and the write data judgment condition for the multiple target databases;
[0085] Step 200: When the source database and the multiple target databases meet the preset traffic switching conditions, switch the data of the source database to the multiple target databases according to the preset traffic switching order.
[0086] As can be seen from the above description, an embodiment of the present invention provides a general-purpose database traffic switching method in a service scenario, including: First, in response to the received database traffic switching request, determine whether the source database and multiple target databases meet the preset traffic switching conditions; wherein, the traffic switching conditions include the read data judgment condition for the source database and the write data judgment condition for the multiple target databases; when the source database and the multiple target databases meet the preset traffic switching conditions, switch the data of the source database to the multiple target databases according to the preset traffic switching order.
[0087] The general-purpose database traffic switching method provided by the present invention can batch complete database migration and transaction traffic switching within a limited production time window, and can complete database smooth migration and transaction stable traffic switching without the user noticing. In addition, in addition to providing a general database migration and transaction traffic switching method, the present invention can also urgently avoid risks through an emergency rollback plan in case of problems during the migration and traffic switching process, reducing the impact on customers.
[0088] Regarding step 100, database traffic switching refers to the process of performing traffic or connection switching in a database system. This operation is often carried out in scenarios such as load balancing, failover, maintenance operations, or database migration.
[0089] Specifically, in a business transaction scenario, first, determine the tables, indexes, and serial numbers to be migrated in the source database. Then, create a script based on the objects of the tables, indexes, and serial numbers to be migrated, export the script, and execute the script in the target database.
[0090] Step 200 determines the cutover order from several dimensions such as customers (compliant customers and non-compliant customers), regions, and scopes. The advantage of this method is that it can effectively reduce the production implementation risks brought by database cutover.
[0091] In some embodiments of the present invention, refer to Figure 2 , switching the data of the source database to the multiple target databases according to the preset cutover order in step 200 includes:
[0092] Step 201: Create a snapshot of the data in the source database; wherein, the snapshot is a snapshot of the full amount of data in the source database;
[0093] Specifically, implement listening to the log information in the source database. When the log information changes, determine the changed fields (including the changed fields themselves and the fields associated with the changed fields) from the fields in the log information, generate a data snapshot of the changed fields through a database tool, and store it in a previously pre-generated snapshot repository.
[0094] Step 202: Switch the snapshot to the multiple target databases according to the preset cutover order.
[0095] In some embodiments of the present invention, refer to Figure 3 , step 202 includes:
[0096] Step 2021: Select at least one target database according to the current data read traffic of the multiple target databases;
[0097] Since database cutover needs to write the data in the source database to the target databases, it is necessary to consider the current data read traffic of each target database during the writing process. Preferably, when the current data read traffic of the target database is less than a preset threshold, it can be used as the selected target database.
[0098] Step 2022: Generate a traffic ratio according to the current data read traffic of the selected target database;
[0099] Specifically, determine the data traffic that should be allocated to each target database according to the current data read traffic of each selected target database and the total data flow of the source database, so as to generate a traffic ratio.
[0100] Step 2023: Switch the snapshot to the selected target database according to the cut flow order and the flow rate ratio.
[0101] In some embodiments of the present invention, the read data judgment conditions include:
[0102] The relationship between the failure rate in the previous database cut flow result of the source database and the first threshold.
[0103] It can be understood that there may be multiple source databases. In this case, selecting the source database with a lower failure rate in the previous database cut flow result is more beneficial for the current round of database cut flow.
[0104] In some embodiments of the present invention, the write data judgment conditions include:
[0105] The relationship between the failure rate in the previous database cut flow result of each target database and the second threshold.
[0106] It can be understood that selecting the target database with a lower failure rate in the previous database cut flow result is more beneficial for the current round of database cut flow.
[0107] In some embodiments of the present invention, referring to Figure 4 , a general database cut flow method in a business scenario further includes:
[0108] Step 300: Classify the data in the source database in the business scenario according to the regions where the customers belong to generate a classification result.
[0109] It can be understood that the data types corresponding to different customers also have different reactions during the database cut flow process. Thus, the scope of pilot customers can be selected, that is, typical key customers are selected for piloting, and the corresponding database cut flow effective time is set.
[0110] In some embodiments of the present invention, referring to Figure 5 , in step 200, switching the data of the source database to the multiple target databases according to the preset cut flow order further includes:
[0111] Step 203: Select the data corresponding to the customers in at least one region for switching; wherein, the number of categories of the regional customers selected is less than the number of categories of the regional customers in the classification result;
[0112] Step 204: When the data corresponding to the customers in the at least one selected region is switched normally, select the data corresponding to the customers in the next region for switching;
[0113] Step 205: Put the data of the customers corresponding to the normal data switch into the normal list for use in the next database cutover.
[0114] It can be understood that during the next database cutover, the data of the corresponding customers can be preferentially selected from the normal list for database cutover.
[0115] In some embodiments of the present invention, refer to Figure 6 , step 200 of switching the data of the source database to the multiple target databases according to the preset cutover order further includes:
[0116] Step 206: When the data corresponding to the customers in at least one selected region is switched abnormally, put the data of the customers corresponding to the abnormal data switch into the abnormal list for use in the next database cutover.
[0117] It can be understood that during the next database cutover, the data of the corresponding customers can be preferentially excluded from the abnormal list for database cutover. After the application of the problem-solving version is released, the database cutover can be performed again.
[0118] In some embodiments of the present invention, refer to Figure 7 , a general database cutover method in a business scenario further includes:
[0119] Step 400: Verify the database cutover result. Step 400 includes:
[0120] Randomly select at least two customer data in the source database, and establish the ASCII mapping relationship of these two customer data according to the mapping function. After all the data in the source database is cut over to the target database, calculate according to this mapping relationship and any one of the ASCII of the two customer data. If the ASCII of the other customer data can be calculated, it can prove that the database cutover result is correct.
[0121] As can be seen from the above description, the embodiments of the present invention provide a general database cutover method in a business scenario, including: First, in response to the received database cutover request, determine whether the source database and the multiple target databases meet the preset cutover conditions; wherein, the cutover conditions include the read data judgment condition for the source database and the write data judgment condition for the multiple target databases; when it is determined that the source database and the multiple target databases meet the preset cutover conditions, switch the data of the source database to the multiple target databases according to the preset cutover order.
[0122] A general-purpose database cutover method in a service scenario provided by an embodiment of the present invention can first improve the stability of production cutover. In addition, this method controls the pilot scope in the combination dimension of customers, regions, whitelists, and blacklists, effectively reducing the risk of production implementation.
[0123] To further illustrate the solution, the present invention also provides a specific implementation manner of a general-purpose database cutover method in a service scenario, which specifically includes the following content.
[0124] First, refer to Figure 8 , the present invention provides a general-purpose database cutover system in a service scenario. The system includes: a data synchronization server, a source database, a target database, a batch server, and an online application server. In Figure 8 , the batch server is used to complete the migration of stock data, and the data synchronization server is used to complete the real-time synchronization of incremental data. The two parts complete the overall data migration process; the batch server is also used for the batch data filling process, and the online server is used for application cutover.
[0125] Next, the batch server further includes: a database synchronization module, a batch data filling module, and an online application cutover module. Specifically:
[0126] Database synchronization module: For a transaction scenario, confirm the tables, indexes, serial numbers, etc. that need to be migrated in the database, export the creation scripts of relevant data objects in the source database, and then execute them in the target database.
[0127] Preferably, the data migration adopts the method of stock + increment. For the migration of stock data, a data export program is deployed in the batch server to export the data of relevant tables to generate data files, and then a corresponding import program is deployed to import the data files into the target database. Thus, the migration of stock data is completed. The incremental online real-time synchronization is completed by the data synchronization server. For the incremental data of relevant tables, a real-time push thread is deployed to push it to the data synchronization server, and a data pull program is deployed in the target database to pull data from the data synchronization server in real time. It can be understood that through the data synchronization method of stock + increment, the consistency of data required for the transaction scenario can be guaranteed.
[0128] Batch data filling module: In case of failure of incremental synchronization, a batch data filling method is deployed to fill in data at the early morning of the next day. An incremental data export program for relevant tables is deployed in the batch server. For example, all data added on T-1 day is exported to a data file at the early morning of T day, and then a data incremental import program is deployed to import the T-1 day data file into the target database to achieve the effect of batch data filling.
[0129] Online application cutover module: After the data migration is completed, in order to prevent various unknown problems in the target database, the cutover pilot scope is strictly controlled in the application cutover module (connect to the target database within the scope).
[0130] Based on the general database cutover system in the above-mentioned business scenario, see Figure 9 , the specific implementation of the general database cutover method provided by the present invention includes the following steps:
[0131] It should be noted that all transaction scenarios in the following steps are used as dimensions to split the migration plan, sort out relevant database objects such as tables, indexes, and serial numbers in the transaction scenarios, and migrate them in batches according to the transaction scenario dimension. And the following steps are illustrated by taking a single transaction scenario as an example.
[0132] S1: Initially set switch_value to 0 (fully closed).
[0133] See Table 1. Set the switch table TRADE_SWITCH in the source database, which contains the following fields:
[0134] 1) Transaction scenario name trade_name (primary key);
[0135] 2) Total switch value switch_value (0: fully closed; 1: pilot according to region or customer number; 2: fully open);
[0136] 3) Pilot region switch_area;
[0137] 4) Pilot customer switch_group;
[0138] 5) Effective time of pilot region area_date;
[0139] 6) Effective time of pilot customer group_date;
[0140] 7) Customer exception list black.
[0141] Table 1
[0142]
[0143] On the day of system production upgrade, the switch_value is default set to 0. When the switch is fully closed, the online application server still connects to the source database. After confirming that the data migration is normal, the subsequent cutover plan will start. After the data migration is normal, go to step S2.
[0144] S2: Set switch_value to 1.
[0145] When piloting in the customer dimension or regional dimension, go to step S3.
[0146] S3: Set the pilot customers through switch_group and synchronously set the effective time group_date.
[0147] At this time, the customers in switch_group connect to the target database after logging in to the system. If an exception occurs in the transaction, go to step S1. If the transaction is normal for a period of time, go to step S4.
[0148] S4: Expand the scope of pilot customers in switch_group and select typical key customers for piloting.
[0149] Set the corresponding effective time group_date. If an exception occurs in the transaction of a customer, go to step S5. If the transaction is normal for a period of time, go to step S6.
[0150] S5: Remove the problem customers from switch_group and go to step S4 after the problem is resolved in the release.
[0151] S6: Set the pilot region through switch_area and synchronously set the effective time area_date. At this time, all customers in the regions in switch_area connect to the target database after logging in to the system. If an exception occurs in the transaction, go to step S1. If the transaction is normal for a period of time, go to step S7.
[0152] S7: Expand the scope of pilot customers in switch_area and select typical key regions for piloting.
[0153] Set the corresponding effective time area_date. If an exception occurs in the transaction of a region, go to step S8. If the transaction is normal for a period of time, go to step S9.
[0154] S8: Remove the problem regions from switch_area and go to step S7 after the problem is resolved in the release.
[0155] S9: Set switch_value to 2 for full open. If an exception occurs in the transaction of some customers, go to step S10. If the transaction is normal for a period of time, go to step S11.
[0156] S10: Record the problem customer numbers in the black field. The customers in the blacklist always access the source database. After the problem is solved, remove the customers from black and go to step S9.
[0157] S11: Complete the cutover migration of the trading scenario through trade_name.
[0158] As can be seen from the above description, a general-purpose database cutover method in a business scenario provided by the specific implementation manner of the present invention includes: First, in response to a received database cutover request, it is determined whether the source database and multiple target databases meet preset cutover conditions; wherein, the cutover conditions include a read data judgment condition for the source database and a write data judgment condition for the multiple target databases; when it is determined that the source database and the multiple target databases meet the preset cutover conditions, the data of the source database is switched to the multiple target databases according to a preset cutover order.
[0159] The general-purpose database cutover method in a business scenario provided by the specific implementation manner of the present invention can batch complete database migration and transaction cutover within a limited production time window, and can smoothly migrate the database and stably cut over the transaction without the customer noticing. In addition, in addition to providing a general database migration and transaction cutover method, the present invention can also urgently avoid risks through an emergency rollback plan after problems occur during the migration and cutover process, reducing the impact on customers.
[0160] Based on the same inventive concept, the embodiment of the present application also provides a general-purpose database cutover device in a business scenario, which can be used to implement the method described in the above embodiment, as in the following embodiment. Since the principle of the general-purpose database cutover device in a business scenario for solving problems is similar to that of the general-purpose database cutover method in a business scenario, the implementation of the general-purpose database cutover device in a business scenario can refer to the implementation of the general-purpose database cutover method in a business scenario, and the repeated parts will not be described again. As used hereinafter, the term "unit" or "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the systems described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0161] The embodiment of the present invention provides a specific implementation manner of a general-purpose database cutover device in a business scenario that can implement the general-purpose database cutover method in a business scenario. Refer to Figure 10 , a general-purpose database cutover device in a business scenario specifically includes the following content:
[0162] A cutover condition judgment module 10, configured to, in response to a received database cutover request, determine whether a source database and multiple target databases meet preset cutover conditions; wherein, the cutover conditions include a read data judgment condition for the source database and a write data judgment condition for the multiple target databases;
[0163] A database cutover module 20, configured to, when the source database and the multiple target databases meet the preset cutover conditions, switch the data of the source database to the multiple target databases according to a preset cutover order.
[0164] In some embodiments of the present invention, referring to Figure 11 , the database traffic switching module 20 includes:
[0165] A snapshot creation unit 20a, configured to create a snapshot of the data of the source database; wherein, the snapshot is a snapshot of all the data in the source database;
[0166] A snapshot switching unit 20b, configured to switch the snapshot to the multiple target databases according to a preset traffic switching order.
[0167] In some embodiments of the present invention, referring to Figure 12 , the snapshot switching unit 20b includes:
[0168] A target database selection unit 20b1, configured to select at least one target database according to the current data reading traffic of the multiple target databases;
[0169] A traffic ratio generation unit 20b2, configured to generate a traffic ratio according to the current data reading traffic of the selected target databases;
[0170] A snapshot switching subunit 20b3, configured to switch the snapshot to the selected target databases according to the traffic switching order and the traffic ratio.
[0171] In some embodiments of the present invention, the read data judgment condition includes:
[0172] The relationship between the failure rate in the previous database traffic switching result of the source database and a first threshold.
[0173] In some embodiments of the present invention, the write data judgment condition includes:
[0174] The relationship between the failure rate in the previous database traffic switching result of each target database and a second threshold.
[0175] In some embodiments of the present invention, referring to Figure 13 , a general-purpose database traffic switching device in a business scenario further includes:
[0176] A classification result generation module 30, configured to classify the data in the source database in the business scenario according to the regions to which the customers belong to generate a classification result.
[0177] In some embodiments of the present invention, referring to Figure 14 , the database traffic switching module 20 further includes:
[0178] A region selection unit 20c is configured to select data corresponding to customers in at least one region for switching; wherein, the number of categories of regional customers selected is less than the number of categories of regional customers in the classification result;
[0179] A next region selection unit 20d is configured to, when the data corresponding to the customers in the at least one selected region is switched normally, select data corresponding to the customers in the next region for switching;
[0180] A normal list generation unit 20e is configured to put the data of the customers corresponding to normal data switching into a normal list for use in the next database cutover.
[0181] In some embodiments of the present invention, refer to Figure 15 , the database cutover module 20 further includes:
[0182] An abnormal list selection unit 20f is configured to, when the data corresponding to the customers in the at least one selected region is switched abnormally, put the data of the customers corresponding to the abnormal data switching into an abnormal list for use in the next database cutover.
[0183] As can be seen from the above description, the embodiments of the present invention provide a general-purpose database cutover device in a service scenario, including: a cutover condition judgment module, configured to, in response to a received database cutover request, judge whether a source database and multiple target databases meet a preset cutover condition; wherein, the cutover condition includes a read data judgment condition for the source database and a write data judgment condition for the multiple target databases; a database cutover module, configured to, when the source database and the multiple target databases meet the preset cutover condition, switch the data of the source database to the multiple target databases according to a preset cutover order.
[0184] The general-purpose database cutover device in a service scenario provided by the present invention can complete database migration and transaction cutover in batches within a limited production time window, and can complete smooth database migration and stable transaction cutover without customers noticing. In addition, in addition to providing a general database migration and transaction cutover method, the present invention can also urgently avoid risks through an emergency rollback plan when problems occur during the migration and cutover process, reducing the impact on customers.
[0185] It should be noted that the general-purpose database cutover method and device in a service scenario provided by the embodiments of the present invention can be used in the financial field, and can also be used in any technical field other than the financial field. The embodiments of the present invention do not limit the application fields of the general-purpose database cutover method and device in a service scenario.
[0186] Embodiments of the present application also provide a specific implementation manner of an electronic device capable of implementing all steps in the general database cutover method in the business scenario of the above embodiments. Refer to Figure 16 , the electronic device specifically includes the following:
[0187] A processor (1201), a memory (1202), a communication interface (1203), and a bus (1204);
[0188] Among them, the processor (1201), the memory (1202), and the communication interface (1203) complete mutual communication through the bus (1204); the communication interface (1203) is used to implement information transmission between related devices such as server-side devices and user-side devices;
[0189] The processor (1201) is used to call the computer program in the memory (1202). When the processor executes the computer program, all steps in the general database cutover method in the business scenario of the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0190] Step 100: In response to a received database cutover request, determine whether the source database and multiple target databases meet preset cutover conditions; wherein, the cutover conditions include a read data determination condition for the source database and a write data determination condition for the multiple target databases;
[0191] Step 200: When the source database and the multiple target databases meet the preset cutover conditions, switch the data of the source database to the multiple target databases according to a preset cutover order.
[0192] Embodiments of the present application also provide a computer-readable storage medium capable of implementing all steps in the general database cutover method in the business scenario of the above embodiments. A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all steps in the general database cutover method in the business scenario of the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0193] Step 100: In response to a received database cutover request, determine whether the source database and multiple target databases meet preset cutover conditions; wherein, the cutover conditions include a read data determination condition for the source database and a write data determination condition for the multiple target databases;
[0194] Step 200: When the source database and the multiple target databases meet the preset cutover conditions, switch the data of the source database to the multiple target databases according to a preset cutover order.
[0195] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program type of embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant parts, reference can be made to the partial description of the method embodiments.
[0196] The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0197] Although this application provides method operation steps such as in the embodiments or flowcharts, based on routine or non-creative labor, there can be more or fewer operation steps. The order of steps listed in the embodiments is only one way among the numerous order of step executions and does not represent the only execution order. When the actual device or client product is executing, it can be executed in the order shown in the embodiments or the drawings or in parallel (such as in an environment of parallel processors or multithreaded processing).
[0198] For convenience of description, when describing the above device, it is divided into various modules according to functions for separate description. Of course, when implementing the embodiments of this specification, the functions of each module can be implemented in the same or multiple software and / or hardware, or the modules implementing the same function can be realized by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.
[0199] Those skilled in the art also know that, in addition to implementing the controller in the form of pure computer-readable program code, the method steps can be logically programmed to enable the controller to implement the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Therefore, such a controller can be regarded as a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or structures within the hardware component.
[0200] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0201] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash RAM). The memory is an example of computer-readable media.
[0202] Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment. In the description of this specification, the description referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0203] The above is only the embodiments of the embodiments of this specification and is not used to limit the embodiments of this specification. For those skilled in the art, various changes and modifications can be made to the embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of this specification shall be included within the scope of the claims of the embodiments of this specification.
Claims
1. A general database cutover method in a business scenario, characterized in that Including: In response to the received database cutover request, determine whether the source database and multiple target databases meet the preset cutover conditions; wherein, the cutover conditions include the read data judgment condition for the source database and the write data judgment condition for the multiple target databases; When the source database and the multiple target databases meet the preset cutover conditions, switch the data of the source database to the multiple target databases according to the preset cutover order.
2. The general database cut-off flow method according to claim 1, wherein The step of switching the data of the source database to the multiple target databases according to the preset cutover order includes: Create a snapshot of the data of the source database; wherein, the snapshot is a snapshot of the full amount of data in the source database; Switch the snapshot to the multiple target databases according to the preset cutover order.
3. The general database cut-off flow method according to claim 2, wherein The step of switching the snapshot to the multiple target databases according to the preset cutover order includes: Select at least one target database according to the current data read traffic of the multiple target databases; Generate a traffic ratio according to the current data read traffic of the selected target database; Switch the snapshot to the selected target databases according to the cutover order and the traffic ratio.
4. The general database cut-off flow method according to claim 1, characterized in that The read data judgment condition includes: The relationship between the failure rate in the previous database cutover result of the source database and the first threshold.
5. The general database flow splitting method according to claim 1, characterized in that, The write data judgment condition includes: The relationship between the failure rate in the previous database cutover result of each target database and the second threshold.
6. The general database flow splitting method according to any one of claims 1 to 5, characterized in that It also includes: Classify the data in the source database in the business scenario according to the regions where the customers belong to generate a classification result.
7. The general database cut-off flow method according to claim 6, characterized in that The step of switching the data of the source database to the multiple target databases according to the preset cutover order further includes: Select the data corresponding to the customers in at least one region for switching; wherein, the number of categories of the customers in the selected region is less than the number of categories of the customers in the regions in the classification result; When the data corresponding to the customers in the selected at least one region is switched normally, select the data corresponding to the customers in the next region for switching; Put the data of the customers corresponding to the normal data switch into the normal list for use in the next database cutover.
8. The general database cut-off flow method according to claim 7, wherein After the step of selecting the data corresponding to the customers in at least one region for switching, it also includes: When the data corresponding to the customers in the selected at least one region is switched abnormally, put the data of the customers corresponding to the abnormal data switch into the abnormal list for use in the next database cutover.
9. A general-purpose database traffic switching device in a business scenario, characterized in that, Including: A cutover condition judgment module, configured to determine whether the source database and multiple target databases meet the preset cutover conditions in response to the received database cutover request; wherein, the cutover conditions include the read data judgment condition for the source database and the write data judgment condition for the multiple target databases; A database cutover module, configured to switch the data of the source database to the multiple target databases according to the preset cutover order when the source database and the multiple target databases meet the preset cutover conditions.
10. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, the steps of the general database cutover method in the service scenario described in any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the general database cutover method in the service scenario described in any one of claims 1 to 8 are implemented.