Search

CN-114328442-B - Database migration method, device, equipment and computer readable storage medium

CN114328442BCN 114328442 BCN114328442 BCN 114328442BCN-114328442-B

Abstract

The application provides a database migration method, a database migration device, database migration equipment and a computer readable storage medium; the method comprises the steps of migrating data in a source database of an external network to a destination database of an internal network, keeping synchronization of the source database and the destination database, redirecting an address of a virtual private network of the destination database to the address of the source database, switching an access request to the address of the virtual private network of the destination database, redirecting the access request to the source database based on the redirected address of the source database, stopping synchronization of the source database and the destination database, and recovering the address of the virtual private network of the destination database to the address of the destination database. By the method and the device, smooth migration of the database can be realized.

Inventors

  • WU SHUANGQIAO

Assignees

  • 腾讯科技(深圳)有限公司

Dates

Publication Date
20260508
Application Date
20201010

Claims (17)

  1. 1. A method of database migration, the method comprising: The method comprises the steps of obtaining a source database of an external network, importing the total data in the source database of the external network into a destination database of the internal network, importing a log of the source database into a relay log of the destination database, executing an event in the relay log to update the data of the destination database, and keeping the synchronization of the source database and the destination database after the total data is imported; Redirecting the address of the virtual private network of the destination database to the address of the source database during synchronization, and Switching an access request to an address of a virtual private network of the destination database to redirect the access request to the source database based on the redirected address of the source database; And stopping synchronization of the source database and the destination database when the access requests to the source database are determined to be successfully switched, and recovering the address of the virtual private network of the destination database to the address of the destination database.
  2. 2. The method of claim 1, wherein redirecting the address of the virtual private network of the destination database to the address of the source database comprises: And modifying the routing rule of the virtual private network to modify the address of the virtual private network of the destination database from an address pointing to the destination database to an address pointing to the source database.
  3. 3. The method of claim 1, wherein after said redirecting the address of the virtual private network of the destination database to the address of the source database, the method further comprises: Detecting connectivity of a link from the virtual private network to the source database; When the connectivity passing is detected, determining that redirection is successful; And when the connectivity failure is detected, recovering the address of the virtual private network of the target database to be the address of the target database.
  4. 4. The method of claim 1, wherein said switching the access request to the address of the virtual private network of the destination database comprises: determining a switching sequence of services corresponding to a plurality of access requests aiming at the source database; And according to the switching sequence, modifying the destination address of the access request corresponding to each service from the address of the source database to the address of the virtual private network of the destination database in batches.
  5. 5. The method of claim 1, wherein said switching the access request to the address of the virtual private network of the destination database comprises: distributing switching time periods for the services corresponding to the multiple access requests; and in each switching time period, modifying the destination address of the access request of the corresponding service from the address of the source database to the address of the virtual private network of the destination database.
  6. 6. The method of claim 1, wherein prior to said ceasing synchronization of said source database and said destination database, said method further comprises: And when the access requests to the source database are determined to be successfully switched, setting the source database as read-only, and setting the destination database as readable and writable.
  7. 7. The method of any of claims 1 to 6, wherein the log of the source database is a binary log generated by the source database during the importing of the full amount of data into the destination database.
  8. 8. A database migration apparatus, comprising: The system comprises a synchronization module, a relay log, a synchronization module and a synchronization module, wherein the synchronization module is used for importing the total data in a source database of an external network into a destination database of an internal network; A redirection module for redirecting an address of a virtual private network of the destination database to an address of the source database and switching an access request to an address of a virtual private network of the destination database to redirect the access request to the source database based on the redirected address of the source database; And the recovery module is used for stopping the synchronization of the source database and the destination database and recovering the address of the virtual private network of the destination database to the address of the destination database when the access requests to the source database are determined to be successfully switched.
  9. 9. The apparatus of claim 8, wherein the device comprises a plurality of sensors, The redirection module is further configured to modify a routing rule of the vpn to modify an address of the vpn of the destination database from an address pointing to the destination database to an address pointing to the source database.
  10. 10. The apparatus of claim 8, wherein the apparatus further comprises: The system comprises a source database, a virtual private network, a detection module, a redirection success determination module and a target database, wherein the source database is used for receiving the virtual private network, the detection module is used for detecting the connectivity of a link from the virtual private network to the source database, when the connectivity is detected to pass, the redirection is determined to be successful, and when the connectivity is detected to fail, the address of the virtual private network of the target database is restored to the address of the target database.
  11. 11. The apparatus of claim 8, wherein the device comprises a plurality of sensors, The redirection module is further used for determining a switching sequence of the business corresponding to the access requests of the source database, and modifying the destination address of the access request corresponding to each business from the address of the source database to the address of the virtual private network of the destination database in batches according to the switching sequence.
  12. 12. The apparatus of claim 8, wherein the device comprises a plurality of sensors, And in each switching time period, modifying the destination address of the access request of the corresponding service from the address of the source database to the address of the virtual private network of the destination database.
  13. 13. The apparatus of claim 8, wherein the device comprises a plurality of sensors, And the recovery module is further used for setting the source database as read-only and setting the destination database as readable and writable when the access requests to the source database are determined to be switched successfully.
  14. 14. The apparatus of any of claims 8-13, wherein the log of the source database is a binary log generated by the source database during import of the full amount of data into the destination database.
  15. 15. A database migration apparatus, comprising: A memory for storing executable instructions; A processor for implementing the database migration method of any one of claims 1 to 7 when executing executable instructions stored in the memory.
  16. 16. A computer readable storage medium having stored thereon executable instructions for causing a processor to perform the database migration method of any one of claims 1 to 7.
  17. 17. A computer program product comprising computer instructions which, when executed by a processor, implement the database migration method of any one of claims 1 to 7.

Description

Database migration method, device, equipment and computer readable storage medium Technical Field The present application relates to cloud technology and database technology, and in particular, to a database migration method, a database migration apparatus, a database migration device, and a computer readable storage medium. Background With the development of internet technology, the demand for data processing is also increasing. Compared with the way of locally storing data, the cloud technology-based cloud storage method can improve the safety, stability and flexibility of data storage, so that more and more enterprises or individuals choose to migrate the data to the cloud. However, because the access amount of the data is large and different services are involved, complex dependency relationship exists between the different services, and when the data of the database originally deployed under cloud is migrated to the database in the cloud, continuous smooth switching of the services is difficult to realize. Disclosure of Invention The embodiment of the application provides a database migration method, a database migration device, database migration equipment and a computer readable storage medium, which can realize smooth migration of a database. The technical scheme of the embodiment of the application is realized as follows: The embodiment of the application provides a database migration method, which comprises the following steps: Migrating data in a source database of an external network to a destination database of an internal network, and keeping synchronization of the source database and the destination database; Redirecting the address of the virtual private network of the destination database to the address of the source database during synchronization, and Switching an access request to an address of a virtual private network of the destination database to redirect the access request to the source database based on the redirected address of the source database; And stopping the synchronization of the source database and the destination database, and recovering the address of the virtual private network of the destination database to the address of the destination database. The embodiment of the application provides a database migration device, which comprises: the synchronization module is used for migrating data in a source database of an external network to a destination database of an internal network and keeping synchronization of the source database and the destination database; A redirection module for redirecting an address of a virtual private network of the destination database to an address of the source database and switching an access request to an address of a virtual private network of the destination database to redirect the access request to the source database based on the redirected address of the source database; And the recovery module is used for stopping the synchronization of the source database and the destination database and recovering the address of the virtual private network of the destination database to the address of the destination database. In the above scheme, the redirection module is further configured to modify a routing rule of the vpn so as to modify an address of the vpn of the destination database from an address pointing to the destination database to an address pointing to the source database. In the scheme, the database migration device further comprises a detection module, wherein the detection module is used for detecting connectivity of a link from the virtual private network to the source database, determining that redirection is successful when the connectivity is detected to pass, and recovering an address of the virtual private network of the target database to an address of the target database when the connectivity is detected to fail. In the scheme, the redirection module is further used for determining the switching sequence of the business corresponding to the plurality of access requests of the source database, and modifying the destination address of each access request corresponding to the business from the address of the source database to the address of the virtual private network of the destination database in batches according to the switching sequence. In the scheme, the redirection module is further used for distributing switching time periods for the services corresponding to the multiple access requests, and in each switching time period, modifying the destination address of the access request of the corresponding service from the address of the source database to the address of the virtual private network of the destination database. In the above scheme, the recovery module is further configured to set the source database to be read-only and set the destination database to be readable and writable when it is determined that the access requests to the source database are all successfully switched. In the scheme, the synchroniza