Database migration method and device, equipment and storage medium

By using dual-server interactive replacement during the database migration process, data synchronization and code verification are solved, and database migration in the existing technology is low efficiency and high cost, and efficient and low-risk database migration is achieved.

CN120407540APending Publication Date: 2025-08-01DUXIAOMAN TECH (BEIJING) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510479060.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

In the prior art, database migration is less efficient and costly, and has high risks and time consumption.

Method used

By synchronizing data between the main server and the standby server, using the standby server to undertake real-time online services, and prohibiting the write operation of the database to be migrated within the preset time period, ensuring that the main server undertakes reading services, and database migration is carried out through dual-server interactive replacement, and the normality of the target new code and the migration database are pre-verified.

Benefits of technology

It greatly reduces the risks during database migration, reduces migration time and cost, ensures the continuity of real-time online services, improves migration efficiency and reduces resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407540A_ABST
    Figure CN120407540A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of data processing, and discloses a database migration method, device and equipment and a storage medium, the method comprises the following steps: starting data synchronization processing between a to-be-migrated database and a migrated database, and undertaking real-time online business by using a standby server of a main server; deploying a target new code on the main server, and verifying that the target new code is correct and the migration database is normal; forbidding the execution of the write operation on the to-be-migrated database in a preset time period, enabling the main server to undertake the read service in the real-time online service, and stopping the standby server from undertaking the real-time online service; deploying the target new code on the standby server, and performing database connection on the standby server and the migration database; and when the read flow and the write flow for the to-be-migrated database do not exist, closing data synchronization processing, and offline the to-be-migrated database. The technical effects of improving the database migration efficiency and reducing the database migration cost are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of data processing, and particularly to a database migration method, apparatus, device and storage medium. Background Art

[0002] In the technical field of data processing, database migration is a common solution adopted when the existing database capacity is insufficient. However, in the prior art, database migration needs to be operated during the online period, which will cause the services relying on the database to be unavailable throughout the database migration period. Moreover, the migration process needs to be verified, and when problems are found during the migration process, rollback is required. Therefore, in the prior art, when performing database migration, the risks faced are relatively large, more time is required, and the risk cost is relatively high. That is, there are problems of low efficiency and high cost in database migration in the prior art. Summary of the Invention

[0003] The purpose of the present invention is to provide at least a database migration method, apparatus, device and storage medium, which can at least solve the technical problem of low efficiency and high cost during database migration, and can at least achieve the technical effects of improving the efficiency of database migration and reducing the migration cost.

[0004] To solve the above technical problem, at least one embodiment of the present application provides a database migration method, including: starting data synchronization processing between the database to be migrated and the migration database, and using the standby server of the main server to undertake real-time online services, where the real-time online services refer to real-time services relying on the data in the database to be migrated; deploying target new code on the main server, and verifying that the target new code is correct and the migration database is normal; prohibiting write operations on the database to be migrated during a preset time period, so that the main server undertakes the read services in the real-time online services, and stopping the standby server from undertaking the real-time online services; deploying the target new code on the standby server, and establishing a database connection between the standby server and the migration database; when there is no read traffic and write traffic for the database to be migrated, closing the data synchronization processing and taking the database to be migrated offline.

[0005] At least one embodiment of the present application further provides a database migration device, including: an enabling module, configured to enable data synchronization processing between a database to be migrated and a migration database, and use a standby server of a primary server to undertake real-time online services, where the real-time online services refer to real-time services that rely on data in the database to be migrated; a deployment module, configured to deploy target new code on the primary server and verify that the target new code is correct and the migration database is normal; a prohibition module, configured to prohibit writing operations on the database to be migrated during a preset time period, enable the primary server to undertake read services in the real-time online services, and stop the standby server from undertaking the real-time online services; the deployment module is further configured to deploy the target new code on the standby server and establish a database connection between the standby server and the migration database; a closing module, configured to close the data synchronization processing and take offline the database to be migrated when there is no read traffic and write traffic for the database to be migrated.

[0006] At least one embodiment of the present application further provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned database migration method.

[0007] At least one embodiment of the present application further provides a computer-readable storage medium, storing a computer program, where the computer program, when executed by a processor, implements the above-mentioned database migration method.

[0008] The database migration method provided by the embodiments of the present application includes: enabling data synchronization processing between the database to be migrated and the migration database, and using the standby server of the primary server to undertake real-time online services, where the real-time online services refer to real-time services that rely on the data in the database to be migrated; deploying target new code on the primary server, and verifying that the target new code is correct and the migration database is normal; prohibiting write operations on the database to be migrated during a preset time period, so that the primary server undertakes the read services in the real-time online services, and stops the standby server from undertaking the real-time online services; deploying the target new code on the standby server, and establishing a database connection between the standby server and the migration database; when there is no read traffic and write traffic for the database to be migrated, closing the data synchronization processing and taking the database to be migrated offline. By pre-verifying the target new code and the migration database, it is determined that the target new code can run successfully in the primary server and can be smoothly docked with the database to be migrated. At the same time, during the verification process, by using a dual-server, it is ensured that during the verification, the standby server can be used to process real-time online services, and the real-time online services will not be unable to be processed. During the migration process, it is only necessary to prohibit write operations on the database to be migrated for a short time, deploy the target new code through one server, and the other server undertakes the read services. By using the interactive replacement method of the two servers, the loss caused by the migration database to the business is reduced as much as possible. The risk existing in the migration database is greatly reduced, and the time consumed by the migration database is reduced. The technical effects of improving the efficiency of database migration and reducing the cost of database migration are achieved.

[0009] In some optional embodiments, before deploying the target new code on the primary server, the method further includes: writing the table files in the database to be migrated into a first file; encrypting the first file by using an encryption hash function to obtain a first hash value; writing the table files in the migration database into a second file; encrypting the second file by using the encryption hash function to obtain a second hash value; determining that the data of the database to be migrated is consistent with the data of the migration database by comparing the first hash value and the second hash value. By writing the table files in the database into files, the table files in the database are backed up. When the data in the database is lost, it can still be found through the backed-up files, avoiding the loss caused by data loss. And by encrypting the backed-up files of the two databases and comparing the encrypted values, it can be determined whether the data of the two databases is consistent, improving the accuracy of database migration.

[0010] In some alternative embodiments, if the replay of the read interface that depends on the migration database and the test of the whitelist write interface are both successful when executed using the primary server, it is regarded that the target new code is correct and the migration database is normal. By executing the replay of the read interface, it can be determined whether the read logic of the target new code is correct and whether the read function of the migration database is normal. By executing the test of the whitelist write interface, it can be determined whether the write logic of the target new code is correct and whether the write function of the migration database is normal. Thus, the target new code and the migration database can be pre-checked to ensure that the target new code is correct and the migration database can work properly, avoiding errors in the target new code and unavailability of the migration database during the migration of the database, which may result in waste of migration resources, migration time, and losses caused by the unnecessary suspension of the server from undertaking business. This improves the efficiency of migrating the database and reduces the cost of migrating the database.

[0011] In some alternative embodiments, after the target new code is correct and the migration database is normal, and before the write operation on the database to be migrated is prohibited during a preset time period, the method further includes: rolling back the code on the primary server to the state before the target new code was deployed; establishing a database connection between the primary server and the database to be migrated, so that the primary server and the standby server jointly undertake the real-time online business that depends on the database to be migrated; obtaining the first time period when the traffic of the real-time online business undertaken by the primary server and the standby server is at a low point; using the first time period as the preset time period; after using the first time period as the preset time period, the method further includes: deploying the target new code on the primary server during the preset time period and establishing a database connection between the primary server and the migration database. Selecting the first time period when the traffic of the real-time online business is at a low point for database migration can avoid a large number of users accessing the database, and minimize the impact caused by the inability to perform database write operations during the migration period of the database migration.

[0012] In some alternative embodiments, after establishing a database connection between the standby server and the migration database, the method further includes: using the standby server and the primary server to jointly undertake the read service in the real-time online business. By having the standby server undertake the read service of the real-time online business, it can be determined whether the standby server can access the migration database normally, ensuring that the standby server can successfully connect to the migration database.

[0013] In some alternative embodiments, the method further includes: if the primary server fails to undertake the read service in the real-time online service, stop the primary server from undertaking the real-time online service, and start the standby server to undertake the real-time online service; roll back the code in the primary server to the state when the target new code was not deployed. When an error occurs while the primary server is executing the online read service, it indicates that the primary server cannot successfully access the migration database, which further indicates that there is an error in migrating the database to be migrated to the migration database. By promptly using the standby server to undertake the online service, the problem of poor user experience caused by the online service not being executed all the time is avoided, and the user experience is improved.

[0014] In some alternative embodiments, the method further includes: obtaining the database permission accounts to be disabled, setting the database permission accounts to be temporarily disabled; when the primary server and the standby server can normally call the data in the migration database within a preset period, setting the database permission accounts to be permanently disabled. By disabling some database permission accounts, for example, the database permission accounts corresponding to developers, testers or other relevant personnel, the security of the data in the migration database is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] One or more embodiments are exemplarily illustrated by the pictures in the corresponding drawings, and these exemplary illustrations do not limit the embodiments.

[0016] Figure 1 is a flowchart of a database migration method provided by an embodiment of the present application;

[0017] Figure 2 is a structural diagram of the relationship between a server and a database provided by an embodiment of the present application;

[0018] Figure 3 is a structural diagram of a server undertaking services provided by an embodiment of the present application;

[0019] Figure 4 is a structural diagram of two servers undertaking services provided by an embodiment of the present application;

[0020] Figure 5 is a structural diagram of another server undertaking services provided by another embodiment of the present application;

[0021] Figure 6 is a schematic diagram of a database migration device provided by another embodiment of the present application;

[0022] Figure 7 is a structural diagram of an electronic device provided by another embodiment of the present application. Detailed implementation manners

[0023] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art can understand that in the embodiments of the present application, many technical details are presented to help the reader better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in the present application can still be implemented. The following division of each embodiment is for convenience of description and should not constitute any limitation on the specific implementation manner of the present application. Each embodiment can be combined and cross-referenced with each other on the premise of no contradiction.

[0024] It should be noted that the acquisition or use of the data in the embodiments of the present application requires the consent of the user. The relevant data can only be obtained after the user authorizes and permits it, and the acquisition or use of the data complies with the provisions of relevant laws and regulations.

[0025] To facilitate the understanding of this solution, some terms in this solution are explained here:

[0026] DBA (Database Administrator): The general term for professionals engaged in the management and maintenance of database management systems;

[0027] DTS (Data Transmission Service): A service used to achieve real-time or near-real-time synchronization of data between different data sources.

[0028] Read interface playback: It refers to the process of, after the system (code) goes live, resending the read interface requests and their related data captured in the previous test environment or production environment to the live system (code) for processing, and comparing the returned results with the expected results.

[0029] White list write interface test: It refers to the test conducted on specific and authorized write interface operations after the system (code) goes live. Only those write interfaces included in the white list can be called during the test, which is a security measure to prevent unauthorized write operations from damaging the system (code) or causing data leakage.

[0030] In the field of data processing technology, database migration is a common solution adopted when the capacity of the existing database is insufficient. However, in the prior art, database migration requires operational processing during the go-live process, which will cause the services relying on the database to be unavailable throughout the entire period of database migration. Moreover, the migration process also requires verification, and when problems are found during the migration process, rollback is needed. Therefore, in the prior art, when performing database migration, there are relatively high risks, it takes a long time, and the risk cost is high. That is, there are problems of low efficiency and high cost in database migration in the prior art.

[0031] To solve the above technical problems of low efficiency and high cost in database migration, the present invention proposes a database migration method. The following specifically describes the implementation details of the database migration method in this embodiment. The following content is only the implementation details provided for easy understanding and is not necessary for implementing this solution.

[0032] Embodiment 1:

[0033] The database migration method in this embodiment can be applied to an electronic device with communication, computing, and data storage capabilities. Its specific process can be as Figure 1 shown, including:

[0034] Step 101, start the data synchronization process between the database to be migrated and the migration database, and use the standby server of the main server to undertake the real-time online business, where the real-time online business refers to the real-time business that depends on the data in the database to be migrated.

[0035] Specifically, the database to be migrated refers to the old database that needs to be replaced. The migration database refers to the new database that needs to replace the database to be migrated.

[0036] Specifically, the data synchronization process is an operation that makes the data in the migration database consistent with the data in the database to be migrated.

[0037] Specifically, the main server can be one server or multiple servers. The main server is placed in a computer room. For example, the main server can be placed in the HBA computer room.

[0038] Specifically, the standby server can be one server or multiple servers. The standby server is placed in a computer room different from the main server. For example, the main server can be placed in the HBB computer room.

[0039] Specifically, the real-time online business refers to the business that is generated in real time and needs to read the data in the database to be migrated or write data into the database to be migrated.

[0040] In some examples, the relationship between the database to be migrated and the primary server and the standby server can be seen in Figure 2 , where the primary server is used to undertake the online services that depend on the database to be migrated, such as reading data from the database to be migrated and writing data into the database to be migrated. The standby server can also perform the same online services as the primary server, but usually the standby server does not perform online services. When there are too many online services, the primary server is overloaded or the primary server runs abnormally, the standby server is used to temporarily replace the primary server and perform online services.

[0041] In some examples, it can be seen in Figure 2 , the DBA can use DTS to synchronize the data in the database to be migrated to the migration database, realizing the real-time synchronization of the data in the database to be migrated and the data in the migration database, ensuring the consistency of the new data and the old data.

[0042] In some examples, it can be seen in Figure 3 , by using the operation OP to make the primary server unable to undertake real-time online services, so that the standby server undertakes all real-time online services, that is, the standby server undertakes all traffic. To ensure that real-time online services can be used normally without delaying the processing of real-time online services.

[0043] Step 102, deploy the target new code on the primary server and verify that the target new code is correct and the migration database is normal.

[0044] Specifically, the target new code refers to the code originally deployed on the primary server related to the database to be migrated based on the library information of the migration database, where the library information in the migration database includes database configuration parameters, table structures, indexes, constraints and other information.

[0045] In some examples, if both the read interface playback and the whitelist write interface test that depend on the migration database are successfully executed using the primary server, it is regarded as verifying that the target new code is correct and the migration database is normal.

[0046] In some examples, it can be seen in Figure 3When the primary server no longer undertakes real-time online services, the developer RD can deploy the target new code on the primary server and modify the database connection between the primary server and the database to be migrated to the database connection between the primary server and the migrated database. The quality assurance engineer QA can execute the read interface playback to verify the deployed target new code and the migrated database to ensure that the read logic of the target new code is correct and the read function of the migrated database is normal. The developer RD can execute the whitelist write interface test to determine that the write logic of the target new code is correct and the write function of the migrated database is normal. Thus, it is determined that the new database (migrated database) functions normally and the read and write logic of the new online service code (target new code) is correct.

[0047] In some examples, before deploying the target new code on the primary server, the method further includes: writing the table files in the database to be migrated into a first file; encrypting the first file using an encryption hash function to obtain a first hash value; writing the table files in the migrated database into a second file; encrypting the second file using the encryption hash function to obtain a second hash value; determining that the data in the database to be migrated is consistent with the migrated database by comparing the first hash value and the second hash value.

[0048] Step 103, prohibit writing operations on the database to be migrated during a preset time period, so that the primary server undertakes the read operations in the real-time online services, and stop the standby server from undertaking the real-time online services.

[0049] In some examples, after the target new code is correct and the migrated database is normal, and before prohibiting writing operations on the database to be migrated during the preset time period, the method further includes: rolling back the code on the primary server to the state before the target new code was deployed; connecting the primary server to the database to be migrated so that the primary server and the standby server jointly undertake the real-time online services that depend on the database to be migrated; obtaining the first time period of the low traffic point when the primary server and the standby server undertake the real-time online services; using the first time period as the preset time period; after using the first time period as the preset time period, the method further includes: deploying the target new code on the primary server during the preset time period and connecting the primary server to the migrated database.

[0050] In some examples, the first period of the traffic low point is determined by integrating the online interface, offline data, and dts monitoring information. Specifically, the currently used write interface is determined through the interface authentication mechanism, the traffic corresponding to the write interface at the moment of the traffic low peak is queried through monitoring, the impact of migrating the database at different times on the write operation is evaluated by the developers related to the database to be migrated, the offline tasks to be concerned about in different periods are determined through the offline account, and the dts tasks are searched by the database table name to determine the tasks to be executed in each period. Based on the above-mentioned various information obtained, the first period of the traffic low point with the least impact on the write operation, the least impact on the offline tasks, and the least impact on the important tasks is comprehensively determined to reduce the losses caused by migrating the database.

[0051] In some examples, refer to Figure 4 , the RD can be used to roll back the target new code deployed on the main server to the latest state when the target new code was not deployed, that is, the target new code deployed on the main server is revoked, and the database connection between the main server and the database to be migrated is modified to the database connection between the main server and the database to be migrated. The OP is used to enable the main server to undertake the real-time online business, so that the main server and the standby server jointly undertake the real-time online business to share the traffic for the standby server.

[0052] In some examples, if the current moment is at the start moment of the preset time period, the operation of migrating the database to be migrated is started. At this time, the main server stops undertaking the real-time online business, the target new code is deployed again on the main server, and the database connection between the main server and the database to be migrated is modified to the database connection between the main server and the migrated database. At the same time, the standby server stops undertaking the real-time online business. Specifically, within the preset time period, the standby server and the main server stop undertaking the business related to the write operation. Within the preset time period, although the server stops undertaking the business related to the write operation, it can still undertake the business related to the read operation, and the duration of this preset time period is relatively short, about 5 minutes or so, which is greatly shortened compared with the 30 minutes required by the prior art, and greatly reduces the cost of migrating the database.

[0053] Within the preset time period, the data on which the main server depends to undertake the real-time online business is synchronized from the database to be migrated to the migrated database, that is, the main server undertakes the real-time online business that depends on the migrated database.

[0054] In some examples, the method further includes: if the primary server fails to undertake the read service in the real-time online service, stop the primary server from undertaking the real-time online service, and start the standby server to undertake the real-time online service; roll back the code in the primary server to the state when the target new code was not deployed.

[0055] Step 104, deploy the target new code on the standby server, and establish a database connection between the standby server and the migration database.

[0056] In some examples, refer to Figure 5 , when the primary server successfully undertakes the real-time online service related to read operations that depends on the migration database, start the primary server to undertake the real-time online service including write operation related that depends on the migration database. RD deploys the target new code to the standby server, and modifies the database connection of the standby server from the database to be migrated to the migration database.

[0057] In some examples, after establishing the database connection between the standby server and the migration database, the method further includes: using the standby server and the primary server to jointly undertake the read service in the real-time online service that depends on.

[0058] In some examples, the method further includes: obtain the database permission account to be disabled, set the database permission account to be temporarily disabled; within a preset period, when the primary server and the standby server can normally call the data in the migration database, set the database permission account to be permanently disabled.

[0059] Step 105, when there is no read traffic and write traffic for the database to be migrated, turn off the data synchronization process and take offline the database to be migrated.

[0060] In some examples, refer to Figure 5 , when there is no read and write traffic in the database to be migrated, that is, there is no traffic related to the real-time online service in the database to be migrated, and there is also no traffic related to the offline service, cut off the data synchronization process between the migration database and the database to be migrated.

[0061] The method further includes: obtain the database permission account to be disabled, set the database permission account to be temporarily disabled; within a preset period, when the primary server and the standby server can normally call the data in the migration database, set the database permission account to be permanently disabled.

[0062] Specifically, the database privilege accounts to be disabled include the accounts that developers, testers or other personnel have and can operate on the migrated database, or other accounts that threaten the security of the migrated database. When it is determined that the database to be migrated has been successfully migrated to the migrated database, the database privilege accounts to be disabled need to be disabled to ensure the security of the data in the migrated database.

[0063] In summary, the present application provides a solution for enabling data synchronization processing between the database to be migrated and the migrated database, using the standby server of the primary server to undertake real-time online services. Among them, the real-time online service refers to a real-time service that depends on the data in the database to be migrated; deploying target new code on the primary server and verifying that the target new code is correct and the migrated database is normal; prohibiting write operations on the database to be migrated during a preset time period, so that the primary server undertakes the read service in the real-time online service, and stops the standby server from undertaking the real-time online service; deploying the target new code on the standby server and establishing a database connection between the standby server and the migrated database; when there is no read traffic and write traffic for the database to be migrated, closing the data synchronization processing and taking offline the database to be migrated. By pre-verifying the target new code and the migrated database, it is determined that the target new code can successfully run in the primary server and can be smoothly docked with the database to be migrated. At the same time, during the verification process, using a dual-server ensures that during the verification, the standby server can be used to process real-time online services and will not cause the real-time online services to be unable to be processed. During the migration process, it is only necessary to prohibit write operations on the database to be migrated for a short time, deploy the target new code on one server, and the other server undertakes the read service. By using the interactive replacement method of the two servers, the loss of the migrated database to the business is reduced as much as possible. The risk existing in the migrated database is greatly reduced, and the time consumed by the migrated database is reduced. The technical effects of improving the efficiency of database migration and reducing the cost of database migration are achieved.

[0064] Specifically, by deploying code on one server and having another server handle the traffic, it is ensured that during database migration, except for write operations which are not supported, other operations can be executed normally, that is, a part of the online business can also be supported during the database migration process. This greatly reduces the huge losses caused by the unavailability of the online business due to database migration. And when problems occur during the migration process, the migration can be quickly stopped and the standby server can be immediately started to support the online business, enabling rapid rollback and quick loss prevention, reducing the risk of database migration. At the same time, before performing the database migration, code verification is carried out in advance, which also reduces the risks existing in the database migration, ultimately minimizing the impact of database switching on the overall business. The dual-data center switching is used to handle the online business, combined with the control of database read and write permissions, and through read traffic playback, the migration of the underlying database and code verification are completed with almost no loss to the business.

[0065] Embodiment 2:

[0066] Another embodiment of the present application relates to a database migration device. The implementation details of the database migration device in this embodiment will be specifically described below. The following content is only the implementation details provided for easy understanding and is not necessary for implementing this solution. The schematic diagram of the database migration device in this embodiment can be as Figure 6 shown, including an enabling module 601, a deployment module 602, a prohibiting module 603, and a closing module 604.

[0067] The enabling module 601 is used to enable data synchronization processing between the database to be migrated and the migration database, and use the standby server of the main server to handle the real-time online business, where the real-time online business refers to the real-time business that depends on the data in the database to be migrated;

[0068] The deployment module 602 is used to deploy the target new code on the main server and verify that the target new code is correct and the migration database is normal;

[0069] The prohibiting module 603 is used to prohibit write operations on the database to be migrated during a preset time period, enable the main server to handle the read operations in the real-time online business, and stop the standby server from handling the real-time online business;

[0070] The deployment module 602 is further used to deploy the target new code on the standby server and establish a database connection between the standby server and the migration database;

[0071] The closing module 604 is used to close the data synchronization processing and take offline the database to be migrated when there is no read traffic and write traffic for the database to be migrated.

[0072] In some examples, before the device is used to deploy the target new code on the primary server, the device is further configured to: write the table files in the database to be migrated into a first file; encrypt the first file using a cryptographic hash function to obtain a first hash value; write the table files in the migration database into a second file; encrypt the second file using the cryptographic hash function to obtain a second hash value; determine that the data in the database to be migrated is consistent with the data in the migration database by comparing the first hash value and the second hash value.

[0073] In some examples, in the device, if both the read interface replay and the whitelist write interface test that depend on the migration database are successfully executed using the primary server, it is regarded as verifying that the target new code is correct and the migration database is normal.

[0074] In some examples, after the device is used to verify that the target new code is correct and the migration database is normal, and before prohibiting write operations on the database to be migrated during a preset time period, the device further includes: rolling back the code on the primary server to the state before the target new code was deployed; establishing a database connection between the primary server and the database to be migrated, so that the primary server and the standby server jointly undertake the real-time online services that depend on the database to be migrated; obtaining a first time period when the traffic of the real-time online services jointly undertaken by the primary server and the standby server is at a low point; using the first time period as the preset time period; after using the first time period as the preset time period, the device is further configured to: deploy the target new code on the primary server during the preset time period and establish a database connection between the primary server and the migration database.

[0075] In some examples, after the device is used to establish a database connection between the standby server and the migration database, the device is further configured to: use the standby server and the primary server to jointly undertake the read services in the real-time online services.

[0076] In some examples, the device is further configured to: if the primary server fails to undertake the read services in the real-time online services, stop the primary server from undertaking the real-time online services and start the standby server to undertake the real-time online services; roll back the code in the primary server to the state before the target new code was deployed.

[0077] In some examples, the device is further configured to: obtain a database privilege account to be disabled, and set the database privilege account to be temporarily disabled; within a preset period, when the primary server and the standby server can normally call the data in the migrated database, set the database privilege account to be permanently disabled.

[0078] It is worth mentioning that each module involved in this embodiment is a logical module. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or can be implemented by a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, units that are not closely related to solving the technical problems proposed in this application are not introduced in this embodiment, but this does not mean that there are no other units in this embodiment.

[0079] Embodiment Three:

[0080] Another embodiment of the present application relates to an electronic device, as Figure 7 shown, including: at least one processor 901; and a memory 902 communicatively connected to the at least one processor 901; wherein, the memory 902 stores instructions executable by the at least one processor 901, and the instructions are executed by the at least one processor 901 to enable the at least one processor 901 to execute the database migration method in the above embodiments.

[0081] Among them, the memory and the processor are connected in a bus manner. The bus can include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art, so they will not be further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be an element or multiple elements, such as multiple receivers and transmitters, and provides a unit for communicating with various other devices on the transmission medium. The data processed by the processor is transmitted on the wireless medium through the antenna. Further, the antenna also receives data and transmits the data to the processor.

[0082] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. The memory can be used to store the data used by the processor when performing operations.

[0083] Embodiment Four:

[0084] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the method embodiments described above are implemented.

[0085] That is, those skilled in the art can understand that all or part of the steps in the methods of the above embodiments can be completed by instructing relevant hardware through a program. The program is stored in a storage medium and includes several instructions to enable a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs that can store program codes.

[0086] Those of ordinary skill in the art can understand that the above embodiments are specific embodiments for implementing the present application, and in practical applications, various changes can be made in form and details without departing from the spirit and scope of the present application.

Claims

1. A database migration method, characterized in that, Including: Enable data synchronization processing between the database to be migrated and the migration database, and use the standby server of the primary server to undertake real-time online services, where the real-time online service refers to a real-time service that depends on the data in the database to be migrated; Deploy the target new code on the primary server and verify that the target new code is correct and the migration database is normal; Execute a prohibition on writing operations to the database to be migrated during a preset time period, so that the primary server undertakes the read service in the real-time online service, and stop the standby server from undertaking the real-time online service; Deploy the target new code on the standby server and establish a database connection between the standby server and the migration database; When there is no read traffic and write traffic for the database to be migrated, close the data synchronization processing and take the database to be migrated offline.

2. The database migration method according to claim 1, wherein Before deploying the target new code on the primary server, the method further includes: Write the table files in the database to be migrated into a first file; Encrypt the first file using an encryption hash function to obtain a first hash value; Write the table files in the migration database into a second file; Encrypt the second file using the encryption hash function to obtain a second hash value; Determine that the data of the database to be migrated is consistent with the migration database by comparing the first hash value and the second hash value.

3. The database migration method according to claim 1, wherein If both the read interface playback and the whitelist write interface test that depend on the migration database are successfully executed using the primary server, it is regarded as verifying that the target new code is correct and the migration database is normal.

4. The database migration method according to claim 1, wherein After the target new code is correct and the migration database is normal, and before executing the prohibition on writing operations to the database to be migrated during the preset time period, the method further includes: Roll back the code on the primary server to the state before the target new code was deployed; Establish a database connection between the primary server and the database to be migrated, so that the primary server and the standby server jointly undertake the real-time online service that depends on the database to be migrated; Obtain the first time period at the low traffic point when the primary server and the standby server undertake the real-time online service; Use the first time period as the preset time period; After using the first time period as the preset time period, the method further includes: During the preset time period, deploy the target new code on the primary server and establish a database connection between the primary server and the migration database.

5. The database migration method according to claim 1, wherein After establishing a database connection between the standby server and the migration database, the method further includes: Use the standby server and the primary server to jointly undertake the read service in the real-time online service.

6. The database migration method according to claim 1, wherein The method further includes: If the primary server fails to undertake the read service in the real-time online service, stop the primary server from undertaking the real-time online service and start the standby server to undertake the real-time online service; Roll back the code in the primary server to the state before the target new code was deployed.

7. The database migration method according to claim 1, wherein The method further includes: Obtain the database permission account to be disabled and set the database permission account to be temporarily disabled; Within a preset period, when the primary server and the standby server can normally call the data in the migration database, set the database permission account to be permanently disabled.

8. A database migration device, characterized in that, It includes: An enabling module, used to enable data synchronization processing between the database to be migrated and the migration database, and use the standby server of the primary server to undertake real-time online services, where the real-time online services refer to real-time services that rely on the data in the database to be migrated; A deployment module, used to deploy the target new code on the primary server and verify that the target new code is correct and the migration database is normal; A prohibition module, used to prohibit writing operations on the database to be migrated during a preset time period, so that the primary server undertakes the read operations in the real-time online services, and stops the standby server from undertaking the real-time online services; The deployment module is further used to deploy the target new code on the standby server and establish a database connection between the standby server and the migration database; A closing module, used to close the data synchronization processing and take offline the database to be migrated when there is no read traffic and write traffic for the database to be migrated.

9. An electronic device, characterized in that, It includes: At least one processor; And, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the database migration method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the database migration method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Database online migration method, electronic equipment and storage medium

    CN109656908A

  • Database data updating synchronization method and device

    CN110674148A

  • Data migration method and device, equipment and storage medium

    CN113010496A

  • Data processing method and device, computer equipment and storage medium

    CN116166632A

  • Automatic deployment and operation and maintenance system of distributed cluster

    CN117834433A