Movatterモバイル変換


[0]ホーム

URL:


CN106294387B - Data migration method and device - Google Patents

Data migration method and device
Download PDF

Info

Publication number
CN106294387B
CN106294387BCN201510258062.7ACN201510258062ACN106294387BCN 106294387 BCN106294387 BCN 106294387BCN 201510258062 ACN201510258062 ACN 201510258062ACN 106294387 BCN106294387 BCN 106294387B
Authority
CN
China
Prior art keywords
database
data
migration
request
read request
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
CN201510258062.7A
Other languages
Chinese (zh)
Other versions
CN106294387A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co LtdfiledCriticalTencent Technology Shenzhen Co Ltd
Priority to CN201510258062.7ApriorityCriticalpatent/CN106294387B/en
Publication of CN106294387ApublicationCriticalpatent/CN106294387A/en
Application grantedgrantedCritical
Publication of CN106294387BpublicationCriticalpatent/CN106294387B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The invention relates to a data migration method, which comprises the following steps: migrating data in a first database to a second database; receiving a read request and a write request from a user terminal; detecting a migration state of data; and processing the read request and the write request according to the migration state of the data. A data migration apparatus is also provided. The invention can provide read-write service for the user in the data migration process, and unnecessary loss is not brought to the user because the service of the database is not stopped.

Description

Data migration method and device
Technical Field
The present invention relates to the field of network data processing, and in particular, to a data migration method and apparatus.
Background
Due to the increase of the number of users, the sudden increase of the request amount during holiday activities, or unpredictable faults of software and hardware of the server, the server in the background of the internet often encounters the situation that the data of the database needs to be migrated urgently.
However, when data is migrated from an old database to a new database, the conventional data migration method needs to stop the service of the old database, copy the data to the new database, and then replace the old database with the new database to provide the service. In the process of data migration, the user use is seriously affected due to the fact that the database is out of service, and inestimable loss is brought to the user along with the increase of the data volume.
Disclosure of Invention
Therefore, it is necessary to provide a data migration method and apparatus for solving the technical problem that the service of the database needs to be stopped during the data migration process, which causes loss to the user.
A method of data migration, the method comprising:
migrating data in a first database to a second database;
receiving a read request and a write request from a user terminal;
detecting a migration state of data;
and processing the read request and the write request according to the migration state of the data.
A data migration apparatus, the apparatus comprising:
the migration module is used for migrating the data in the first database to the second database;
the request receiving module is used for receiving a read request and a write request from a user terminal;
the detection module is used for detecting the migration state of the data;
and the processing module is used for processing the read request and the write request according to the migration state of the data.
According to the data migration method and device, in the process of migrating data from the first database to the second database, after a read request and a write request from a user terminal are received, the migration state of the data is detected, and the read request and the write request are processed according to the migration state, so that read-write service can be provided for a user in the process of migrating the data, and unnecessary loss is not brought to the user due to stopping of service of the database.
Drawings
FIG. 1 is a diagram of an application environment of a data migration system in one embodiment;
FIG. 2 is a schematic diagram of a server in one embodiment;
FIG. 3 is a flow diagram that illustrates a method for data migration in one embodiment;
FIG. 4 is a flow diagram that illustrates the process of assigning a read request to a first database or a second database, according to one embodiment;
FIG. 5 is a schematic flow chart illustrating migration of data in a first database to a second database in one embodiment;
FIG. 6 is a first state diagram illustrating data migration in a particular application scenario;
FIG. 7 is a second state diagram of data migration in a particular application scenario;
FIG. 8 is a third state diagram illustrating data migration in a particular application scenario;
FIG. 9 is a block diagram of a data migration apparatus in one embodiment;
FIG. 10 is a block diagram that illustrates the structure of a migration module in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in FIG. 1, in one embodiment, a data migration system is provided that includes a plurality ofterminals 102 and aserver 104. Theterminal 102 may be a mobile phone, a personal notebook, a tablet computer, a desktop computer, or the like; theserver 104 may be one or more servers. Theuser terminal 102 runs a request application program, and at least provides a request sending function. Theserver 104 is used to provide service support for requesting applications running on theterminal 102. The user may send various read and write requests to theserver 104 through theterminal 102, and theserver 104 processes the various read and write requests through its internal database. Data corresponding to the read request and the write request sent by the user is stored in a database of theserver 104, and the data can be migrated between different databases.
In one embodiment, the internal structure of theserver 104 in fig. 1 is schematically illustrated in fig. 2. The server comprises a processor, a memory, a storage medium and a network interface which are connected through a system bus. Theserver 104 receives read requests and write requests from theuser terminal 102 through the network interface. The storage medium of the server stores an operating system, a database and a data migration device, wherein the database can be one or more than two databases. The data migration device is used for realizing a data migration method. The processor of the server is configured to perform a data migration method.
As shown in fig. 3, in an embodiment, a data migration method is provided, and this embodiment is illustrated by applying the method to the server in fig. 1. The data migration method specifically comprises the following steps:
step S302: data in the first database is migrated to the second database.
Specifically, a DB (database) refers to a collection of data that is stored together in a manner that can be shared by multiple users, has as little redundancy as possible, and is independent of applications. The database belongs to an application system and can be installed on a server.
The first database and the second database may be installed on the same server or may be installed on different servers. In this embodiment, the first database and the second database are installed on the same server.
Step S304: a read request and a write request are received from a user terminal.
Specifically, a requesting application is run on the user terminal, and a request trigger control, such as a button or a hyperlink, is set in a page of the requesting application. The user inputs a trigger instruction through an input device such as a touch screen, a button or a track ball of the user terminal, so that the user terminal sends a read request or a write request to the server. Read requests do not require data to be modified, such as security knowledge browsing requests, while write requests require data to be modified, such as password modification requests.
In this embodiment, the server may receive one or more requests from one user terminal, or may receive requests from two or more user terminals.
Step S306: the migration state of the data is detected.
Specifically, after data starts to be migrated from one database to another database, the migration state at least includes the migration in progress and the migration completed.
In this embodiment, step S306 specifically includes: and detecting whether all the data in the first database are migrated into the second database, if so, determining that the migration of the data is completed, and if not, determining that the migration of the data is in progress.
And step S308, processing the read request and the write request according to the migration state of the data.
Specifically, if the migration state of the data is migration, the write request is allocated to the second database for processing, and the read request is allocated to the first database or the second database for processing; and if the migration state of the data is migration completion, distributing the read request and the write request to the second database for processing.
For example, if the migration state of the data is migration, after receiving the read request, the server searches the second database for the data corresponding to the read request. If the second database has data corresponding to the read request, the server will distribute the read request to the second database for processing through a logic process (i.e. a server process) in the program running process, i.e. the second database provides service for the user. If the second database is found to have no data corresponding to the read request in the searching process, the corresponding data is not migrated to the second database, and the logic process redistributes the read request to the first database for processing.
According to the data migration method, in the process of migrating data from the first database to the second database, after the server receives the read request and the write request from the user terminal, the migration state of the data is detected, and the read request and the write request are processed according to the migration state, so that the read-write service can be provided for a user in the process of data migration, and unnecessary loss is not brought to the user due to stopping the service of the database.
Fig. 4 is a flowchart illustrating a process of allocating a read request to a first database or a second database according to an embodiment.
In this embodiment, the allocating the read request to the first database or the second database specifically includes:
step S402: and searching whether the second database has data corresponding to the reading request, if so, executing step S404, and if not, executing step S406.
Step S402: the read request is assigned to a second database transaction.
Step S406: the read request is assigned to a first database transaction.
For example, if a user sends a read request through the terminal to read data a, data a corresponding to the read request is searched in the second database. If the second database has data a, the read request is assigned to the second database for processing, i.e. data a is returned to the user terminal via the second database. If the second database does not have the data a corresponding to the read request, it indicates that the data a has not been migrated from the first database to the second database, and therefore, the read request needs to be allocated to the first database for processing, and the first database returns the data a to the user terminal.
Fig. 5 is a flowchart illustrating migration of data in a first database to a second database according to an embodiment.
Step S502: data in the first database is replicated.
Step S504: detecting whether the data already exists in the second database or whether the second database receives a deletion request corresponding to the data, if so, executing step S506; if not, go to step S508.
Step S506: the data is directly discarded.
Step S508: pasting the data into a second database.
In particular, the write request comprises a delete request. In this embodiment, if the data corresponding to the deletion request has not been migrated to the second database, the deletion request may be recorded in the second database in a tag manner after being processed, and when the data is migrated to the second database, if it is detected that the second database receives the deletion request corresponding to the data, it is detected that a corresponding tag is recorded in the second database, so that the data may be directly lost.
For example, when the second database processes the delete request, a column is added in the data table as a reserved field of the data, and if the data corresponding to the delete request has not been migrated to the second database, the data corresponding to the delete request will be marked at the reserved field after being processed, indicating that the data corresponding to the delete request has been deleted.
The principle of the data migration method is described below by using a specific application scenario, which takes a desktop computer as a terminal, installs a first database and a second database on the same server, and sends a security knowledge browsing request and a password modification request to the server through the desktop computer by a user as an example.
Referring to fig. 6, before data is not migrated, a user sends a security knowledge browsing request and a password modification request to aserver 620 corresponding to an account security center through adesktop computer 610. Because the relevant data corresponding to these requests are stored in thefirst database 622 before migration, theserver 620 distributes the security knowledge browsing request and the password modification request to thefirst database 622 for processing through a logic process during the program running process after receiving the requests, that is, thefirst database 622 provides services for the user.
The account security center is account protection software, can provide one-stop software security service for users, and comprises functions of password protection, account protection, security physical examination, password modification, account complaint and the like, so that the account is safer and more reliable.
Nowadays, various accounts registered by a user through a network need to fill in some personal information, and the security of the accounts is very important for the user. When a user wants to know some security knowledge related to account protection, a security knowledge browsing request can be sent to the server. After receiving the request, the server processes the safety knowledge browsing request by running a series of programs, and feeds back related data stored in the database to the user terminal in a certain mode.
Each account is provided with a corresponding password, and the data corresponding to the password is stored in a database for providing services. If the user feels that the security of the previously set password is not high enough, the password needs to be modified. At this point, the user may send a password modification request to the server. After receiving the request, the server processes the password modification request by running a series of programs, and at this time, the user is required to write a new password to be stored in the database to replace the previous password, that is, the data corresponding to the previous password is deleted.
Referring to fig. 7, due to some unpredictable failures, the data in thefirst database 622 needs to be urgently migrated to thesecond database 624. During the data migration process, a user sends a safety knowledge browsing request to aserver 620 corresponding to the account safety center through adesktop computer 610. Because it is detected that all the data in thefirst database 622 has not been migrated to thesecond database 624, the migration status of the data is migration, and the data corresponding to the request may have been migrated to thesecond database 624 or may not have been migrated to thesecond database 624. Thus, upon receiving the request, theserver 620 will look up thesecond database 624 for the data corresponding to the security knowledge browsing request. If thesecond database 624 has data corresponding to the security knowledge browsing request, theserver 620 will distribute the security knowledge browsing request to thesecond database 624 for processing through a logic process during the program running process, i.e. thesecond database 624 provides services for the user. If during the search process, it is found that thesecond database 624 does not have the data corresponding to the security knowledge browse request, which indicates that the corresponding data has not been migrated to thesecond database 624, the logic process will redistribute the security knowledge browse request to thefirst database 622 for processing.
During the data migration process, suppose that the user sends a password modification request to theserver 620 corresponding to the account security center through thedesktop computer 610. Because the password modification request belongs to the write request, theserver 620 needs to delete the data corresponding to the previous password after storing the data corresponding to the new password input by the user. At this time, if the data corresponding to the previous password has not been migrated to thesecond database 624, the data corresponding to the previous password is recorded in thesecond database 624 in a flag manner, and when the data corresponding to the previous password is migrated to thesecond database 624, if it is detected that the corresponding flag is recorded in thesecond database 624, the data corresponding to the previous password is directly discarded.
Referring to fig. 8, after all data in thefirst database 622 is migrated to thesecond database 624, the user sends a security knowledge browsing request and a password modification request to theserver 620 corresponding to the account security center through thedesktop computer 610, respectively, because it is detected that all data in thefirst database 622 is migrated to thesecond database 624, the migration state of the data is migration completion, and after receiving the request, theserver 620 distributes both the security knowledge browsing request and the password modification request to thesecond database 624 through a logic process in the program running process, that is, thesecond database 624 provides services for the user.
As shown in fig. 9, in one embodiment, adata migration apparatus 900 having functions of implementing the data migration methods of the above embodiments is provided. Thedata migration apparatus 900 includes amigration module 902, arequest receiving module 904, adetection module 906, and aprocessing module 908.
Themigration module 902 is configured to migrate data in the first database to the second database.
Therequest receiving module 904 is configured to receive a read request and a write request from a user terminal.
Thedetection module 906 is configured to detect a migration status of data.
Specifically, the detectingmodule 906 is configured to detect whether all data in the first database is migrated to the second database, if so, the migration state of the data is migration completion, and if not, the migration state of the data is migration in progress.
Theprocessing module 908 is configured to process the read request and the write request according to the migration status of the data.
Specifically, theprocessing module 908 includes an allocating unit, and if the migration state of the data is migration, the allocating unit is configured to allocate the write request to the second database process, and allocate the read request to the first database or the second database process; and if the migration state of the data is migration completion, the allocation unit is used for allocating the read request and the write request to the second database for processing.
If the migration state of the data is migration, the allocating unit allocates the read request to the first database or the second database for processing specifically as follows: if the migration state of the data is migration, the allocation unit is used for searching whether the second database has data corresponding to the read request, and if so, the read request is allocated to the second database for processing; and if not, distributing the read request to the first database for processing.
As shown in fig. 10, in one embodiment, amigration module 1000 is provided, themigration module 1000 including acopy unit 1002, adetection unit 1004, adelete unit 1006, and apaste unit 1008.
The copyingunit 1002 is used for copying data in the first database.
The detectingunit 1004 is configured to detect whether the data already exists in the second database or whether a deletion request corresponding to the data is received by the second database.
The deletingunit 1006 is used to directly discard the data.
Thepasting unit 1008 is used to paste the data into the second database.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (16)

CN201510258062.7A2015-05-192015-05-19Data migration method and deviceActiveCN106294387B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201510258062.7ACN106294387B (en)2015-05-192015-05-19Data migration method and device

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201510258062.7ACN106294387B (en)2015-05-192015-05-19Data migration method and device

Publications (2)

Publication NumberPublication Date
CN106294387A CN106294387A (en)2017-01-04
CN106294387Btrue CN106294387B (en)2020-06-02

Family

ID=57632456

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201510258062.7AActiveCN106294387B (en)2015-05-192015-05-19Data migration method and device

Country Status (1)

CountryLink
CN (1)CN106294387B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN109725827B (en)*2017-10-272022-05-13伊姆西Ip控股有限责任公司Method, system and computer program product for managing a storage system
CN109189324B (en)*2018-07-092021-01-08华为技术有限公司Data migration method and device
CN110059075B (en)2019-03-262020-07-28阿里巴巴集团控股有限公司Method, device and equipment for migrating database and computer readable medium
CN111090701B (en)*2019-12-192024-04-02腾讯科技(深圳)有限公司Service request processing method, device, readable storage medium and computer equipment
CN111427868B (en)*2020-04-062023-05-09中信银行股份有限公司Processing method and device for operation request in database migration and electronic equipment
CN113222751B (en)*2021-02-182024-05-17百果园技术(新加坡)有限公司Data migration method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101185077A (en)*2005-03-312008-05-21瑞士银行股份有限公司Computer network system for constructing, synchronizing and/or managing a second database from/with a first database, and methods therefore
CN101861572A (en)*2007-11-192010-10-13国际商业机器公司 Techniques for Controlling Access to Databases
CN102331993A (en)*2011-06-232012-01-25北京新媒传信科技有限公司Data migration method of distributed database and distributed database migration system
CN102955845A (en)*2012-10-232013-03-06北京亿赞普网络技术有限公司Data access method and device as well as distributed database system
CN103490983A (en)*2013-09-172014-01-01新浪网技术(中国)有限公司Enterprise mail system and mail migration executing method thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN101185077A (en)*2005-03-312008-05-21瑞士银行股份有限公司Computer network system for constructing, synchronizing and/or managing a second database from/with a first database, and methods therefore
CN101861572A (en)*2007-11-192010-10-13国际商业机器公司 Techniques for Controlling Access to Databases
CN102331993A (en)*2011-06-232012-01-25北京新媒传信科技有限公司Data migration method of distributed database and distributed database migration system
CN102955845A (en)*2012-10-232013-03-06北京亿赞普网络技术有限公司Data access method and device as well as distributed database system
CN103490983A (en)*2013-09-172014-01-01新浪网技术(中国)有限公司Enterprise mail system and mail migration executing method thereof

Also Published As

Publication numberPublication date
CN106294387A (en)2017-01-04

Similar Documents

PublicationPublication DateTitle
CN106294387B (en)Data migration method and device
US11086638B2 (en)Method and apparatus for loading application
US20130179495A1 (en)System and method for alerting leakage of personal information in cloud computing environment
CN114416667B (en)Method and device for rapidly sharing network disk file, network disk and storage medium
CN106681799B (en)It is inserted into the methods, devices and systems of disk
CN113157477B (en)Memory leakage attribution method, device, electronic equipment and storage medium
US20170199889A1 (en)Method and device for identifying junk picture files
US12086106B2 (en)Method and apparatus for providing metadata sharing service
CN110688353A (en)File management method, device and computer readable medium
CN117827365A (en) Port allocation method, device, equipment, medium and product for application container
CN112115521A (en)Data access method and device
CN110022341B (en)Data transmission method and related equipment
CN114840562B (en)Distributed caching method and device for business data, electronic equipment and storage medium
US11157456B2 (en)Replication of data in a distributed file system using an arbiter
CN110674426B (en)Webpage behavior reporting method and device
CN111522626B (en)Virtual machine list generation method and device and electronic equipment
CN108228611B (en)Document information copying method and device
CN106202456B (en)Method and device for sending pictures
US20140297953A1 (en)Removable Storage Device Identity and Configuration Information
CN110888643A (en)Page processing method and device
CN107340974B (en)Virtual disk migration method and virtual disk migration device
CN116414716A (en)Stability test method for application program, terminal equipment and storage medium
CN106557263B (en)For checking pseudo- shared method and apparatus in data block is deleted
CN106650480B (en)File access isolation method and device
US11080238B2 (en)System and method for interactive visual representation of metadata within a networked heterogeneous workflow environment

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp