CN105528368B - A kind of database migration method and device - Google Patents

A kind of database migration method and device Download PDF

Info

Publication number
CN105528368B
CN105528368B CN201410522064.8A CN201410522064A CN105528368B CN 105528368 B CN105528368 B CN 105528368B CN 201410522064 A CN201410522064 A CN 201410522064A CN 105528368 B CN105528368 B CN 105528368B
Authority
CN
China
Prior art keywords
database
target
migrated
environment
threshold value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410522064.8A
Other languages
Chinese (zh)
Other versions
CN105528368A (en
Inventor
符玲亭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201410522064.8A priority Critical patent/CN105528368B/en
Publication of CN105528368A publication Critical patent/CN105528368A/en
Application granted granted Critical
Publication of CN105528368B publication Critical patent/CN105528368B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a kind of database migration method and devices, comprising: receives database migration instruction, determines the source environment of database to be migrated and create target environment;The last full backup for treating migrating data library is obtained, at least the last full backup is loaded into target environment;After the completion of loading the last full backup, migrated in the target database in target environment using the transaction journal of database to be migrated;Judge whether target database and the difference of database to be migrated are equal to or less than preset threshold value, if so, virtual IP address to be switched to the IP address for being directed toward target database from the IP address for being directed toward database to be migrated;Judge whether target database is completed to migrate;It is carried out if so, the read-write operation of user is switched to target database.Using the embodiment of the present invention, realizes during database migration, do not interfere user to operate database.

Description

A kind of database migration method and device
Technical field
The present invention relates to computer application technology, in particular to a kind of database migration method and device.
Background technique
With the development of computer technology and Internet technology, the application of database has been deep into life and work, respectively The data of kind data base management system, website etc. all be unable to do without the support of database.In certain situations it is desirable to database into Row migration, so-called database migration refer to the database loaded in the environment of source in target environment.Database migration technology One application purpose is to realize the upgrade or downgrade of database resource.For example, for database used in tenant in cloud platform Example, at the beginning of establishment, will the database resource that can occupy of specified database example, but with the change of tenant's demand More, tenant needs upgrading or degrading data base resource to need target environment in another example the database in the environment of source goes wrong When reconfiguring to database, database migration technology can be used.In the above cases, it is necessary to database into Row migration.
Database migration method in the prior art is usually after receiving the migration instruction of database, to stop external Access to database no longer allows to be written and read database, using the backup to database in the environment of source, will count It is loaded into target environment according to library, until after database completes migration, then outside is allowed to access the database.
But using above-mentioned database migration method, in the transition process of database, user cannot to database into Row operation, only database migration complete, allow outside to the access of the database of target environment after, user could again Database is operated, the migration of database may be since the demand of user generates, it is also possible to be manufacturer server Demand generate, it is also possible to caused by database upgrade, as database is more and more huger, high-frequency or move for a long time The behavior for moving database happens occasionally, and the too many time cannot will substantially reduce the service quality of database to database manipulation, Cause customer churn.Therefore, when the present invention wishes database migration, unavailable time is reduced to greatest extent to the greatest extent.
Summary of the invention
The embodiment of the present invention is designed to provide a kind of database migration method and device, to realize in database migration During, do not interfere user to operate database.
In order to achieve the above objectives, the embodiment of the invention discloses a kind of database migration methods, comprising:
Database migration instruction is received, determines the source environment of database to be migrated, and create target environment;
The last full backup to the database to be migrated is obtained, at least adds the last full backup It is downloaded in target environment;
After the completion of loading the last full backup, using described to be migrated in the target database in target environment The transaction journal of database is migrated;
Judge whether the target database and the difference of database to be migrated are equal to or less than pre-set threshold value;
The target database is directed toward if so, virtual IP address is switched to from the IP address for being directed toward the database to be migrated IP address;
Judge the direction of the virtual IP address whether switched finish and the target database complete migration;
It is written and read if it is, user is switched to target database.
Preferably, the full backup and the transaction journal be respectively stored in document storage system or source environment or In person's target environment.
Preferably, the document storage system is distributed file system.
Preferably, it is described after the completion of loading the last full backup, it is answered in the target database in target environment It is migrated with the transaction journal of the database to be migrated, comprising:
Operation note according to each time point user recorded in the transaction journal to database, from apart from described complete The operation note that the time of amount backup generation is primary the latest starts, and updates target database one by one according to every operation note, directly It is finished to according to apart from the nearest transaction journal update of current time.
It is set in advance preferably, whether the difference for judging the target database and database to be migrated is equal to or less than After the threshold value set, if the target database and the difference of the database to be migrated are greater than pre-set threshold value, Return execute it is described after the completion of loading the last full backup, in the target database in target environment using it is described to The step of transaction journal in migrating data library is migrated.
It is set in advance preferably, whether the difference for judging the target database and database to be migrated is equal to or less than The threshold value set, comprising:
When the target database reads an operation note in the transaction journal, the operation note is calculated The difference of timestamp and present system time, it is described if the time difference is equal to or less than the pre-set threshold value Target database and the difference of the database to be migrated reach preset threshold value;If the time difference sets in advance greater than described The threshold value set, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
In order to achieve the above objectives, the embodiment of the invention discloses a kind of database migration devices, comprising: migration command reception Module, loading module, transferring module, threshold value judgment module, switching module, migration judgment module and read-write transferring module, wherein
The migration command reception module, library migration instruction, determines the source environment of database to be migrated for receiving data, And create target environment;
The loading module at least will be described for obtaining the last full backup to the database to be migrated The last full backup is loaded into target environment;
The transferring module, for target data after the completion of loading the last full backup, in target environment It is migrated on library using the transaction journal of the database to be migrated;
The threshold value judgment module, for judge the difference of the target database and database to be migrated whether be equal to or Less than pre-set threshold value;
The switching module, for when the threshold value judgment module judging result, which is, is, by virtual IP address from direction The IP address of the database to be migrated is switched to the IP address for being directed toward the target database;
The migration judgment module finishes and the target data for judging whether the direction of the virtual IP address has switched Whether library, which completes, migrates;
The read-write transferring module, in the case where the migration judgment module judging result, which is, is, user to be cut Target database is changed to be written and read.
Preferably, the full backup and the transaction journal be respectively stored in document storage system or source environment or In person's target environment.
Preferably, the document storage system is distributed file system.
Preferably, the loading module, is specifically used for:
Operation note according to each time point user recorded in the transaction journal to database, from apart from described complete The operation note that the time of amount backup generation is primary the latest starts, and updates target database one by one according to every operation note, directly It is finished to according to apart from the nearest transaction journal update of current time.
Preferably, the switching module, is also used to:
In the case where the threshold value judgment module judging result is no situation, the transferring module is triggered.
Preferably, the threshold value judgment module, is specifically used for:
When the target database reads an operation note in the transaction journal, the operation note is calculated The difference of timestamp and present system time, it is described if the time difference is equal to or less than the pre-set threshold value Target database and the difference of the database to be migrated reach preset threshold value;If the time difference sets in advance greater than described The threshold value set, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
In order to achieve the above objectives, the embodiment of the invention discloses a kind of database migration methods, comprising:
Database migration instruction is received, determines the source environment of database to be migrated, and create target environment;
Judge whether the difference of target database and database to be migrated in the target environment is equal to or less than in advance The threshold value of setting;
If so, virtual IP address to be switched to the IP address for being directed toward the target database;
Judge the direction of the virtual IP address whether switched finish and the target database complete migration;
It is written and read if it is, user is switched to target database.
Preferably, the creation target environment, further includes:
The last full backup to the database to be migrated is obtained, at least adds the last full backup It is downloaded in target environment;
After the completion of loading the last full backup, using described to be migrated in the target database in target environment The transaction journal of database is migrated.
Preferably, described the step of virtual IP address is switched to the IP address for being directed toward the target database, comprising: described to incite somebody to action Virtual IP address is switched to the IP address for being directed toward the target database from the IP address for being directed toward the database to be migrated.
In order to achieve the above objectives, the embodiment of the invention discloses a kind of database migration devices, comprising: migration command reception Module, loading module, transferring module, threshold value judgment module, switching module, migration judgment module and read-write transferring module, wherein
The migration command reception module, library migration instruction, determines the source environment of database to be migrated for receiving data, And create target environment;
The threshold value judgment module, for judging the difference of the target database in the target environment Yu database to be migrated Not whether not to be equal to or less than pre-set threshold value;
The switching module, for when the threshold value judgment module judging result, which is, is, virtual IP address to be switched to It is directed toward the IP address of the target database;
The migration judgment module finishes and the target data for judging whether the direction of the virtual IP address has switched Whether library, which completes, migrates;
The read-write transferring module, in the case where the migration judgment module judging result, which is, is, user to be cut Target database is changed to be written and read.
Preferably, after migration command reception module, further includes:
The loading module at least will be described for obtaining the last full backup to the database to be migrated The last full backup is loaded into target environment;
The transferring module, for target data after the completion of loading the last full backup, in target environment It is migrated on library using the transaction journal of the database to be migrated.
Preferably, the loading module, is specifically used for:
Operation note according to each time point user recorded in the transaction journal to database, from apart from described complete The operation note that the time of amount backup generation is primary the latest starts, and updates target database one by one according to every operation note, directly It is finished to according to apart from the nearest transaction journal update of current time.
Preferably, migration judgment module, is also used to switch virtual IP address from the IP address for being directed toward the database to be migrated For the IP address for being directed toward the target database.
Preferably, the full backup and the transaction journal be respectively stored in document storage system or source environment or In person's target environment.
Preferably, the document storage system is distributed file system.
Preferably, the switching module, is also used to:
In the case where the threshold value judgment module judging result is no situation, the transferring module is triggered.
Preferably, the threshold value judgment module, is specifically used for:
When the target database reads an operation note in the transaction journal, the operation note is calculated The difference of timestamp and present system time, it is described if the time difference is equal to or less than the pre-set threshold value Target database and the difference of the database to be migrated reach preset threshold value;If the time difference sets in advance greater than described The threshold value set, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
As seen from the above technical solutions, the embodiment of the invention provides a kind of database migration method and devices, in mesh It marks and is loaded in environment in the environment of source to the last full backup of database, according to the transaction journal of database in the environment of source, Gradually by the database migration in target environment to database unanimous circumstances in the environment of source, then using IP it is virtual, will use Family is switched to the operation of source environment and operates to the database of target environment, to realize the process in database migration In, energy graceful migration database does not interfere user to the read-write operation of database.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is the first flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 2 is second of flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 3 is the third flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 4 is the 4th kind of flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 5 is the 5th kind of flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 6 is the 6th kind of flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 7 is the 7th kind of flow diagram of database migration method provided in an embodiment of the present invention;
Fig. 8 is a kind of structural schematic diagram of database migration device provided in an embodiment of the present invention;
Fig. 9 is a kind of structural schematic diagram of database migration system provided in an embodiment of the present invention.
Specific embodiment
The embodiment of the invention provides a kind of database migration system, which includes: database in the environment of source, target Database, document storage system, virtual IP address management module in environment.Convenient for style of writing, the database in the environment of source is referred to as Source database, the database in target environment are referred to as target database, and the database in thermal environment is referred to as dsc data library.
Specifically, database migration system can also include the database in thermal environment.Create one it is complete with source environment The thermal environment migrated entirely, if source database does any change and update, thermal environment database real-time update keeps data complete Unanimously.
Specifically, environment refers to that database runs relied on calculating, network, storage, the relevant system of operating system Arrange the software and hardware resources being relatively isolated.Source environment refers to the source environment of migration.Target environment refers to the target ring of migration Border.
Specifically, document storage system can be distributed file system.
Specifically, virtual IP address management module is by one virtual ip address of setting to user's access originator environment and target environment In database IP address be managed, can be convenient realize IP address switching.Virtual ip address (VIP) be one not with spy Determine the connected IP address of network interface card (NIC) in computer or a computer.Data packet is with being sent to this VIP Location, specific database IP address is directed toward in the address VIP, so that all data still pass through true network interface.
As shown in figure 9, user or tenant can be written and read the source database in the environment of source.In distributed document In system, source database is stored in the full backup database of various time points and the transaction journal of source database.When need When migrating to source database, target environment is created.The last full backup database is loaded in target environment, Then according to the transaction journal of the source database obtained from distributed file system, by full backup database in target environment Migrate into the target database smaller and smaller with source database difference.When target database genbank database difference reaches one in advance When the threshold value being first arranged, virtual IP address is switched to finger from the IP address (IP1) for being directed toward source database using virtual IP address management module To the IP address (IP2) of target database, it is directed toward in the time of address in switching virtual IP address, target database continues to complete migration Process has been to target data when user is written and read again at this time until completely the same with source environment data base data Library is written and read.
The technical solution of this database migration, the database after can not only guaranteeing migration is with one mould one of source database Sample, and the time that user can not be written and read database is extremely short, only using virtual IP address management module by source The extremely short time user of this section of IP address that the IP address of environment data base is switched to target environment database can not be to data Library is written and read, this extremely short time can not be perceived by the user, and does not influence the smooth read-write operation of user, very It is practical.And during this period, target database still completes the migration work with source database.
In practical applications, the source environment of database to be migrated and target environment can be same environment, can not also be Same environment, wherein the source environment and target environment of database to be migrated are not same environment, comprising: database to be migrated Source environment and target environment be not in same physical machine;Or the source environment and target environment of database to be migrated are in same object Reason machine, but an environment carries out framework based on the operating platform of physical machine, and one with the behaviour in the virtual machine in physical machine Make to carry out framework based on platform;Or the source environment and target environment of database to be migrated be in same physical machine, but two rings Framework is carried out based on operating platform of the border in the different virtual machine in physical machine.Conversely, the source environment of database to be migrated It is same environment with target environment.
In practical applications, by the way of generally being combined using both full backup and incremental backup or full backup and difference The mode or full backup, differential backup and incremental backup triplicity mode that both amount backups combine, carry out source database Backup.Wherein, full backup refers to completely is backed up to entire database.Incremental backup refers to every time only backup upper one The data modified after secondary backup.Differential backup refers to the data for only backing up modified after last full backup every time.
In practical applications, in order to avoid the occupancy of system resource, a kind of backup can be only set at same time point.
The embodiment of the invention provides a kind of database migration methods, and this method comprises the following steps: receiving database and move Instruction is moved, determines the source environment of database to be migrated, and create target environment;Judge the target database in the target environment Whether it is equal to or less than pre-set threshold value with the difference of database to be migrated;Institute is directed toward if so, virtual IP address is switched to State the IP address of target database;Judge the direction of the virtual IP address whether switched finish and the target database completion move It moves;It is written and read if it is, user is switched to target database.
Specifically, further include following steps after the creation target environment: obtaining to the database to be migrated most The last full backup is at least loaded into target environment by a nearly full backup;Loading the last full dose After the completion of backup, migrated in the target database in target environment using the transaction journal of the database to be migrated.
Specifically, described the step of virtual IP address is switched to the IP address for being directed toward the target database, can be will be empty Quasi- IP is switched to the IP address for being directed toward the target database from the IP address for being directed toward the database to be migrated.
Specifically, virtual IP address management module realizes the switching of IP address by modification binding.
The embodiment of the invention also provides a kind of database migration methods, comprising: receive database migration instruction, determine to The source environment in migrating data library, and create target environment;The last full backup to the database to be migrated is obtained, until The last time described in major general, full backup was loaded into target environment;After the completion of loading the last full backup, in target It is migrated in target database in environment using the transaction journal of the database to be migrated;Judge the target database Whether it is equal to or less than pre-set threshold value with the difference of database to be migrated;If so, by virtual IP address from be directed toward it is described to The IP address in migrating data library is switched to the IP address for being directed toward the target database;Whether to judge the direction of the virtual IP address Switching finishes and the target database completes migration;It is written and read if it is, user is switched to target database.
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
Fig. 1 is the first flow diagram of database migration method provided in an embodiment of the present invention, may include:
S101: database migration instruction is received, determines the source environment of database to be migrated, and create target environment;
Illustratively, in embodiments of the present invention, it is assumed that the entitled xxx of database to be migrated, the database is in physics It runs, is intended to by the database migration into physical machine B on machine A, then the source environment of xxx database is physical machine A, and target environment is Physical machine B.
S102: obtaining the last full backup to the database to be migrated, at least by the last full dose Backup is loaded into target environment;
Specifically, the last full backup, it can be understood as reliable the last time full backup data.If recently Primary full backup work is not yet completed, then belongs to insecure full backup data, can look for again a little later The full backup data completed are backed up as the last full backup.
Specifically, backup is the operation carried out to source environment data base, and load is the behaviour carried out to target environment database Make.
Specifically, database backup method is included in pre-set database full-volume BACKUP TIME point, to database into Row full backup, between the backup of database full-volume twice or whole process records the modification to database, generates transaction journal.
Specifically, the full backup of database has many parts, can store in document storage system.In addition, source number It can also be backuped in document storage system according to the transaction journal in library.If document storage system is distributed file system, The full backup for the database that different time generates, can store in distributed file system.
Specifically, target environment needs full backup database to be loaded that can obtain from the environment of source, can also be from source It is obtained in the hot copy of environment.In order to avoid source carrying capacity of environment is overweight, it is standby that we can obtain full dose from document storage system Part database.Wherein, the hot copy of source environment is to create the Database Replica migrated completely with source environment, referred to as hot Environment data base.If source database does any change and update, thermal environment database real-time update keeps data complete one It causes.
Realize the migration of database, it is intended that create target database in target environment, finally make target data Library and the data in source database are completely the same.
For this purpose, a specific embodiment is, we are by the last full backup data of source database Library is loaded into target environment, then according to transaction journal, by the last full backup database migration at source database Data are completely the same.
For this purpose, six specific embodiments are that (1) is in practical applications, standby using full backup and increment The mode that both parts combine, backs up database in the environment of source, then being loaded in target environment to database also needs By the way of the combination of both full backup and incremental backup, the embodiment that provides referring to fig. 2;(2) in practical applications, it uses The mode that both full backup and differential backup combine, backs up database in the environment of source, then the logarithm in target environment Being loaded according to library also needs in such a way that both full backup and differential backup combine, the embodiment provided referring to Fig. 3;(3) In practical applications, by the way of full backup, differential backup and incremental backup triplicity, to database in the environment of source into Row backup, then being loaded in target environment to database also needs using full backup, differential backup and incremental backup three In conjunction with mode, the embodiment provided referring to fig. 4;(4) in view of in practical applications, in target environment to DB Backup into Row load needs the time, starts this period completed to DB Backup load in DB Backup load, and source environment may Database can be backed up again, these backups also need to be loaded into target environment;Using full backup and incremental backup two The mode that person combines, backs up database in the environment of source, then being loaded in target environment to database also needs to use The mode that both full backup and incremental backup combine, the embodiment provided referring to Fig. 5;(5) it considers in practical applications, mesh Load is carried out to DB Backup in mark environment and needs the time, starts to DB Backup to load to complete in DB Backup load This period, may back up again to database in the environment of source, these backups also need to be loaded into target environment; By the way of the combination of both full backup and differential backup, database in the environment of source is backed up, then in target environment Being loaded to database also needs in such a way that both full backup and differential backup combine, the embodiment provided referring to Fig. 6; (6) it in view of in practical applications, carrying out load to DB Backup in target environment and needing the time, is loaded in DB Backup Start this period completed to DB Backup load, database may be backed up again in the environment of source, these Backup also needs to be loaded into target environment;In practical applications, using full backup, differential backup and incremental backup triplicity Mode, database in the environment of source is backed up, then database is loaded in target environment also need using full dose it is standby The mode of part, differential backup and incremental backup triplicity is loaded, the embodiment provided referring to Fig. 7.
S103: after the completion of loading the last full backup, using described in the target database in target environment The transaction journal of database to be migrated is migrated;
Wherein, full backup and transaction journal are respectively stored in document storage system or source environment or target environment In.Specifically, document storage system is distributed file system.
Specifically, applying institute in the target database in target environment after the completion of loading the last full backup The transaction journal for stating database to be migrated is migrated, can be according to each time point user couple recorded in the transaction journal The operation note of database, since the time generated apart from the full backup operation note primary the latest, according to every Operation note updates target database one by one, finishes until according to apart from the nearest transaction journal update of current time.
Specifically, it is migrated in target database using the transaction journal of source database, for gradually reducing target The difference of database and source database data.
Specifically, target environment needs full backup database to be loaded and transaction journal that can obtain from the environment of source , it can also be obtained from the hot copy of source environment.In order to avoid source carrying capacity of environment is overweight, we can be from document storage system Middle acquisition full backup database and transaction journal.In addition, transaction journal and full backup database can be respectively stored in These above-mentioned different positions, also can store in identical position.It is stored in different positions, to same when can reduce migration Load caused by the access of one equipment.Preferably, thermal environment obtains data from the environment of source, keeps data one with source environment Cause, distributed file system obtains data from thermal environment, store full backup database and transaction journal, target environment from point Full backup database and transaction journal are obtained in cloth file system.
Specifically, the method for migration is the operation according to each time point user recorded in transaction journal to database Record, since time record primary the latest, updates target database according to every operation note, until according to nearest one by one One transaction journal update finishes.
Database file can be divided into data file and transaction journal.Repairing with transaction log record data in the database Change operation, every log recording therein perhaps record performed logical operation or record modified data preceding picture and After image.Before seem operation execute before data duplicate;After image is the data duplicate after operation executes.
S104: judge whether the target database and the difference of database to be migrated are equal to or less than pre-set threshold Value, if so, S105 is executed, if not, executing S103;
Specifically, it is pre-set to judge whether the difference of the target database and database to be migrated is equal to or less than Threshold value can calculate the operation note when the target database reads an operation note in the transaction journal Timestamp and present system time difference, if the time difference be equal to or less than the pre-set threshold value, institute The difference for stating target database and the database to be migrated reaches preset threshold value;If the time difference is greater than described preparatory The threshold value of setting, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
Since target database needs are finally consistent with source database, it is therefore desirable to judge target database and source number According to the difference in library.Since user is at this time also constantly being written and read source data, transaction journal is constantly updating, because If this target database and the difference of source database are not up to pre-set threshold value, newest affairs day is continued to search Will migrates target database according to transaction journal.When target database genbank database difference reaches pre-set When threshold value, virtual IP address is switched to the IP address for being directed toward target database from the IP address for being directed toward source database.
Specifically, about judging whether the difference of target database and source database reaches the method for pre-set threshold value It is, since target database restores target database by transaction journal one by one, when target database is read in transaction journal When one record, the timestamp of this record and the difference of present system time are calculated, if the time difference is equal to or less than in advance If threshold value, then target database and the difference of source database reach preset threshold value, if the time difference be greater than preset threshold Value, then target database and the difference of source database are not up to preset threshold value.
S105: virtual IP address is switched to from the IP address for being directed toward the database to be migrated and is directed toward the target database IP address;
S106: judge the direction of the virtual IP address whether switched finish and the target database complete migration, if It is to execute S107;
Specifically, the method for judging whether target database completes migration is that target database can not read more A new transaction journal.
Specifically, target database does not still stop working, also in the data for continuing to further itself with source database Difference, when virtual IP address carries out IP switching, source database stops write service, but can be accessed by the user and carry out read operation, Until target environment is all applied to the data of transaction journal in target database, lead to the data of target database completely etc. In the data of source database, then IP is switched to the IP address of the target database by virtual IP address management module.
S107: user is switched to target database and is written and read.
Illustratively, it is assumed that the source environment of xxx database is A physical machine, IP address 192.168.0.45, target ring Border be B physical machine, IP address 192.168.0.25, user pass through virtual ip address 124.193.134.192 access originator ring Xxx database in the A physical machine of border, i.e. IP address 192.168.0.45 are externally mapped as virtual ip address 124.193.134.192, it is migrated in B physical machine in database, only IP address 192.168.0.25 need to be externally mapped as Virtual ip address 124.193.134.192 can be realized user and pass through outer net IP address 124.193.134.192 access target ring Xxx database in the B physical machine of border.
The above-mentioned direction IP address to virtual IP address, which modifies can be, will be directed toward the access of database described in the environment of source Link is modified to point to the access link of database described in target environment, the database-name and object being practically applicable in physical machine B The identical situation of xxx database-name in reason machine A, if the xxx number in database-name and physical machine A in physical machine B It is not identical according to library name, then it needs that the database-name in physical machine B is first changed to xxx database.
If the source environment and target environment of xxx database are same environment, the number in target environment is renamed According to the title in library: the database-name in target environment is revised as to the title of database described in the environment of source.It is exemplary , it is assumed that the source environment of xxx database is A physical machine, and target environment is also A physical machine, since database is not in same environment It can bear the same name, therefore when carrying out database migration, need newly-built and xxx database database not of the same name, it is assumed that newdata Library name is known as yyy, will be loaded into yyy database in the environment of source to the backup of xxx database, and the load of pending data library is completed, will Xxx database is deleted from A physical machine, and yyy database is renamed as xxx database, it can completes moving for xxx database It moves.
Using embodiment illustrated in fig. 1 of the present invention, realizes during database migration, do not interfere user to database It is operated.
In view of being backed up in practical application to database in the environment of source, full backup and incremental backup can be used The mode that the two combines, then being loaded in target environment to database also needs to tie using both full backup and incremental backup The mode of conjunction, embodiment shown in Figure 2, wherein full backup refers to completely to be backed up to entire database, increment Backup refers to the data for only backing up modified after last backup every time.In practical applications, accounting in order to avoid system resource With a kind of backup can only be arranged at same time point.
In the present embodiment, the last time full backup in the environment of source to the database is determined, at least by described in most A full backup is loaded into target environment the specific implementation of (S102) afterwards, comprising:
S10210: the last time full backup in the environment of source to the database is determined;
S10211: judge whether the last time full backup is standby to the last time of the database in the environment of source Part;If so, S10212 is executed, if not, executing S10213;
S10212: the last time full backup is loaded into target environment;
S10213: the determining time T0 for receiving the database migration instruction to the last time full backup time To the incremental backup of the database in source environment between T1, the backup sequence incrementally backed up, by the last time Full backup and T0 are loaded into target environment to the incremental backup between T1.
If the time T0 for receiving database migration instruction is 6:20, determine in the environment of source to xxx database most Primary backup is the full backup that 6:00 is carried out afterwards, judges that the full backup that 6:00 is carried out is in the environment of source to the database Last time backup, then the full backup of 6:00 is loaded into target environment.
In view of being backed up in practical application to database in the environment of source, full backup and differential backup can be used The mode that the two combines, then being loaded in target environment to database also needs to tie using both full backup and differential backup The mode of conjunction, embodiment shown in Figure 3, wherein full backup refers to completely to be backed up to entire database, residual quantity Backup refers to the data for only backing up modified after last full backup every time.In practical applications, in order to avoid system resource Occupancy, at same time point, a kind of backup can be only set.
In the present embodiment, the last time full backup in the environment of source to the database is determined, at least by described in most A full backup is loaded into target environment the specific implementation of (S102) afterwards, comprising:
S10220: the last time full backup in the environment of source to the database is determined;
S10221: judge whether the last time full backup is standby to the last time of the database in the environment of source Part;If so, S10222 is executed, if not, executing S10223;
S10222: the last time full backup is loaded into target environment;
S10223: the determining time T0 for receiving the database migration instruction to the last time full backup time To the last time differential backup of the database in source environment between T1, by the last time full backup and it is described most A differential backup is loaded into target environment afterwards.
If the time T0 for receiving database migration instruction is 6:20, determine in the environment of source to xxx database most Primary backup is the full backup that 6:00 is carried out afterwards, judges that the full backup that 6:00 is carried out is in the environment of source to the database Last time backup, then the full backup of 6:00 is loaded into target environment.
In view of being backed up to database in the environment of source in practical application, can using full backup, differential backup and The mode of incremental backup triplicity, then being loaded in target environment to database also needs to use full backup, residual quantity standby The mode of part and incremental backup triplicity, embodiment shown in Figure 4, wherein full backup refers to entire database It is completely backed up, incremental backup refers to the data for only backing up modified after last backup every time, and differential backup refers to often Secondary is backed up the data modified after last full backup.In practical applications, in order to avoid the occupancy of system resource, same A kind of backup can be only arranged in one time point.
In the present embodiment, the last time full backup in the environment of source to the database is determined, at least by described in most A full backup is loaded into target environment the specific implementation of (S102) afterwards, comprising:
S10230: it determines in the environment of source and the last time of the database is backed up;
S10231: judge whether the last time full backup is standby to the last time of the database in the environment of source Part;If so, S10232 is executed, if not, executing S10233;
S10232: the last time full backup is loaded into target environment;
S10233: the determining time T0 for receiving the database migration instruction to the last time full backup time To the last time differential backup of the database in source environment between T1, when determining T0 to the last time differential backup Between in source environment between T2 to the incremental backup of the database, the backup sequence incrementally backed up, will it is described last Secondary full backup, the last time differential backup and T0 are loaded into target environment to the incremental backup between T2.
If the time T0 for receiving database migration instruction is 9:45, since there are the incremental backup of 8:00 and 9:30 Differential backup judges that the full backup that 6:00 is carried out is not to back up in the environment of source to the last time of the database, then really The differential backup that 9:45 is 9:30 to the last time differential backup between 6:00 is made, determines 9:45 to not depositing between 9:30 The differential backup of the full backup of 6:00 and 9:30 is loaded into target environment in incremental backup.
If the time T0 for receiving database migration instruction is 8:45, due to judging there are the incremental backup of 8:00 The full backup that 6:00 is carried out is not to back up in the environment of source to the last time of the database, it is determined that go out 8:45 to 6:00 it Between be not present differential backup, determine 8:45 to the incremental backup between 6:00 be 8:00 incremental backup, by the full dose of 6:00 The incremental backup of backup and 8:00, is loaded into target environment.
If the time T0 for receiving database migration instruction is 6:20, determine in the environment of source to xxx database most Primary backup is the full backup that 6:00 is carried out afterwards, judges that the full backup that 6:00 is carried out is in the environment of source to the database Last time backup, then the full backup of 6:00 is loaded into target environment.
It is standby in database in view of in practical applications, carrying out load to DB Backup in target environment and needing the time Part load starts this period completed to DB Backup load, and source environment may again back up database, this A little backups also need to be loaded into target environment;By the way of the combination of both full backup and incremental backup, to number in the environment of source It is backed up according to library, then being loaded in target environment to database also needs to combine using both full backup and incremental backup Mode, embodiment shown in Figure 5.Wherein, full backup refers to completely is backed up to entire database, and increment is standby Part refers to the data for only backing up modified after last backup every time.In practical applications, in order to avoid the occupancy of system resource, At same time point, a kind of backup can be only set.
In the present embodiment, the last time full backup in the environment of source to the database is determined, at least by described in most A full backup is loaded into target environment the specific implementation of (S102) afterwards, comprising:
S10240: determining the last time full backup in the environment of source to the database, by the last time full dose Backup is loaded into target environment;
S10241: the judgement last time backup load deadline is standby to whether there is full dose between the secondary BACKUP TIME Part, if so, S10242 is executed, if not, executing S10243;
Assuming that loading in full backup of the 10:20 to 6:00, which is loaded the used time 2 hours, and the deadline reaches 12:20 carries out a full backup in 12:00 to database xxx in the environment of source again;
Assuming that loading in full backup of the 10:20 to 6:00, which is loaded the used time 1 hour, and the deadline reaches 11:20 does not carry out full backup again to database xxx in the environment of source.
S10242: the last time full backup in this time to the database is determined;The secondary full backup is added It is downloaded in target environment, continues to execute S10241;
If loaded in full backup of the 10:20 to 6:00, which is loaded the used time 2 hours, and the deadline reaches 12:20 carries out a full backup in 12:00 to database xxx in the environment of source again;
The full backup carried out to the last time full backup 12:00 of database xxx is determined, by the full dose of 12:00 In backup load target environment, continue to judge that the last time backup load deadline whether there is between the secondary BACKUP TIME Full backup.
S10243: judgement last time backup load the deadline between the secondary full backup time whether there is increment Backup, if so, S10244 is executed, if not, executing S103;
If loaded in full backup of the 10:20 to 6:00, which is loaded the used time 1 hour, and the deadline reaches 11:20 does not carry out full backup again to database xxx in the environment of source;
Then determine 11:20 to the incremental backup between 6:00: the incremental backup of 8:00 and the incremental backup of 10:00.
S10244: the backup sequence incrementally backed up will load the incremental backup of the database in this time Into target environment, S10241 is continued to execute.
The incremental backup of the incremental backup of the step S10243 8:00 determined and 10:00 is loaded into target environment, After having loaded the incremental backup of 10:00, continue judgement last time backup load the deadline to the secondary BACKUP TIME it Between whether there is full backup, to the last the primary backup load deadline between this time backup there is no full backup, Also incremental backup is not present.
It is standby in database in view of in practical applications, carrying out load to DB Backup in target environment and needing the time Part load starts this period completed to DB Backup load, and source environment may again back up database, this A little backups also need to be loaded into target environment;By the way of the combination of both full backup and differential backup, to number in the environment of source It is backed up according to library, then being loaded in target environment to database also needs to combine using both full backup and differential backup Mode, embodiment shown in Figure 6, wherein full backup refers to completely to be backed up to entire database, and residual quantity is standby Part refers to the data for only backing up modified after last full backup every time, in practical applications, in order to avoid system resource It occupies, a kind of backup can be only set at same time point.
In the present embodiment, the last time full backup in the environment of source to the database is determined, at least by described in most A full backup is loaded into target environment the specific implementation of (S102) afterwards, comprising:
S10250: determining the last time full backup in the environment of source to the database, by the last time full dose Backup is loaded into target environment;
S10241: the judgement last time backup load deadline is standby to whether there is full dose between the secondary BACKUP TIME Part, if so, S10252 is executed, if not, executing S10253;
Assuming that loading in full backup of the 10:20 to 6:00, which is loaded the used time 2 hours, and the deadline reaches 12:20 carries out a full backup in 12:00 to database xxx in the environment of source again;
Assuming that loading in full backup of the 10:20 to 6:00, which is loaded the used time 1 hour, and the deadline reaches 11:20 does not carry out full backup again to database xxx in the environment of source.
S10252: the last time full backup in this time to the database is determined;The secondary full backup is added It is downloaded in target environment, continues to execute S10251;
If loaded in full backup of the 10:20 to 6:00, which is loaded the used time 2 hours, and the deadline reaches 12:20 carries out a full backup in 12:00 to database xxx in the environment of source again;
The full backup carried out to the last time full backup 12:00 of database xxx is determined, by the full dose of 12:00 In backup load target environment, continue to judge that the last time backup load deadline whether there is between the secondary BACKUP TIME Full backup.
S10253: judgement last time backup load the deadline between the secondary full backup time whether there is residual quantity Backup, if so, S10254 is executed, if not, executing S103;
If loaded in full backup of the 10:20 to 6:00, which is loaded the used time 1 hour, and the deadline reaches 11:20 does not carry out full backup again to database xxx in the environment of source, judges that 11:20 is standby to there are residual quantity between 6:00 Part.
S10254: it determines the last time differential backup in this time to the database, which is added It is downloaded in target environment, continues to execute S10251.
Determine 11:20 to the last time differential backup between 6:00: the differential backup of 10:00, by the differential backup It is loaded into target environment, after having loaded the differential backup of 10:00, continues the judgement last time backup load deadline To whether there is full backup between the secondary BACKUP TIME, to the last the primary backup load deadline is between this time backup There is no full backup, and differential backup is also not present.
It is standby in database in view of in practical applications, carrying out load to DB Backup in target environment and needing the time Part load starts this period completed to DB Backup load, and source environment may again back up database, this A little backups also need to be loaded into target environment;By the way of full backup, differential backup and incremental backup triplicity, to source Database is backed up in environment, then being loaded in target environment to database also needs using full backup, differential backup With the mode of incremental backup triplicity, embodiment shown in Figure 7, wherein full backup refer to entire database into The complete backup of row, incremental backup refer to the data for only backing up modified after last backup every time, and differential backup refers to every time The data modified after last full backup are only backed up, in practical applications, in order to avoid the occupancy of system resource, same A kind of backup can be only arranged in time point.
In the present embodiment, the last time full backup in the environment of source to the database is determined, at least by described in most A full backup is loaded into target environment the specific implementation of (S102) afterwards, comprising:
S10260: determining the last time full backup in the environment of source to the database, by the last time full dose Backup is loaded into target environment;
S10261: the judgement last time backup load deadline is standby to whether there is full dose between the secondary BACKUP TIME Part, if so, S10262 is executed, if not, executing S10263;
Assuming that loading in full backup of the 10:20 to 6:00, which is loaded the used time 2 hours, and the deadline reaches 12:20 carries out a full backup in 12:00 to database xxx in the environment of source again;
Assuming that loading in full backup of the 10:20 to 6:00, which is loaded the used time 1 hour, and the deadline reaches 11:20 does not carry out full backup again to database xxx in the environment of source.
S10262: the last time full backup in this time to the database is determined;The secondary full backup is added It is downloaded in target environment, continues to execute S10261;
If loaded in full backup of the 10:20 to 6:00, which is loaded the used time 2 hours, and the deadline reaches 12:20 carries out a full backup in 12:00 to database xxx in the environment of source again;
The full backup carried out to the last time full backup 12:00 of database xxx is determined, by the full dose of 12:00 In backup load target environment, continue to judge that the last time backup load deadline whether there is between the secondary BACKUP TIME Full backup.
S10263: judgement last time backup load the deadline between the secondary full backup time whether there is residual quantity Backup, if so, S10264 is executed, if not, executing S10265;
If loaded in full backup of the 10:20 to 6:00, which is loaded the used time 1 hour, and the deadline reaches 11:20 does not carry out full backup again to database xxx in the environment of source, judges that 11:20 is standby to there are residual quantity between 6:00 Part.
S10264: it determines the last time differential backup in this time to the database, which is added It is downloaded in target environment, continues to execute S10261;
Determine 11:20 to the last time differential backup between 6:00: the differential backup of 9:30 adds the differential backup It is downloaded in target environment, after having loaded the differential backup of 9:30, continues the judgement last time backup load deadline extremely It whether there is full backup between the secondary BACKUP TIME.
S10265: the judgement last time backup load deadline is standby to whether there is increment between the secondary BACKUP TIME Part, if so, S10266 is executed, if not, executing S103;
Assuming that in S10264 step 9:30 the differential backup deadline be 11:40, judge that 9:30 is deposited between 11:40 In incremental backup.
S10266: the backup sequence incrementally backed up will load the incremental backup of the database in this time Into target environment, S10261 is continued to execute.
Determining 9:30, there are incremental backups between 11:40: the incremental backup of 10:00 adds the incremental backup of 10:00 It is downloaded in target environment, continues judgement and judge that the last time backup load deadline whether there is between the secondary BACKUP TIME Full backup, to the last the primary backup load deadline does not deposit between the secondary BACKUP TIME there is no full backup, also In differential backup, there is not yet incremental backup.
A kind of database migration method, comprising steps of
S801: database migration instruction is received, determines the source environment of database to be migrated, and create target environment;
S802: obtaining the last full backup to the database to be migrated, at least by the last full dose Backup is loaded into target environment;
S803: described wait move in the target database in target environment after the completion of loading the last full backup The transaction journal for moving database is migrated;
Specifically, after the completion of loading the last full backup, in the target database in target environment it is described to The transaction journal in migrating data library is migrated, and specific method is: being used according to each time point recorded in the transaction journal Operation note of the family to database, since the time generated apart from the full backup operation note primary the latest, according to Every operation note updates target database one by one, finishes until according to apart from the nearest transaction journal update of current time.
S804: judging whether the target database and the difference of database to be migrated reach pre-set threshold value, when When the target database and the database difference to be migrated are equal to or less than the pre-set threshold value, by virtual IP address from The IP address for being directed toward the database to be migrated is switched to the IP address for being directed toward the target database;
Specifically, judge the difference of the target database and database to be migrated whether reach pre-set threshold value it Afterwards, it if the target database and the difference of the database to be migrated are greater than pre-set threshold value, returns and executes institute It states after the completion of loading the last full backup, the thing of the database to be migrated in the target database in target environment The step of business log is migrated.
Specifically, judge whether the target database and the difference of database to be migrated reach pre-set threshold value Method is: when the target database reads an operation note in the transaction journal, calculating the operation note The difference of timestamp and present system time, it is described if the time difference is equal to or less than the pre-set threshold value Target database and the difference of the database to be migrated reach preset threshold value;If the time difference sets in advance greater than described The threshold value set, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
S805: judge whether the target database is completed to migrate;
S806: finishing if the direction of the virtual IP address has switched, and migration is completed in the target database, then will User is switched to target database and is written and read.
Specifically, the full backup and the transaction journal be respectively stored in document storage system or source environment or In person's target environment.
Specifically, the document storage system is distributed file system.
Fig. 8 is a kind of structural schematic diagram of database migration device provided in an embodiment of the present invention, may include: that migration refers to Receiving module 801, loading module 802, transferring module 803, threshold value judgment module 804, switching module 805, migration is enabled to judge mould Block 806 and read-write transferring module 807, wherein
Command reception module 801 is migrated, library migration instruction, determines the source environment of database to be migrated for receiving data, And create target environment;
Loading module 802, for obtaining the last full backup to the database to be migrated, at least by described in most A nearly full backup is loaded into target environment;
The loading module 802 of the embodiment of the present invention, specifically can be used for:
Operation note according to each time point user recorded in the transaction journal to database, from apart from described complete The operation note that the time of amount backup generation is primary the latest starts, and updates target database one by one according to every operation note, directly It is finished to according to apart from the nearest transaction journal update of current time.
Transferring module 803, for target database after the completion of loading the last full backup, in target environment On migrated using the transaction journal of the database to be migrated;
Threshold value judgment module 804, for judging whether the difference of the target database and database to be migrated reaches pre- The threshold value being first arranged;
The threshold value judgment module 804 of the embodiment of the present invention, specifically can be used for:
When the target database reads an operation note in the transaction journal, the operation note is calculated The difference of timestamp and present system time, it is described if the time difference is equal to or less than the pre-set threshold value Target database and the difference of the database to be migrated reach preset threshold value;If the time difference sets in advance greater than described The threshold value set, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
Switching module 805, in the case that the threshold value judgment module judging result be, by virtual IP address from be directed toward institute The IP address for stating database to be migrated is switched to the IP address for being directed toward the target database;
The switching module 805 of the embodiment of the present invention is also used in the case where the threshold value judgment module judging result is no situation, Trigger the transferring module.
Judgment module 806 is migrated, is finished and the target data for judging whether the direction of the virtual IP address has switched Whether library, which completes, migrates;
Transferring module 807 is read and write, in the case where the migration judgment module judging result, which is, is, user to be switched It is written and read to target database.
Specifically, above-mentioned full backup and transaction journal be respectively stored in document storage system or source environment or In target environment.
Specifically, above-mentioned document storage system is distributed file system.
Using embodiment illustrated in fig. 8 of the present invention, realizes during database migration, do not interfere user to database It is operated.
A kind of database migration device of the embodiment of the present invention, comprising: migration command reception module, loading module, migration Module, threshold value judgment module, switching module, migration judgment module and read-write transferring module, wherein
The migration command reception module, library migration instruction, determines the source environment of database to be migrated for receiving data, And create target environment;
The threshold value judgment module, for judging the difference of the target database in the target environment Yu database to be migrated Not whether not to be equal to or less than pre-set threshold value;
The switching module, for when the threshold value judgment module judging result, which is, is, virtual IP address to be switched to It is directed toward the IP address of the target database;The migration judgment module, for judging whether the direction of the virtual IP address has cut It changes and finishes and whether the target database is completed to migrate;
The read-write transferring module, in the case where the migration judgment module judging result, which is, is, user to be cut Target database is changed to be written and read.
Specifically, after migration command reception module, further includes:
The loading module at least will be described for obtaining the last full backup to the database to be migrated The last full backup is loaded into target environment;
The transferring module, for target data after the completion of loading the last full backup, in target environment It is migrated on library using the transaction journal of the database to be migrated.
Specifically, the loading module, for according to each time point user recorded in the transaction journal to data The operation note in library is operated since the time generated apart from the full backup operation note primary the latest according to every Record updates target database one by one, finishes until according to apart from the nearest transaction journal update of current time.
Specifically, judgment module is migrated, is also used to switch virtual IP address from the IP address for being directed toward the database to be migrated For the IP address for being directed toward the target database.
Specifically, the full backup and the transaction journal be respectively stored in document storage system or source environment or In person's target environment.
Specifically, the document storage system is distributed file system.
Specifically, the switching module, is also used to: in the case where the threshold value judgment module judging result is no situation, triggering The transferring module.
Specifically, the threshold value judgment module, is used for: one in the transaction journal is read when the target database When operation note, calculate the timestamp of the operation note and the difference of present system time, if the time difference be equal to or Less than the pre-set threshold value, then the target database and the difference of the database to be migrated reach preset threshold Value;If the time difference is greater than the pre-set threshold value, the target database and the database to be migrated Difference is not up to the pre-set threshold value.
The method and apparatus that the application proposes, by generating reference data, i.e. full backup database and incremental backup thing The business operation log method that combines reduces the consumption to space and realizes matched automatic recovery scheme, overcomes existing The user of technology loses the time of data current time to the last time backup, and the data content of the period is irrecoverable; The data volume of full backup is too big, and with being continuously increased for data volume, server end consumes increasing disadvantage.The application mentions A kind of database migration method and device supplied may operate on virtual machine, also may operate in container, can also run On operating system.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is all made of relevant mode and describes, same and similar portion between each embodiment Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device reality For applying example, since it is substantially similar to the method embodiment, so being described relatively simple, related place is referring to embodiment of the method Part explanation.
Those of ordinary skill in the art will appreciate that all or part of the steps in realization above method embodiment is can It is completed with instructing relevant hardware by program, the program can store in computer-readable storage medium, The storage medium designated herein obtained, such as: ROM/RAM, magnetic disk, CD.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (20)

1. a kind of database migration method characterized by comprising
Database migration instruction is received, determines the source environment of database to be migrated, and create target environment;
The last full backup to the database to be migrated is obtained, is at least loaded into the last full backup In target environment;
After the completion of loading the last full backup, the data to be migrated are applied in the target database in target environment The transaction journal in library is migrated;
Judge whether the target database and the difference of database to be migrated are equal to or less than pre-set threshold value;
If so, virtual IP address to be switched to the IP for being directed toward the target database from the IP address for being directed toward the database to be migrated Address;
Judge the direction of the virtual IP address whether switched finish and the target database complete migration;
It is written and read if it is, user is switched to target database;
Wherein, described to judge whether the target database and the difference of database to be migrated are equal to or less than pre-set threshold Value, comprising:
When reading an operation note in the transaction journal, when calculating the timestamp and current system of the operation note Between difference, if the time difference be equal to or less than the pre-set threshold value, the target database and it is described to The difference in migrating data library reaches preset threshold value;If the time difference is greater than the pre-set threshold value, the mesh The difference of mark database and the database to be migrated is not up to the pre-set threshold value.
2. the method according to claim 1, wherein the full backup and the transaction journal are respectively stored in In document storage system or source environment or target environment.
3. according to the method described in claim 2, it is characterized in that, the document storage system is distributed file system.
4. the method according to claim 1, wherein described after the completion of loading the last full backup, It is migrated in target database in target environment using the transaction journal of the database to be migrated, comprising:
Operation note according to each time point user recorded in the transaction journal to database, from standby apart from the full dose The operation note that the time of part generation is primary the latest starts, and updates target database, Zhi Daoyi one by one according to every operation note Range transaction journal update nearest from current time finishes.
5. the method according to claim 1, wherein the judgement target database and database to be migrated Difference whether be equal to or less than after pre-set threshold value, if the target database and the database to be migrated When difference is greater than pre-set threshold value, return described in executing after the completion of loading the last full backup, in target environment In target database on the step of being migrated using the transaction journal of the database to be migrated.
6. a kind of database migration device characterized by comprising migration command reception module, loading module, transferring module, Threshold value judgment module, switching module, migration judgment module and read-write transferring module, wherein
The migration command reception module, library migration instruction, determines the source environment of database to be migrated, and create for receiving data Build target environment;
The loading module at least will be described nearest for obtaining the last full backup to the database to be migrated One time full backup is loaded into target environment;
The transferring module is used for after the completion of loading the last full backup, in the target database in target environment It is migrated using the transaction journal of the database to be migrated;
The threshold value judgment module, for judging whether the target database and the difference of database to be migrated are equal to or less than Pre-set threshold value;
The switching module, in the case that the threshold value judgment module judging result be, by virtual IP address from described in direction The IP address of database to be migrated is switched to the IP address for being directed toward the target database;
The migration judgment module finishes and the target database is for judging whether the direction of the virtual IP address has switched No completion migration;
The read-write transferring module, in the case where the migration judgment module judging result, which is, is, user to be switched to Target database is written and read;
Wherein, the threshold value judgment module, is specifically used for: when reading an operation note in the transaction journal, calculating The timestamp of the operation note and the difference of present system time, if the time difference is equal to or less than described preset Threshold value, then the difference of the target database and the database to be migrated reaches preset threshold value;If the time difference Greater than the pre-set threshold value, then the target database and the difference of the database to be migrated are not up to described preparatory The threshold value of setting.
7. device according to claim 6, which is characterized in that the full backup and the transaction journal are respectively stored in In document storage system or source environment or target environment.
8. device according to claim 7, which is characterized in that the document storage system is distributed file system.
9. device according to claim 6, which is characterized in that the loading module is specifically used for:
Operation note according to each time point user recorded in the transaction journal to database, from standby apart from the full dose The operation note that the time of part generation is primary the latest starts, and updates target database, Zhi Daoyi one by one according to every operation note Range transaction journal update nearest from current time finishes.
10. device according to claim 7, which is characterized in that the switching module is also used to:
In the case where the threshold value judgment module judging result is no situation, the transferring module is triggered.
11. a kind of database migration method characterized by comprising
Database migration instruction is received, determines the source environment of database to be migrated, and create target environment;
Judge whether the difference of target database and database to be migrated in the target environment is equal to or less than to preset Threshold value;
If so, virtual IP address to be switched to the IP address for being directed toward the target database;
Judge the direction of the virtual IP address whether switched finish and the target database complete migration;
It is written and read if it is, user is switched to target database;
Wherein, described to judge whether the target database and the difference of database to be migrated are equal to or less than pre-set threshold Value, comprising:
When an operation note in the transaction journal for reading the database to be migrated, the time of the operation note is calculated The difference of stamp and present system time, if the time difference is equal to or less than the pre-set threshold value, the target The difference of database and the database to be migrated reaches preset threshold value;If the time difference is greater than described pre-set Threshold value, then the target database and the difference of the database to be migrated are not up to the pre-set threshold value.
12. according to the method for claim 11, which is characterized in that the creation target environment, further includes:
The last full backup to the database to be migrated is obtained, is at least loaded into the last full backup In target environment;
After the completion of loading the last full backup, the data to be migrated are applied in the target database in target environment The transaction journal in library is migrated.
13. according to the method for claim 11, which is characterized in that described be switched to virtual IP address is directed toward the target data The step of IP address in library, comprising: described be switched to virtual IP address from the IP address for being directed toward the database to be migrated is directed toward institute State the IP address of target database.
14. a kind of database migration device characterized by comprising migration command reception module, threshold value judgment module, switching Module, migration judgment module and read-write transferring module, wherein
The migration command reception module, library migration instruction, determines the source environment of database to be migrated, and create for receiving data Build target environment;
The threshold value judgment module, for judging the target database in the target environment and the difference of database to be migrated is It is no to be equal to or less than pre-set threshold value;
The switching module, for when the threshold value judgment module judging result, which is, is, virtual IP address to be switched to direction The IP address of the target database;
The migration judgment module finishes and the target database is for judging whether the direction of the virtual IP address has switched No completion migration;
The read-write transferring module, in the case where the migration judgment module judging result, which is, is, user to be switched to Target database is written and read;
The threshold value judgment module, is specifically used for: when the operation note in the transaction journal for reading the database to be migrated When record, the timestamp of the operation note and the difference of present system time are calculated, if the time difference is equal to or less than institute Pre-set threshold value is stated, then the target database and the difference of the database to be migrated reach preset threshold value;If The time difference is greater than the pre-set threshold value, then the target database and the difference of the database to be migrated do not reach To the pre-set threshold value.
15. device according to claim 14, which is characterized in that after migration command reception module, further includes:
Loading module, for obtaining the last full backup to the database to be migrated, at least by described the last time Full backup is loaded into target environment;
Transferring module, for being applied in the target database in target environment after the completion of loading the last full backup The transaction journal of the database to be migrated is migrated.
16. device according to claim 15, which is characterized in that the loading module is specifically used for:
Operation note according to each time point user recorded in the transaction journal to database, from standby apart from the full dose The operation note that the time of part generation is primary the latest starts, and updates target database, Zhi Daoyi one by one according to every operation note Range transaction journal update nearest from current time finishes.
17. device according to claim 14, which is characterized in that migration judgment module is also used to virtual IP address from direction The IP address of the database to be migrated is switched to the IP address for being directed toward the target database.
18. device according to claim 15, which is characterized in that the full backup and the transaction journal store respectively In document storage system or source environment or target environment.
19. device according to claim 18, which is characterized in that the document storage system is distributed file system.
20. device according to claim 14, which is characterized in that the switching module is also used to:
In the case where the threshold value judgment module judging result is no situation, the transferring module is triggered.
CN201410522064.8A 2014-09-30 2014-09-30 A kind of database migration method and device Active CN105528368B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410522064.8A CN105528368B (en) 2014-09-30 2014-09-30 A kind of database migration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410522064.8A CN105528368B (en) 2014-09-30 2014-09-30 A kind of database migration method and device

Publications (2)

Publication Number Publication Date
CN105528368A CN105528368A (en) 2016-04-27
CN105528368B true CN105528368B (en) 2019-03-12

Family

ID=55770596

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410522064.8A Active CN105528368B (en) 2014-09-30 2014-09-30 A kind of database migration method and device

Country Status (1)

Country Link
CN (1) CN105528368B (en)

Families Citing this family (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106021019A (en) * 2016-05-12 2016-10-12 广西尊达电子商务有限公司 Automatic recovery method for databases
CN106331132A (en) * 2016-08-31 2017-01-11 天津南大通用数据技术股份有限公司 Node replacement method and device in distributed database
CN108021585B (en) * 2016-10-28 2022-01-18 腾讯科技(深圳)有限公司 Distributed data storage method and device
CN108132949B (en) * 2016-12-01 2021-02-12 腾讯科技(深圳)有限公司 Data migration method and device in database cluster
CN108319596A (en) * 2017-01-16 2018-07-24 阿里巴巴集团控股有限公司 A kind of expansion method and device of database
CN108511035A (en) * 2017-02-23 2018-09-07 仁智(苏州)医学研究有限公司 A kind of data managing method and device of hospital information system
CN107391635A (en) * 2017-06-30 2017-11-24 北京奇虎科技有限公司 Data synchronous system and method
CN107391628B (en) * 2017-06-30 2021-04-09 北京奇虎科技有限公司 Data synchronization method and device
CN107357883A (en) * 2017-06-30 2017-11-17 北京奇虎科技有限公司 Data migration method and device
CN107391634B (en) * 2017-06-30 2021-04-09 北京奇虎科技有限公司 Data migration method and device
CN107943572B (en) * 2017-11-16 2019-09-03 平安科技(深圳)有限公司 Data migration method, device, computer equipment and storage medium
CN109842636A (en) * 2017-11-24 2019-06-04 阿里巴巴集团控股有限公司 Cloud service moving method, device and electronic equipment
CN107977466A (en) * 2017-12-21 2018-05-01 广东小天才科技有限公司 A kind of database upgrade method and device
CN108647270A (en) * 2018-04-28 2018-10-12 尚谷科技(天津)有限公司 A method of the Data Migration based on fault-tolerant time daily record
CN109067823A (en) * 2018-06-11 2018-12-21 中国平安人寿保险股份有限公司 A kind of data migration method, device, computer equipment and storage medium
CN109062727B (en) * 2018-06-20 2023-04-14 平安科技(深圳)有限公司 Data synchronization system and method
CN109783571B (en) * 2018-12-13 2023-10-27 平安科技(深圳)有限公司 Data processing method, device, computer equipment and storage medium for isolated environment
CN110019538B (en) * 2019-02-03 2023-09-05 创新先进技术有限公司 Data table switching method and device
CN110633171A (en) * 2019-08-26 2019-12-31 重庆卡歌科技有限公司 JAVA hibernate framework-based log backup remote restoration system and method
CN111104255A (en) * 2019-11-29 2020-05-05 浪潮(北京)电子信息产业有限公司 Intelligent timing cloud backup method, device, equipment and storage medium
CN111400276A (en) * 2020-03-03 2020-07-10 杭州天谷信息科技有限公司 Real-time synchronous database migration device and method
CN111611108A (en) * 2020-05-21 2020-09-01 云和恩墨(北京)信息技术有限公司 Method and device for restoring virtual database
CN111813760B (en) * 2020-05-29 2024-03-26 阿里巴巴集团控股有限公司 Data migration method and device
CN111783141B (en) * 2020-07-02 2021-08-06 深圳市腾盟技术有限公司 Data storage method, device and equipment based on block chain and storage medium
CN112015351B (en) * 2020-10-19 2021-01-29 北京易真学思教育科技有限公司 Data migration method and device, storage medium and electronic equipment
CN112817702A (en) * 2021-02-25 2021-05-18 紫光云技术有限公司 Virtual machine automation rapid cross-architecture migration method
CN113010496B (en) * 2021-03-19 2024-03-08 腾讯云计算(北京)有限责任公司 Data migration method, device, equipment and storage medium
CN113220666B (en) * 2021-05-24 2024-03-08 中国工商银行股份有限公司 Batch processing log playback method, device and system after database migration

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101997911A (en) * 2010-10-21 2011-03-30 中兴通讯股份有限公司 Data migration method and system
CN103530290A (en) * 2012-07-03 2014-01-22 深圳市腾讯计算机系统有限公司 Method and system for data migration among databases

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7065541B2 (en) * 2001-10-10 2006-06-20 International Business Machines Corporation Database migration
US7426559B2 (en) * 2002-05-09 2008-09-16 International Business Machines Corporation Method for sequential coordination of external database application events with asynchronous internal database events

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101997911A (en) * 2010-10-21 2011-03-30 中兴通讯股份有限公司 Data migration method and system
CN103530290A (en) * 2012-07-03 2014-01-22 深圳市腾讯计算机系统有限公司 Method and system for data migration among databases

Also Published As

Publication number Publication date
CN105528368A (en) 2016-04-27

Similar Documents

Publication Publication Date Title
CN105528368B (en) A kind of database migration method and device
CN109074306B (en) Hybrid garbage collection in a distributed storage system
US9753813B1 (en) Data replication snapshots for persistent storage using operation numbers
JP6416279B2 (en) Scalable file storage service
JP6371858B2 (en) Atomic writing for multiple extent operations
US11132350B2 (en) Replicable differential store data structure
US8086807B2 (en) Backup data management method in which differential copy time is taken into account
CN107247619B (en) Live migration of virtual machine method, apparatus, system, storage medium and equipment
US20090019251A1 (en) Dynamic storage pools with thin provisioning
JP5592493B2 (en) Storage network system and control method thereof
MXPA05009273A (en) Method, system, and apparatus for creating an architectural model for generating robust and easy to manage data protection applications in a data protection system.
CN104301360A (en) Method, log server and system for recording log data
CN107209705A (en) Activity rollback for computing environment
JP2016529633A (en) Snapshot and clone replication
JPH04233639A (en) File controlling method and system
CN107066296A (en) The method for cleaning and device of mirror image in a kind of clustered node
US9733869B1 (en) Provisioning a slave for data storage using metadata with updated references
US8112665B1 (en) Methods and systems for rapid rollback and rapid retry of a data migration
US20100106685A1 (en) Method and system for data synchronization
EP3353627B1 (en) Adaptive storage reclamation
JP4693540B2 (en) Database reconfiguration device and database reconfiguration program
US10585627B2 (en) Distributed metadata management in a distributed storage system
CN104216802B (en) Memory database recovery method and device
CN109933632A (en) A kind of data migration method of database, device and equipment
JP5284604B2 (en) Method, system and computer program for storing transient state information

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant