CN109284281A - Method and apparatus for migrating data - Google Patents

Method and apparatus for migrating data Download PDF

Info

Publication number
CN109284281A
CN109284281A CN201811050267.6A CN201811050267A CN109284281A CN 109284281 A CN109284281 A CN 109284281A CN 201811050267 A CN201811050267 A CN 201811050267A CN 109284281 A CN109284281 A CN 109284281A
Authority
CN
China
Prior art keywords
database
data
field
migrating objects
migrating
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.)
Pending
Application number
CN201811050267.6A
Other languages
Chinese (zh)
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 Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201811050267.6A priority Critical patent/CN109284281A/en
Publication of CN109284281A publication Critical patent/CN109284281A/en
Pending legal-status Critical Current

Links

Abstract

The embodiment of the present application discloses the method and apparatus for migrating data.One specific embodiment of the above method includes: the Data Migration instruction for receiving terminal and sending, wherein Data Migration instruction includes migrating objects;Migrating objects are obtained from first database;Information based on migrating objects generates data base manipulation statement;It controls the second database and executes data base manipulation statement, the second database is written into migrating objects.The embodiment realizes the Data Migration between disparate databases.

Description

Method and apparatus for migrating data
Technical field
The invention relates to database technical fields, and in particular to the method and apparatus for migrating data.
Background technique
Database is to come tissue, storage and the warehouse for managing data according to data structure.With the development of the times, enterprise Data volume increases at an unprecedented rate, higher and higher to the Intensity-dependent of data.The traditional network architecture of enterprise is deposited In the problem of HardwareUpgring dilatation complexity, and input cost is high, and sexual valence is relatively low.Therefore, the network architecture of enterprise is changed For Internet architecture, it has also become the trend of the times of global information industry.How stability, safety in data migration process is guaranteed The problem of property and reliability are urgent need to resolve.
Summary of the invention
The embodiment of the present application proposes the method and apparatus for migrating data.
In a first aspect, the embodiment of the present application provides a kind of method for migrating data, comprising: receive what terminal was sent Data Migration instruction, wherein above-mentioned Data Migration instruction includes migrating objects;Above-mentioned migration pair is obtained from first database As;Based on the information of above-mentioned migrating objects, data base manipulation statement is generated;It controls the second database and executes above-mentioned database manipulation Above-mentioned second database is written in above-mentioned migrating objects by sentence.
In some embodiments, the above method further include: create the materialized view log of above-mentioned migrating objects.
In some embodiments, above-mentioned migrating objects include tables of data, and tables of data includes field, and materialized view log includes To the action type of field in tables of data;And the above-mentioned information based on above-mentioned migrating objects, generate data base manipulation statement, packet It includes: extracting the information of field in above-mentioned tables of data, wherein the information of above-mentioned field includes the type of field;According to above-mentioned first The default mapping relations of the type of field between database and above-mentioned second database turn the type of the field of above-mentioned tables of data The type for turning to the field of above-mentioned second database, obtains destination field type;According to the information of field, destination field type with And the action type to field, generate data base manipulation statement.
In some embodiments, before obtaining above-mentioned migrating objects in first database, the above method further include: really Surely it whether there is the migration progress msg of above-mentioned migrating objects;In response to determining that there are above-mentioned migration progress msgs, according to above-mentioned Progress msg is migrated, determines the part to be migrated of above-mentioned migrating objects;And above-mentioned above-mentioned migration is obtained from first database Object, comprising: obtain above-mentioned part to be migrated.
In some embodiments, above-mentioned that above-mentioned migrating objects are obtained from first database, comprising: multiple threads are created, So that above-mentioned multiple thread parallels obtain above-mentioned migrating objects;The migrating objects that above-mentioned multiple threads obtain are stored in preset In storage queue.
In some embodiments, above-mentioned materialized view log includes the sequence of operation number;And it is above-mentioned from first database Obtain above-mentioned migrating objects, comprising: traverse above-mentioned materialized view log, according to the value of aforesaid operations sequence number, determine maximum value The corresponding sequence of operation number;According to the corresponding sequence of operation number of above-mentioned maximum value, the record of materialized view log is obtained.
In some embodiments, the above method further include: determine the sequence of operation played back in above-mentioned materialized view log Number;Delete in above-mentioned materialized view log, the value of the sequence of operation number be less than the above-mentioned sequence of operation number played back value record.
Second aspect, the embodiment of the present application provide a kind of device for migrating data, comprising: receiving unit is matched It is set to and receives the Data Migration instruction that terminal is sent, wherein above-mentioned Data Migration instruction includes migrating objects;Acquiring unit, quilt It is configured to obtain above-mentioned migrating objects from first database;Generation unit is configured to the information based on above-mentioned migrating objects, Generate data base manipulation statement;Migration units are configured to control the second database and execute above-mentioned data base manipulation statement, will Above-mentioned second database is written in above-mentioned migrating objects.
In some embodiments, above-mentioned apparatus further include: creating unit is configured to create the materialization of above-mentioned migrating objects View log.
In some embodiments, above-mentioned migrating objects include tables of data, and tables of data includes field, and materialized view log includes To the action type of field in tables of data;And above-mentioned generation unit is further configured to: extracting field in above-mentioned tables of data Information, wherein the information of above-mentioned field includes the type of field;According to above-mentioned first database and above-mentioned second database it Between field type default mapping relations, convert the type of the field of above-mentioned tables of data to the field of above-mentioned second database Type, obtain destination field type;According to the information of field, above-mentioned purpose field type and to the action type of field, Generate data base manipulation statement.
In some embodiments, above-mentioned apparatus further include: detection unit is configured to count in above-mentioned acquiring unit from first According to before obtaining above-mentioned migrating objects in library, it is determined whether there are the migration progress msgs of above-mentioned migrating objects;Progress determines single Member is configured in response to determine that there are above-mentioned migration progress msgs to determine above-mentioned migration pair according to above-mentioned migration progress msg The part to be migrated of elephant;And above-mentioned acquiring unit is further configured to: obtaining above-mentioned part to be migrated.
In some embodiments, above-mentioned acquiring unit is further configured to: multiple threads is created, so that above-mentioned multiple lines Cheng Binghang obtains above-mentioned migrating objects;The migrating objects that above-mentioned multiple threads obtain are stored in preset storage queue.
In some embodiments, above-mentioned materialized view log includes the sequence of operation number;And above-mentioned acquiring unit is further It is configured to: traversing above-mentioned materialized view log, according to the value of aforesaid operations sequence number, determine the corresponding sequence of operation of maximum value Number;According to the corresponding sequence of operation number of above-mentioned maximum value, the record of materialized view log is obtained.
In some embodiments, above-mentioned apparatus further includes deleting unit, is configured to: determining in above-mentioned materialized view log The sequence of operation number played back;It deletes in above-mentioned materialized view log, the value of the sequence of operation number is less than the above-mentioned operation played back The record of the value of sequence number.
The third aspect, the embodiment of the present application provide a kind of server, comprising: one or more processors;Storage device, One or more programs are stored thereon with, when said one or multiple programs are executed by said one or multiple processors, so that Said one or multiple processors realize the method as described in first aspect any embodiment.
Fourth aspect, the embodiment of the present application provide a kind of computer-readable medium, are stored thereon with computer program, should The method as described in first aspect any embodiment is realized when program is executed by processor.
The method and apparatus provided by the above embodiment for migrating data of the application can receive terminal transmission first Data Migration instruction, the instruction of above-mentioned Data Migration includes migrating objects.It is then possible to obtain migration pair from first database As.And the information based on migrating objects, generate data base manipulation statement.Finally, the second database of control executes above-mentioned database Action statement migrates migrating objects to the second database from first database to realize.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that one embodiment of the application can be applied to exemplary system architecture figure therein;
Fig. 2 is the flow chart according to one embodiment of the method for migrating data of the application;
Fig. 3 is the schematic diagram according to an application scenarios of the method for migrating data of the application;
Fig. 4 is the flow chart according to another embodiment of the method for migrating data of the application;
Fig. 5 is the structural schematic diagram according to one embodiment of the device for migrating data of the application;
Fig. 6 is adapted for the structural schematic diagram for the computer system for realizing the server of the embodiment of the present application.
Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 is shown can be using the method for migrating data of the application or the implementation of the device for migrating data The exemplary system architecture 100 of example.
As shown in Figure 1, system architecture 100 may include server 101, first database 102,103 He of the second database Terminal device 104.Server 101 can by network and first database 102, the second database 103 and terminal device 104 into Row interaction.Network may include various connection types, such as wired, wireless communication link or fiber optic cables etc..
Server 101 can be to provide the server of various services, such as the message sent to terminal device 104 is rung The Database Administration Server answered.Database Administration Server can be when receiving the instruction of user's transmission, the first number of management According to library 102 and/or the second database 103.
Server 101 can be hardware, be also possible to software.When server is hardware, multiple services may be implemented into The distributed server cluster of device composition, also may be implemented into individual server.When server is software, may be implemented into more A software or software module (such as providing Distributed Services), also may be implemented into single software or software module.Herein It is not specifically limited.
First database 102 and the second database 103 can be various types of databases, can be used for storing various types of The data of type.First database 102 and the second database 103 can be interacted by network with server 101, to receive or send Message (such as receiving the data base manipulation statement that server 101 is sent) etc..
First database 102 and the second database 103 can be hardware, be also possible to software.When 102 He of first database When second database 103 is hardware, the distributed data base of multiple database compositions may be implemented into, also may be implemented into single Database.When first database 102 and the second database 103 are software, multiple softwares or software module (example may be implemented into Such as it is used to provide Distributed Services), single software or software module also may be implemented into.It is not specifically limited herein.
User can be used terminal device 104 and interact with server 101, with receive or send message (such as send data Migration instruction) etc..Various telecommunication customer end applications, such as database management application, webpage can be installed on terminal device 104 Browser application, shopping class application, searching class application, instant messaging tools, mailbox client, social platform software etc..
Terminal device 104 can be hardware, be also possible to software.When terminal device 104 is hardware, it can be support and refer to Enable the various electronic equipments sent, including but not limited to smart phone, tablet computer, pocket computer on knee and desk-top calculating Machine etc..When terminal device 104 is software, may be mounted in above-mentioned cited electronic equipment.It may be implemented into more A software or software module (such as providing Distributed Services), also may be implemented into single software or software module.Herein It is not specifically limited.
It should be noted that the method provided by the embodiment of the present application for migrating data is generally held by server 101 Row, correspondingly, the device for migrating data is generally positioned in server 101.
It should be understood that the number of server, first database, the second database and terminal device in Fig. 1 is only to show Meaning property.According to needs are realized, any number of server, first database, the second database and terminal device can have.
With continued reference to Fig. 2, the process of one embodiment of the method for migrating data according to the application is shown 200.The method for migrating data of the present embodiment, comprising the following steps:
Step 201, the Data Migration instruction that terminal is sent is received.
It in the present embodiment, can be with for the executing subject of the method for migrating data (such as server 101 shown in FIG. 1) Data Migration instruction is received from terminal by wired connection mode or radio connection.It can be in the instruction of above-mentioned Data Migration Including migrating objects.Migrating objects can be any object stored in database, such as can be the institute stored in database Data or be from the incremental data etc. that generates after last time migration.
It should be pointed out that above-mentioned radio connection can include but is not limited to 3G/4G connection, WiFi connection, bluetooth Connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection and other currently known or exploitations in the future Radio connection.
Step 202, migrating objects are obtained from first database.
In the present embodiment, executing subject can obtain migration when receiving Data Migration instruction from first database Object.First database can be assumed that as source database, the second database can be assumed that as purpose database.Executing subject needs The migrating objects stored in first database are migrated into the second database.It is understood that from first database When obtaining migrating objects, executing subject needs to initially set up the connection with first database.
In some optional implementations of the present embodiment, executing subject can obtain migration pair by following steps As: multiple threads are created, so that multiple thread parallels obtain migrating objects;The migrating objects that multiple threads obtain are stored in pre- If storage queue in.
In this implementation, executing subject can create multiple threads, so that multiple thread parallels obtain above-mentioned migration pair As.Then, the migrating objects that multiple threads obtain can be stored in preset storage queue by executing subject.By this realization The acquisition efficiency of migrating objects can be improved in mode, executing subject.
In some optional implementations of the present embodiment, above-mentioned migrating objects include tables of data.Above-mentioned multiple threads When obtaining tables of data, a plurality of record for recording or reading multiple tables of data in tables of data may be disposably read.It holds The quantity for the record that row main body can also be read according to quantity, the per thread of above-mentioned multiple threads and storage queue can deposit The quantity for the tables of data put, to calculate the flow in acquisition process.When above-mentioned flow is greater than pre-set flow threshold, hold Row main body can reduce the flow in acquisition process by various modes, such as reduce the quantity of thread, reduce per thread The quantity etc. of the record once read.When storage queue is full, executing subject can also control multiple thread pauses and obtain migration Object.
Step 203, based on the information of migrating objects, data base manipulation statement is generated.
In the present embodiment, after executing subject gets migrating objects from first database, the letter of migrating objects can be extracted Breath.It is then based on the information of migrating objects, generates data base manipulation statement.The information of migrating objects, which can be in database, to be stored The mark of tables of data, field name, field value, to the operation information of field, the constrained type of tables of data, tables of data annotation Deng.After being extracted above- mentioned information, executing subject can generate data base manipulation statement according to above- mentioned information.Generating database When action statement, executing subject can be according to the language of data base manipulation language (Data Manipulation Language, DML) Method rule edits above-mentioned carry out information, obtains data base manipulation statement.
Step 204, the second database of control executes data base manipulation statement, and the second database is written in migrating objects.
After obtaining data base manipulation statement, above-mentioned data base manipulation statement can be sent to the second data by executing subject Library.Second database can execute above-mentioned data base manipulation statement, and the second database is written in migrating objects to realize.
In some optional implementations of the present embodiment, first database can be oracle database, the second number It can be MySQL database according to library.
With continued reference to the signal that Fig. 3, Fig. 3 are according to an application scenarios of the method for migrating data of the present embodiment Figure.In the application scenarios of Fig. 3, user passes through terminal 301 first and initiates Data Migration instruction, and Data Migration instruction is specified Migrating objects are all tables of data.Later, server 302 can obtain all tables of data, database from first database 303 302 can create multiple threads for parallel acquisition tables of data.Then the tables of data that will acquire is stored in storage queue.Service Then device 302 extracts the information of tables of data, generate data base manipulation statement.Then data base manipulation statement is sent to the second number According to library 304, the second database 304 can execute above-mentioned data base manipulation statement, realize the tables of data the second database is written 304。
The method provided by the above embodiment for migrating data of the application can receive the data of terminal transmission first Migration instruction, above-mentioned Data Migration instruction includes migrating objects.It is then possible to obtain migrating objects from first database.And Information based on migrating objects generates data base manipulation statement.Finally, the second database of control executes above-mentioned database manipulation language Sentence migrates migrating objects to the second database from first database to realize.
With continued reference to Fig. 4, it illustrates the streams according to another embodiment of the method for migrating data of the application Journey 400.As shown in figure 4, the method for migrating data of the present embodiment the following steps are included:
Step 401, the Data Migration instruction that terminal is sent is received.
In the present embodiment, above-mentioned Data Migration instruction may include migrating objects.Above-mentioned migrating objects can be the first number According to all tables of data stored in library, indicate all Data Migrations that will be stored in first database into the second database, This migration is also known as full dose migration.
Step 402, it is determined whether there are the migration progress msgs of migrating objects.
Executing subject may first determine whether the migration progress msg there are migrating objects before obtaining migrating objects. Specifically, executing subject can determine whether there is migration progress msg by various modes.For example, executing subject can lead to The acquisition record for inquiring each thread is crossed to determine migration progress msg.Alternatively, executing subject can be moved from specific for storing It moves in the memory module of progress msg and determines migration progress msg.Above-mentioned migration progress msg may include having moved for migrating objects Move the mark of part.For example, above-mentioned migration progress msg can be mark, the master of tables of data when migrating objects are tables of data Key name claims and corresponding Major key.Major key can uniquely identify every a line in tables of data.
Step 403, in response to determine exist migration progress msg, according to migration progress msg, determine migrating objects to Migrate part.
If executing subject determine exist migration progress msg, executing subject can according to above-mentioned migration progress msg, Determine have moved part and the part to be migrated of migrating objects.Specifically, executing subject can will migrate the mark in progress msg The position of knowledge, the line of demarcation as have moved part and part to be migrated.It is part to be migrated after the position of above-mentioned mark.
Step 404, part to be migrated is obtained.
After determining part to be migrated, executing subject can directly acquire the part to be migrated of migrating objects, i.e., from migration Continue to obtain migrating objects at the position of progress msg instruction.
Step 405, based on the information of migrating objects, data base manipulation statement is generated.
Step 406, the second database of control executes data base manipulation statement, and the second database is written in migrating objects.
Step 405 is similar with step 203 principle in embodiment illustrated in fig. 2, the step of step 406 and embodiment illustrated in fig. 2 Rapid 204 is similar, and details are not described herein again.
The method provided by the above embodiment for migrating data of the application can continue at the interruption that last time migrates Migrating objects are obtained, improve the efficiency of Data Migration, while also saving memory space.
In some optional implementations of the present embodiment, if executing subject is determined there is no migration progress msg, Migrating objects can then be directly acquired.Specifically, executing subject, which can create multi-threaded parallel, obtains above-mentioned migrating objects.
In some optional implementations of the present embodiment, before obtaining migrating objects, executing subject can also be created The materialized view log of migrating objects.Specifically, executing subject can be by sending materialized view log wound to first database Instruction is built to create materialized view log.Materialized view log can recorde the operation information to tables of data, including tables of data Mark, action type, operation object etc..
It may include multiple fields, such as ID, NAME, SEQUENCE $ $, DMLTYPE $ $ etc. in materialized view log.Its In, ID and NAME are corresponding for recording each DML operation when establishing materialized view log in the column in specified data table Mark and title.SEQUENCE $ $, the also referred to as sequence of operation number can operate being sequentially generated for generation according to DML, be generated The value of the sequence of operation number be also incremental.DMLTYPE $ $ is used to indicate the type of DML operation.In materialized view log, each The information of DML operation is a record.
In some optional implementations of the present embodiment, above-mentioned migrating objects include tables of data.Include in tables of data Multiple fields.Above-mentioned steps 405 can be realized by following steps unshowned in Fig. 4: extract the information of field in tables of data. Wherein, the information of field includes the type of field.According between first database and the second database the type of field it is default Mapping relations convert the type of the field of tables of data to the type of the field of the second database, obtain destination field type.Root According to the information of field, destination field type and to the action type of field, data base manipulation statement is generated.
In this implementation, the information of field in tables of data can be extracted first, and the information of above-mentioned field includes field Type, the title of field, value of field etc..It is understood that for different types of database, field in tables of data Type it is different.Executing subject can be reflected with the type of field between first database according to the pre-stored data and the second database Relation list is penetrated, converts the type of the field of tables of data to the type of the field of the second database, obtains destination field class Type.Using first database as oracle database, the second database is field type in Oracle for MySQL database Field type in DATE, corresponding MySQL is DATETIME.Finally, executing subject can information according to field, purpose word Segment type and the corresponding action type of field generate data base manipulation statement.Specifically, executing subject can be according to DML language The title of field, the value of field, destination field type and the corresponding action type of field are spliced, obtain data by method Library action statement.
In some optional implementations of the present embodiment, above-mentioned migrating objects may include tables of data, above-mentioned data Table can be the tables of data generated from after last time Data Migration, as incremental data.Then this Data Migration is referred to as increasing Measure Data Migration.Incremental data is migrated, executing subject, can be by obtaining materialized view log when obtaining migrating objects Mode realize acquisition migrating objects.Due to having recorded the operation information to tables of data in materialized view log, then master is executed To realize that the second database is synchronous with first database, i.e., body can play back materialized view log by the second database of control It realizes the Data Migration in first database to the second database.Specifically, executing subject can be obtained according to following steps Take materialized view log: traversal materialized view log determines the corresponding sequence of operation of maximum value according to the value of the sequence of operation number Number;According to the corresponding sequence of operation number of maximum value, the record of materialized view log is obtained.
Executing subject can traverse materialized view log, according to the value of the sequence of operation number, to determine the corresponding behaviour of maximum value Make sequence number.Then, the corresponding record of each sequence of operation number in the available materialized view log of executing subject is until obtain Get the corresponding record of the corresponding sequence of operation number of maximum value.Optionally, executing subject can create multi-threaded parallel and obtain object Change view log.
Executing subject can control the second database according to the sequence of operation number after getting above-mentioned materialized view log It is worth ascending sequential playback materialized view log, so as to realize that the second database is synchronous with first database.
In some optional implementations of the present embodiment, the above method can also comprise steps of determining that materialization The sequence of operation number played back in view log;It deletes in materialized view log, the value of the sequence of operation number is less than the behaviour played back Make the record of the value of sequence number.
Executing subject can determine the sequence of operation number played back in materialized view log.Specifically, executing subject can be with Determine the sequence of operation number played back in several ways.For example, executing subject can by interacted with the second database come Determine the sequence of operation number played back.After determining the sequence of operation number played back, executing subject can be by materialized view log The value of the middle sequence of operation is less than the record deletion of the value of the sequence of operation number played back.Occupancy not only can effectively be reduced Space.Meanwhile if when the above process is suspended by user or by other reasons is led to terminal, can when being again started up according to The not deleted sequence of operation number continues synchrodata, realizes the breakpoint transmission of migrating objects.
With further reference to Fig. 5, as the realization to method shown in above-mentioned each figure, this application provides one kind to be used for transport number According to device one embodiment, the Installation practice is corresponding with embodiment of the method shown in Fig. 2, which can specifically answer For in various electronic equipments.
As shown in figure 5, the device 500 for migrating data of the present embodiment includes: receiving unit 501, acquiring unit 502, generation unit 503 and migration units 504.
Receiving unit 501 is configured to receive the Data Migration instruction of terminal transmission.Wherein, Data Migration, which instructs, includes Migrating objects.
Acquiring unit 502 is configured to obtain migrating objects from first database.
Generation unit 503 is configured to the information based on migrating objects, generates data base manipulation statement.
Migration units 504 are configured to control the second database and execute data base manipulation statement, migrating objects are written Second database.
In some optional implementations of the present embodiment, above-mentioned apparatus 500, which can further include in Fig. 5, not to be shown Creating unit out is configured to create the materialized view log of migrating objects.
In some optional implementations of the present embodiment, migrating objects include tables of data, and tables of data includes field, object Changing view log includes the action type to field in tables of data.Above-mentioned generation unit 503 can be further configured to: be extracted The information of field in tables of data, wherein the information of field includes the type of field;According to first database and the second database it Between field type default mapping relations, convert the type of the field of tables of data to the type of the field of the second database, Obtain destination field type;According to the information of field, destination field type and to the action type of field, database behaviour is generated Make sentence.
In some optional implementations of the present embodiment, above-mentioned apparatus 500, which can further include in Fig. 5, not to be shown Detection unit and progress determination unit out.
Detection unit is configured in acquiring unit 502 before obtaining migrating objects in first database, it is determined whether There are the migration progress msgs of migrating objects;
Progress determination unit is configured in response to determine there is migration progress msg, according to migration progress msg, determines The part to be migrated of migrating objects.
Correspondingly, acquiring unit 502 is further configured to: obtaining part to be migrated.
In some optional implementations of the present embodiment, acquiring unit 502 is further configured to: creating multiple lines Journey, so that multiple thread parallels obtain migrating objects;The migrating objects that multiple threads obtain are stored in preset storage queue In.
In some optional implementations of the present embodiment, materialized view log includes the sequence of operation number.Acquiring unit 502 are further configured to: traversal materialized view log determines the corresponding operation sequence of maximum value according to the value of the sequence of operation number Row number;According to the corresponding sequence of operation number of maximum value, the record of materialized view log is obtained.
In some optional implementations of the present embodiment, above-mentioned apparatus 500, which can further include in Fig. 5, not to be shown Deletion unit out, is configured to: determining the sequence of operation number played back in materialized view log;Delete materialized view log In, the value of the sequence of operation number be less than the sequence of operation number played back value record.
The device provided by the above embodiment for migrating data of the application can receive the data of terminal transmission first Migration instruction, above-mentioned Data Migration instruction includes migrating objects.It is then possible to obtain migrating objects from first database.And Information based on migrating objects generates data base manipulation statement.Finally, the second database of control executes above-mentioned database manipulation language Sentence migrates migrating objects to the second database from first database to realize.
It should be appreciated that the unit 501 for recording in the device 500 of migrating data is to unit 504 respectively and in reference Fig. 2 Each step in the method for description is corresponding.As a result, above with respect to the operation and feature of the method description for migrating data It is equally applicable to device 500 and unit wherein included, details are not described herein.
Below with reference to Fig. 6, it illustrates the computer systems 600 for the server for being suitable for being used to realize the embodiment of the present application Structural schematic diagram.Server shown in Fig. 6 is only an example, should not function and use scope band to the embodiment of the present application Carry out any restrictions.
As shown in fig. 6, computer system 600 includes central processing unit (CPU) 601, it can be read-only according to being stored in Program in memory (ROM) 602 or be loaded into the program in random access storage device (RAM) 603 from storage section 608 and Execute various movements appropriate and processing.In RAM 603, also it is stored with system 600 and operates required various programs and data. CPU 601, ROM 602 and RAM 603 are connected with each other by bus 604.Input/output (I/O) interface 605 is also connected to always Line 604.
I/O interface 605 is connected to lower component: the importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 608 including hard disk etc.; And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because The network of spy's net executes communication process.Driver 610 is also connected to I/O interface 605 as needed.Detachable media 611, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 610, in order to read from thereon Computer program be mounted into storage section 608 as needed.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising carrying is on a machine-readable medium Computer program, which includes the program code for method shown in execution flow chart.In such implementation In example, which can be downloaded and installed from network by communications portion 609, and/or from detachable media 611 It is mounted.When the computer program is executed by central processing unit (CPU) 601, limited in execution the present processes upper State function.
It should be noted that computer-readable medium described herein can be computer-readable signal media or Computer readable storage medium either the two any combination.Computer readable storage medium for example can be --- but Be not limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination. The more specific example of computer readable storage medium can include but is not limited to: have one or more conducting wires electrical connection, Portable computer diskette, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only deposit Reservoir (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory Part or above-mentioned any appropriate combination.
In this application, computer readable storage medium can be any tangible medium for including or store program, the journey Sequence can be commanded execution system, device or device use or in connection.And in this application, it is computer-readable Signal media may include in a base band or as carrier wave a part propagate data-signal, wherein carrying computer can The program code of reading.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal, optical signal or Above-mentioned any appropriate combination.Computer-readable signal media can also be any other than computer readable storage medium Computer-readable medium, the computer-readable medium can send, propagate or transmit for by instruction execution system, device or Person's device uses or program in connection.The program code for including on computer-readable medium can be with any appropriate Medium transmission, including but not limited to: wireless, electric wire, optical cable, RF etc. or above-mentioned any appropriate combination.
The calculating of the operation for executing the application can be write with one or more programming languages or combinations thereof Machine program code, above procedure design language include object oriented program language-such as Java, Smalltalk, C+ +, it further include conventional procedural programming language-such as " C " language or similar programming language.Program code can Fully to execute, partly execute on the user computer on the user computer, be executed as an independent software package, Part executes on the remote computer or executes on a remote computer or server completely on the user computer for part. In situations involving remote computers, remote computer can pass through the network of any kind --- including local area network (LAN) Or wide area network (WAN)-is connected to subscriber computer, or, it may be connected to outer computer (such as utilize Internet service Provider is connected by internet).
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit also can be set in the processor, for example, can be described as: a kind of processor packet Include receiving unit, acquiring unit, generation unit and migration units.Wherein, the title of these units not structure under certain conditions The restriction of the pairs of unit itself, for example, receiving unit is also described as " receiving the Data Migration instruction that terminal is sent Unit ".
As on the other hand, present invention also provides a kind of computer-readable medium, which be can be Included in device described in above-described embodiment;It is also possible to individualism, and without in the supplying device.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the device, so that should Device: the Data Migration instruction that terminal is sent is received, wherein Data Migration instruction includes migrating objects;From first database Obtain migrating objects;Information based on migrating objects generates data base manipulation statement;It controls the second database and executes database behaviour Make sentence, the second database is written into migrating objects.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (16)

1. a kind of method for migrating data, comprising:
Receive the Data Migration instruction that terminal is sent, wherein the Data Migration instruction includes migrating objects;
The migrating objects are obtained from first database;
Based on the information of the migrating objects, data base manipulation statement is generated;
It controls the second database and executes the data base manipulation statement, second database is written into the migrating objects.
2. according to the method described in claim 1, wherein, the method also includes:
Create the materialized view log of the migrating objects.
3. tables of data includes field, materialization according to the method described in claim 2, wherein, the migrating objects include tables of data View log includes the action type to field in tables of data;And
The information based on the migrating objects generates data base manipulation statement, comprising:
Extract the information of field in the tables of data, wherein the information of the field includes the type of field;
According to the default mapping relations of the type of field between the first database and second database, by the data The type of the field of table is converted into the type of the field of second database, obtains destination field type;
According to the information of field, destination field type and to the action type of field, data base manipulation statement is generated.
It is described before obtaining the migrating objects in first database 4. according to the method described in claim 1, wherein Method further include:
Determine whether there is the migration progress msg of the migrating objects;
In response to determining there are the migration progress msg, according to the migration progress msg, determine the migrating objects to Migrate part;And
It is described that the migrating objects are obtained from first database, comprising:
Obtain the part to be migrated.
5. described to obtain the migrating objects from first database according to the method described in claim 1, wherein, comprising:
Multiple threads are created, so that the multiple thread parallel obtains the migrating objects;
The migrating objects that the multiple thread obtains are stored in preset storage queue.
6. according to the method described in claim 2, wherein, the materialized view log includes the sequence of operation number;And
It is described that the migrating objects are obtained from first database, comprising:
The materialized view log is traversed, according to the value of the sequence of operation number, determines the corresponding sequence of operation number of maximum value;
According to the corresponding sequence of operation number of the maximum value, the record of materialized view log is obtained.
7. according to the method described in claim 6, wherein, the method also includes:
Determine the sequence of operation number played back in the materialized view log;
It deletes in the materialized view log, the note of the value for the sequence of operation number that the value of the sequence of operation number has been played back less than described in Record.
8. a kind of device for migrating data, comprising:
Receiving unit is configured to receive the Data Migration instruction of terminal transmission, wherein the Data Migration instruction includes migration Object;
Acquiring unit is configured to obtain the migrating objects from first database;
Generation unit is configured to the information based on the migrating objects, generates data base manipulation statement;
Migration units are configured to control the second database and execute the data base manipulation statement, the migrating objects are write Enter second database.
9. device according to claim 8, wherein described device further include:
Creating unit is configured to create the materialized view log of the migrating objects.
10. device according to claim 9, wherein the migrating objects include tables of data, and tables of data includes field, object Changing view log includes the action type to field in tables of data;And
The generation unit is further configured to:
Extract the information of field in the tables of data, wherein the information of the field includes the type of field;
According to the default mapping relations of the type of field between the first database and second database, by the data The type of the field of table is converted into the type of the field of second database, obtains destination field type;
According to the information of field, the destination field type and to the action type of field, data base manipulation statement is generated.
11. device according to claim 8, wherein described device further include:
Detection unit is configured in the acquiring unit before obtaining the migrating objects in first database, and determination is It is no that there are the migration progress msgs of the migrating objects;
Progress determination unit, is configured in response to determine there are the migration progress msg, according to the migration progress msg, Determine the part to be migrated of the migrating objects;And
The acquiring unit is further configured to:
Obtain the part to be migrated.
12. device according to claim 8, wherein the acquiring unit is further configured to:
Multiple threads are created, so that the multiple thread parallel obtains the migrating objects;
The migrating objects that the multiple thread obtains are stored in preset storage queue.
13. device according to claim 9, wherein the materialized view log includes the sequence of operation number;And
The acquiring unit is further configured to:
The materialized view log is traversed, according to the value of the sequence of operation number, determines the corresponding sequence of operation number of maximum value;
According to the corresponding sequence of operation number of the maximum value, the record of materialized view log is obtained.
14. device according to claim 13, wherein described device further includes deleting unit, is configured to:
Determine the sequence of operation number played back in the materialized view log;
It deletes in the materialized view log, the note of the value for the sequence of operation number that the value of the sequence of operation number has been played back less than described in Record.
15. a kind of server, comprising:
One or more processors;
Storage device is stored thereon with one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now method as described in any in claim 1-7.
16. a kind of computer-readable medium, is stored thereon with computer program, wherein the realization when program is executed by processor Method as described in any in claim 1-7.
CN201811050267.6A 2018-09-10 2018-09-10 Method and apparatus for migrating data Pending CN109284281A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811050267.6A CN109284281A (en) 2018-09-10 2018-09-10 Method and apparatus for migrating data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811050267.6A CN109284281A (en) 2018-09-10 2018-09-10 Method and apparatus for migrating data

Publications (1)

Publication Number Publication Date
CN109284281A true CN109284281A (en) 2019-01-29

Family

ID=65181054

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811050267.6A Pending CN109284281A (en) 2018-09-10 2018-09-10 Method and apparatus for migrating data

Country Status (1)

Country Link
CN (1) CN109284281A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287169A (en) * 2019-06-28 2019-09-27 四川长虹电器股份有限公司 A kind of master data moving method between cloud application
CN110688378A (en) * 2019-09-06 2020-01-14 中国平安财产保险股份有限公司 Migration method and system for database storage process
CN110704398A (en) * 2019-09-30 2020-01-17 深圳前海环融联易信息科技服务有限公司 Database migration method and device from MySQL to Oracle and computer equipment
CN111104393A (en) * 2019-12-17 2020-05-05 深圳追一科技有限公司 Data migration method and device, electronic equipment and storage medium
CN113051245A (en) * 2019-12-26 2021-06-29 云丁网络技术(北京)有限公司 Method, device and system for migrating data
WO2021164451A1 (en) * 2020-02-21 2021-08-26 苏州浪潮智能科技有限公司 Distributed storage volume online migration method, system and apparatus, and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101266606A (en) * 2007-03-15 2008-09-17 阿里巴巴公司 On-line data migration method based on Oracle database
CN101706803A (en) * 2009-11-27 2010-05-12 天津工业大学 Method for migrating production data of weaving workshop
US8150896B2 (en) * 2007-12-21 2012-04-03 Make Technologies, Inc. Auditing tool for a legacy software modernization system
CN103440273A (en) * 2013-08-06 2013-12-11 北京航空航天大学 Data cross-platform migration method and device
CN107357883A (en) * 2017-06-30 2017-11-17 北京奇虎科技有限公司 Data migration method and device
US10057377B2 (en) * 2012-06-29 2018-08-21 Vmware, Inc. Dynamic resolution of servers in a distributed environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101266606A (en) * 2007-03-15 2008-09-17 阿里巴巴公司 On-line data migration method based on Oracle database
US8150896B2 (en) * 2007-12-21 2012-04-03 Make Technologies, Inc. Auditing tool for a legacy software modernization system
CN101706803A (en) * 2009-11-27 2010-05-12 天津工业大学 Method for migrating production data of weaving workshop
US10057377B2 (en) * 2012-06-29 2018-08-21 Vmware, Inc. Dynamic resolution of servers in a distributed environment
CN103440273A (en) * 2013-08-06 2013-12-11 北京航空航天大学 Data cross-platform migration method and device
CN107357883A (en) * 2017-06-30 2017-11-17 北京奇虎科技有限公司 Data migration method and device

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287169A (en) * 2019-06-28 2019-09-27 四川长虹电器股份有限公司 A kind of master data moving method between cloud application
CN110287169B (en) * 2019-06-28 2022-02-01 四川长虹电器股份有限公司 Main data migration method between cloud applications
CN110688378A (en) * 2019-09-06 2020-01-14 中国平安财产保险股份有限公司 Migration method and system for database storage process
CN110704398A (en) * 2019-09-30 2020-01-17 深圳前海环融联易信息科技服务有限公司 Database migration method and device from MySQL to Oracle and computer equipment
CN110704398B (en) * 2019-09-30 2023-08-25 深圳前海环融联易信息科技服务有限公司 Database migration method and device from MySQL to Oracle and computer equipment
CN111104393A (en) * 2019-12-17 2020-05-05 深圳追一科技有限公司 Data migration method and device, electronic equipment and storage medium
CN111104393B (en) * 2019-12-17 2024-02-20 深圳追一科技有限公司 Data migration method, device, electronic equipment and storage medium
CN113051245A (en) * 2019-12-26 2021-06-29 云丁网络技术(北京)有限公司 Method, device and system for migrating data
WO2021164451A1 (en) * 2020-02-21 2021-08-26 苏州浪潮智能科技有限公司 Distributed storage volume online migration method, system and apparatus, and readable storage medium

Similar Documents

Publication Publication Date Title
CN109284281A (en) Method and apparatus for migrating data
CA2980907C (en) Transactional conversation-based computing system
US9398087B1 (en) Secure deployment of an application across deployment locations
CN105144153B (en) Method and system for Content Organizing
US10261808B2 (en) Access operation with dynamic linking and access of data within plural data sources
CN109660397A (en) For acquiring system, the method and apparatus of log
US20110119587A1 (en) Data model and player platform for rich interactive narratives
CN110442330A (en) List element conversion method, device, electronic equipment and storage medium
CN109447635A (en) Information storage means and device for block chain
CN110347674A (en) A kind of index creation method, device and equipment based on service identification
CN108965389A (en) Method for showing information
CN110213105A (en) It is a kind of cross-platform micro- using creation method
CN109564577A (en) Data instance efficiently is gone to standardize
US20240012985A1 (en) Table content processing method and apparatus, and device and storage medium
CN110119418A (en) Data export method and device
US11768801B2 (en) Dynamic identification of cloud storage destination for multi-user files
US11558213B1 (en) Deep tagging artifact review session
CN115470767A (en) Document processing method and device, electronic equipment and computer readable medium
CN109145591A (en) The plug-in loading method of application program
US10068356B2 (en) Synchronized maps in eBooks using virtual GPS channels
US11099969B2 (en) Estimating the number of coding styles by analyzing source code
CN110555070B (en) Method and apparatus for outputting information
US20210141562A1 (en) Output management in command line interface
US20140089207A1 (en) System and method for providing high level view tracking of changes in sca artifacts
US11443101B2 (en) Flexible pseudo-parsing of dense semi-structured text

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination