Data migration method, device, program product, medium and electronic device
By creating two independent data migration threads during the data migration process, processing stock data and incremental data are processed, and the problem of the amount of data and incremental data migration in the data migration process is solved, and the stability and efficiency of data migration are improved. Essence
Patent Information
- Application Number
- CN202210270026.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2042-03-18
AI Technical Summary
During the data migration process, the migration of stock and incremental data may be confusing, resulting in the migration failure or inefficiency.
By creating two data migration threads, one is used for migration of stock data, and the other is used to migrate incremental data to ensure that the migration process of the two is not interfered.
This method improves the stability and efficiency of data migration, ensuring that the stock data and incremental data can be smoothly migrated to the target database.
Smart Images

Figure CN114661696B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computers and data migration, and in particular to a data migration method, device, program product, medium and electronic device. Background Art
[0002] In data migration scenarios, for example, when migrating cloud data from one cloud server to another cloud server, generally, new data may be stored in the cloud server while migrating data. In this case, data migration may be chaotic, resulting in data migration failure and low data migration efficiency. Based on this, how to improve data migration efficiency is a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0003] The embodiments of the present application provide a data migration method, apparatus, program product, medium and electronic device, thereby improving the data migration efficiency at least to a certain extent.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a data migration method is provided, including: creating a first data migration thread and a second data migration thread; migrating the existing data in the original database to the target database through the first data migration thread; and migrating the incremental data in the original database to the target database through the second data migration thread.
[0006] According to one aspect of an embodiment of the present application, a data migration device is provided, including: a creation unit, used to create a first data migration thread and a second data migration thread; a first migration unit, used to migrate the existing data in the original database to the target database through the first data migration thread; and a second migration unit, used to migrate the incremental data in the original database to the target database through the second data migration thread.
[0007] In some embodiments of the present application, based on the aforementioned scheme, the existing data corresponds to a data number, and the first migration unit is configured to: export the existing data in batches according to the data number sequence of each piece of existing data; and migrate each batch of existing data to the target database in sequence through the first data migration thread.
[0008] In some embodiments of the present application, based on the aforementioned scheme, the first migration unit is further configured as: the first data migration thread sends a first notification message of data migration to the second data migration thread; when the second data migration thread receives the first notification message, the second data migration thread sends a first confirmation message of data migration to the first data migration thread; when the first data migration thread receives the first confirmation message, the existing data to be migrated in the original database is determined, and the existing data in the original database is migrated to the target database through the first data migration thread.
[0009] In some embodiments of the present application, based on the aforementioned scheme, the first migration unit is further configured to: determine the moment when the second data migration thread receives the first notification information as the first moment; and determine the data written to the original database before the first moment as the stock data to be migrated.
[0010] In some embodiments of the present application, based on the aforementioned scheme, the device also includes: a writing unit, which is used to determine the moment when all the existing data in the original database are migrated to the target database as the second moment; and write incremental data to the original database within the time interval from the first moment to the second moment.
[0011] In some embodiments of the present application, based on the aforementioned scheme, the writing unit is configured as follows: after the first moment, recording incremental data through the second data migration thread, and writing the recorded incremental data into the original database; at the second moment, the first data migration thread sends a second notification message of data migration completion to the second data migration thread; when the second data migration thread receives the second notification message, it stops recording incremental data.
[0012] In some embodiments of the present application, based on the aforementioned scheme, the second migration unit is configured as follows: the second data migration thread sends a third notification message of data migration to the first data migration thread; when the first data migration thread receives the third notification message, the first data migration thread sends a second confirmation message of data migration to the second data migration thread; when the second data migration thread receives the second confirmation message, the incremental data to be migrated is determined in the original database, and the incremental data in the original database is migrated to the target database through the second data migration thread.
[0013] In some embodiments of the present application, based on the aforementioned scheme, the target database includes at least two sub-databases, and both the existing data and the incremental data carry an attribution identifier that matches the corresponding sub-database; the first migration unit is also configured to: according to the attribution identifier carried by each piece of existing data, migrate the existing data to the sub-database that matches the attribution identifier through the first data migration thread; the second migration unit is also configured to: according to the attribution identifier carried by each piece of incremental data, migrate the incremental data to the sub-database that matches the attribution identifier through the second data migration thread.
[0014] According to one aspect of an embodiment of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data migration method as described in the above embodiment.
[0015] According to one aspect of an embodiment of the present application, an electronic device is also provided, characterized in that it includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the data migration method as described in the above embodiments.
[0016] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement the operations performed by the data migration method described in the above embodiment.
[0017] In the technical solutions provided in some embodiments of the present application, when data needs to be migrated from one database to another, by creating two data migration threads, where one data thread is used to migrate existing data and the other data thread is used to migrate incremental data, it can be ensured that the migration process of the existing data and the migration process of the incremental data do not interfere with each other. In other words, while the incremental data is continuously written to the original database and migrated to the target database, the process of migrating the existing data in the original database to the target database will not be affected in any way. It can be seen that the technical solution proposed in the present application can enhance the stability of data migration, and thus improve the efficiency of data migration.
[0018] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0020] Figure 1 A schematic diagram showing an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied;
[0021] Figure 2 A flow chart of a data migration method according to an embodiment of the present application is shown;
[0022] Figure 3 A detailed flow chart of migrating stock data in an original database to a target database through the first data migration thread according to an embodiment of the present application is shown;
[0023] Figure 4 A detailed flow chart of migrating stock data in an original database to a target database through the first data migration thread according to an embodiment of the present application is shown;
[0024] Figure 5 A detailed flow chart of determining the stock data to be migrated in the original database according to an embodiment of the present application is shown;
[0025] Figure 6 A detailed flow chart of data migration according to an embodiment of the present application is shown;
[0026] Figure 7 A detailed flow chart of writing incremental data to the original database within a time interval from the first moment to the second moment according to an embodiment of the present application is shown;
[0027] Figure 8 A detailed flow chart of migrating incremental data in an original database to a target database through the second data migration thread according to an embodiment of the present application is shown;
[0028] Fig. 9 A demonstration diagram of a data migration process according to an embodiment of the present application is shown;
[0029] Fig.10 A block diagram of a data migration device according to an embodiment of the present application is shown;
[0030] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0031] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0032] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0033] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0034] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0035] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the objects used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those shown or described.
[0037] Figure 1 A schematic diagram of an exemplary system architecture to which the technical solution of the embodiments of the present application can be applied is shown.
[0038] like Figure 1 As shown, the system architecture may include terminal devices (such as Figure 1 The embodiment of the present invention is a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal device and the server 105. The network 104 may include various connection types, such as a wired communication link, a wireless communication link, etc.
[0039] In one embodiment of the present application, in a scenario where data in an original database (such as server 105) needs to be migrated to a target database (such as a terminal device), server 105 can first create a first data migration thread and a second data migration thread, wherein, on the one hand, the existing data in the original database can be migrated to the target database through the first data migration thread, and on the other hand, the incremental data in the original database can be migrated to the target database through the second data migration thread.
[0040] In this embodiment, when it is necessary to migrate data from one database to another, two data migration threads are created, where one data thread is used to migrate existing data and the other data thread is used to migrate incremental data. This ensures that the migration process of the existing data and the migration process of the incremental data do not interfere with each other. In other words, while the incremental data is continuously written to the original database and migrated to the target database, the process of migrating the existing data in the original database to the target database will not be affected in any way. It can be seen that the technical solution proposed in the present application can enhance the stability of data migration, and thus improve the efficiency of data migration.
[0041] It should be noted that the data migration method provided in the embodiment of the present application can be executed by the server 105, and accordingly, the data migration device is generally arranged in the server 105. However, in other embodiments of the present application, the terminal device can also have similar functions as the server, so as to execute the data migration solution provided in the embodiment of the present application.
[0042] It should also be noted that Figure 1 The number of terminal devices, networks and servers in the description is only for illustration. According to the implementation requirements, the server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0043] It should be explained that cloud computing as described above is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, and expanded at any time. By establishing a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform, various types of virtual resources are deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0044] The implementation details of the technical solution of the embodiment of the present application are described in detail below:
[0045] Figure 2 A flow chart of a data migration method according to an embodiment of the present application is shown. The data migration method can be executed by a device having a computing processing function, such as Figure 1 , or may be performed by the server 105 shown in Figure 1 Refer to the terminal device shown in Figure 2 As shown, the data migration method at least includes steps 210 to 250, which are described in detail as follows:
[0046] In step 210, a first data migration thread and a second data migration thread are created.
[0047] First of all, it should be noted that the data migration solution proposed in this application can be applied to the overall migration scenario of cloud data in cloud services. In a specific scenario, cloud data is stored in cloud server A (i.e., the original database). Under some application requirements, such as the need to back up the cloud data in cloud server A, the cloud data can be migrated from cloud server A to cloud server B (i.e., the target database). However, in the process of migrating cloud data from cloud server A to cloud server B, new data may be stored in cloud server A. In this case, data migration may be chaotic, resulting in data migration failure.
[0048] Based on the above situation, two data migration threads can be created, namely the first data migration thread and the second data migration thread, wherein the first data migration thread can be used to migrate the existing data in cloud server A to cloud server B, and the second data migration thread can be used to migrate the newly stored incremental data in cloud server A to cloud server B.
[0049] In the present application, the data in the original database may exist in the form of a data table or in the form of a data packet, and the present application does not make any specific limitation on this.
[0050] Continue to refer to Figure 2 In step 230, the stock data in the original database is migrated to the target database through the first data migration thread.
[0051] In the present application, the stock data may correspond to a data number.
[0052] Specifically, for example, the stock data may refer to 1,000 data tables, wherein each data table may have a data number, for example, "0001" represents the first data table in the stock data, "0500" represents the 500th data table in the stock data, and "1000" represents the 1,000th data table in the stock data.
[0053] In such Figure 2 In one embodiment of step 230, the first data migration thread migrates the stock data in the original database to the target database as follows: Figure 3 Follow the steps shown.
[0054] See also Figure 3 , shows a detailed flow chart of migrating the stock data in the original database to the target database through the first data migration thread according to an embodiment of the present application, specifically including steps 231 to 232:
[0055] Step 231, exporting the stock data in batches according to the data serial number sequence of each stock data.
[0056] Step 232: Migrate each batch of stock data to the target database in sequence through the first data migration thread.
[0057] In this embodiment, for example, the existing data includes 1,000 data tables, and the existing data can be exported in batches in order of data numbers from small to large. For example, data tables with data numbers "1-100", "101-200", ..., "901-1000" are exported in sequence, and then, the data tables with data numbers "1-100", "101-200", ..., "901-1000" are migrated to the target database in sequence through the first data migration thread.
[0058] In this embodiment, on the one hand, by exporting the stock data in batches according to the data serial number sequence of each stock data, the progress and position of data migration can be mastered in real time, and when data migration is interrupted, data migration can still be continued at the interrupted position, thereby enhancing the stability of data migration and improving the efficiency of data migration. On the other hand, migrating each batch of stock data to the target database in sequence can ensure that data migration is carried out in an orderly manner, thereby also improving the efficiency of data migration to a certain extent.
[0059] In such Figure 2 In one embodiment of step 230, the first data migration thread is used to migrate the stock data in the original database to the target database. Figure 4 Follow the steps shown.
[0060] See also Figure 4 , shows a detailed flow chart of migrating the stock data in the original database to the target database through the first data migration thread according to an embodiment of the present application, specifically including steps 233 to 235:
[0061] Step 233: The first data migration thread sends first notification information of data migration to the second data migration thread.
[0062] Step 234: When the second data migration thread receives the first notification information, the second data migration thread sends first confirmation information of data migration to the first data migration thread.
[0063] Step 235: When the first data migration thread receives the first confirmation information, the stock data to be migrated is determined in the original database, and the stock data in the original database is migrated to the target database through the first data migration thread.
[0064] In the present application, before migrating the existing data in the original database through the first data migration thread, the first data migration thread can send a notification message, namely, the first notification message, to the second data migration thread. After receiving the first notification message, the second data migration thread can feedback a confirmation message, namely, the first confirmation message, to the first data migration thread. Furthermore, after receiving the first confirmation message, the first data migration thread can determine the existing data to be migrated in the original database and migrate the existing data to be migrated to the target database.
[0065] In such Figure 4 In one embodiment of step 235, the stock data to be migrated is determined in the original database, and the following method can be used: Figure 5 Follow the steps shown.
[0066] See also Figure 5 , shows a detailed flow chart of determining the stock data to be migrated in the original database according to an embodiment of the present application, specifically including steps 2351 to 2352:
[0067] Step 2351: determine the time when the second data migration thread receives the first notification information as the first time.
[0068] Step 2352: determine the data written into the original database before the first moment as the stock data to be migrated.
[0069] In the present application, when the second data migration thread receives the first notification information, that is, the first moment, it means that the first data migration thread is ready to start migrating the existing data to the target database. At this time, the first data migration thread no longer records the newly added data, that is, it no longer writes the newly added data as stock data into the original database, and thus the data written into the original database before the first moment can be determined as the stock data to be migrated.
[0070] In this embodiment, the following can also be performed: Figure 6 Steps shown.
[0071] See also Figure 6 , shows a detailed flow chart of data migration according to an embodiment of the present application, specifically including steps 241 to 242:
[0072] Step 241: determine the time when all the stock data in the original database are migrated to the target database as the second time.
[0073] Step 242: writing the incremental data into the original database during the time interval from the first moment to the second moment.
[0074] In the present application, the moment when all the existing data in the original database are migrated to the target database can be determined as the second moment. It can be understood that, within the time interval between the first moment and the second moment, all the existing data in the original database are migrated to the target database. At the same time, the newly added data may not be migrated to the target database within the time interval between the first moment and the second moment, but is only written into the original database as incremental data.
[0075] Specifically, in Figure 6 In one embodiment of step 242, the incremental data is written to the original database during the time interval from the first moment to the second moment, and the incremental data can be written as follows: Figure 7 Follow the steps shown.
[0076] See also Figure 7 , shows a detailed flow chart of writing incremental data to the original database within the time interval from the first moment to the second moment according to an embodiment of the present application, specifically including steps 2421 to 2423:
[0077] Step 2421: After the first moment, incremental data is recorded by the second data migration thread, and the recorded incremental data is written into the original database.
[0078] Step 2422: At the second moment, the first data migration thread sends a second notification message of data migration completion to the second data migration thread.
[0079] Step 2423: When the second data migration thread receives the second notification information, stop recording incremental data.
[0080] In the present application, during the process of the first data migration thread migrating the existing data in the original database to the target database, the second data migration thread records the incremental data and writes the recorded incremental data into the original database. Furthermore, during the process of recording the incremental data, the second data migration thread may number the incremental data. For example, when the incremental data is in the form of a data table, the incremental data may be numbered based on the numbering of the existing data. If the last data table of the existing data is numbered "1000", the first data table of the incremental data may be numbered "1001".
[0081] Specifically, at the moment when the first data migration thread migrates all the existing data in the original database to the target database, that is, the second moment, the first data migration thread can send a second notification message of data migration completion to the second data migration thread, and the second data migration thread stops recording incremental data according to the second notification message.
[0082] In the present application, during the time interval between the first moment and the second moment, while the first data migration thread migrates the stock data in the original database to the target database, the second data migration thread records the incremental data and writes the recorded incremental data into the original database. The advantage is that while the incremental data is continuously written into the original database, the process of migrating the stock data in the original database to the target database will not be affected in any way, which can enhance the stability of data migration and thus improve the data migration efficiency.
[0083] In the present application, the target database may include at least two sub-databases, and the stock data may carry an attribution identifier that matches the corresponding sub-database.
[0084] For example, the at least two sub-databases may include database A and database B, and each piece of stock data may carry an attribution identifier a that matches database A, or an attribution identifier b that matches database B.
[0085] In such Figure 2 In one embodiment of step 230 shown, the stock data in the original database is migrated to the target database through the first data migration thread. According to the attribution identifier carried by each piece of stock data, the first data migration thread can migrate the stock data to a sub-database matching the attribution identifier.
[0086] For example, when the existing data is a data table, the data table with data number "0888" carries the attribution identifier a, then the data table with data number "0888" will be migrated to database A by the first data migration thread, and the data table with data number "0999" carries the attribution identifier b, then the data table with data number "0999" will be migrated to database B by the first data migration thread.
[0087] Continue to refer to Figure 2 In step 250, the incremental data in the original database is migrated to the target database through the second data migration thread.
[0088] In such Figure 2 In one embodiment of step 250, the incremental data in the original database is migrated to the target database by the second data migration thread, which can be performed as follows: Figure 8 Follow the steps shown.
[0089] See also Figure 8 , shows a detailed flow chart of migrating incremental data in the original database to the target database through the second data migration thread according to an embodiment of the present application. Specifically including steps 251 to 253:
[0090] Step 251: The second data migration thread sends third notification information of data migration to the first data migration thread.
[0091] Step 252: When the first data migration thread receives the third notification information, the first data migration thread sends second confirmation information of data migration to the second data migration thread.
[0092] Step 253: When the second data migration thread receives the second confirmation information, the incremental data to be migrated is determined in the original database, and the incremental data in the original database is migrated to the target database through the second data migration thread.
[0093] In the present application, after the first data migration thread migrates all the stock data in the original database to the target database, the second data migration thread can migrate the incremental data written into the original database to the target database.
[0094] Specifically, before migrating the incremental data in the original database through the second data migration thread, the second data migration thread may send a notification message, i.e., the third notification message, to the first data migration thread. After receiving the third notification message, the first data migration thread may feedback a confirmation message, i.e., the second confirmation message, to the second data migration thread. Furthermore, after receiving the second confirmation message, the second data migration thread may determine the incremental data to be migrated in the original database, and migrate the incremental data to be migrated to the target database.
[0095] Furthermore, in the process of migrating the incremental data in the original database through the second data migration thread, the new incremental data can be recorded by the first data migration thread and the recorded new incremental data can be written into the original database. Until the second data migration thread migrates all the incremental data in the original database to the target database, the first data migration thread stops recording the new incremental data. Subsequently, the new incremental data recorded by the first data migration thread can be migrated to the target database by itself.
[0096] It can be understood that the first data migration thread and the second data migration thread can ensure that while the incremental data is continuously written to the original database, the process of migrating the existing data in the original database to the target database will not be affected at all, by alternately completing the writing of data into the original database and the migration of data from the original database to the target database. This can enhance the stability of data migration and improve data migration efficiency.
[0097] In the present application, the incremental data may also carry an attribution identifier that matches the corresponding sub-database, and the incremental data may carry an attribution identifier that matches the corresponding sub-database.
[0098] For example, the at least two sub-databases may include database A and database B, and each incremental data may carry an attribution identifier a that matches database A, or an attribution identifier b that matches database B.
[0099] In such Figure 2 In one embodiment of the step 250 shown, the incremental data in the original database is migrated to the target database through the second data migration thread. According to the attribution identifier carried by each incremental data, the incremental data can be migrated to the sub-database matching the attribution identifier through the second data migration thread.
[0100] For example, when the incremental data is a data table, the data table numbered "0888" carries the attribution identifier a, then the data table numbered "0888" will be migrated to database A by the second data migration thread, and the data table numbered "0999" carries the attribution identifier b, then the data table numbered "0999" will be migrated to database B by the second data migration thread.
[0101] In order to enable those skilled in the art to better understand the data migration solution in the present application, it will be explained with reference to 9 below.
[0102] Reference Fig. 9 , showing a demonstration diagram of the data migration process according to an embodiment of the present application.
[0103] Specifically, Fig. 9 As shown, first, the first data migration thread 903 sends a first notification message to the second data migration thread 904 to migrate the stock data from the original database 901 to the target database 902. When the second data migration thread 904 receives the first notification message, it records the incremental data and writes the incremental data into the original database 901. Then, the second data migration thread 904 sends a first confirmation message to the first data migration thread 903 to migrate the stock data from the original database 901 to the target database 902. When the first data migration thread 903 receives the first confirmation message, it starts to migrate the stock data from the original database 901 to the target database 902. Secondly, after the first data migration thread 903 completes the migration of all the stock data, it sends a second notification message to the second data migration thread 904 to complete the migration of all the stock data. When the second data migration thread 904 receives the second notification message, it stops recording the incremental data. Again, the second data migration thread 904 sends a third notification message to migrate the incremental data from the original database 901 to the target database 902 to the first data migration thread 903. Upon receiving the third notification message, the first data migration thread 903 records the new incremental data and writes the new incremental data into the original database 901. Finally, the first data migration thread 903 sends a second confirmation message to migrate the incremental data from the original database 901 to the target database 902 to the second data migration thread 904. Upon receiving the second confirmation message, the second data migration thread 904 starts to migrate the incremental data from the original database 901 to the target database 902.
[0104] In the present application, when it is necessary to migrate data from one database to another, two data migration threads are created, wherein one data thread is used to migrate existing data and the other data thread is used to migrate incremental data. This ensures that the migration process of existing data and the migration process of incremental data do not interfere with each other. In other words, while the incremental data is continuously written to the original database and migrated to the target database, the process of migrating the existing data in the original database to the target database will not be affected in any way. It can be seen that the technical solution proposed in the present application can enhance the stability of data migration, and thus improve the efficiency of data migration.
[0105] The following describes an apparatus embodiment of the present application, which can be used to execute the data migration method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned embodiment of the data migration method of the present application.
[0106] Fig.10 A block diagram of a data migration device according to an embodiment of the present application is shown.
[0107] Reference Fig.10 As shown, a data migration device 1000 according to an embodiment of the present application includes: a creation unit 1001 , a first migration unit 1002 , and a second migration unit 1003 .
[0108] Among them, the creation unit 1001 is used to create a first data migration thread and a second data migration thread; the first migration unit 1002 is used to migrate the existing data in the original database to the target database through the first data migration thread; the second migration unit 1003 is used to migrate the incremental data in the original database to the target database through the second data migration thread.
[0109] In some embodiments of the present application, based on the aforementioned scheme, the existing data corresponds to a data number, and the first migration unit 1002 is configured to: export the existing data in batches according to the data number sequence of each piece of existing data; and migrate each batch of existing data to the target database in sequence through the first data migration thread.
[0110] In some embodiments of the present application, based on the aforementioned scheme, the first migration unit 1002 is also configured as: the first data migration thread sends a first notification message of data migration to the second data migration thread; when the second data migration thread receives the first notification message, the second data migration thread sends a first confirmation message of data migration to the first data migration thread; when the first data migration thread receives the first confirmation message, the existing data to be migrated in the original database is determined, and the existing data in the original database is migrated to the target database through the first data migration thread.
[0111] In some embodiments of the present application, based on the aforementioned scheme, the first migration unit 1002 is further configured to: determine the moment when the second data migration thread receives the first notification information as the first moment; and determine the data written to the original database before the first moment as the stock data to be migrated.
[0112] In some embodiments of the present application, based on the aforementioned scheme, the device also includes: a writing unit, which is used to determine the moment when all the existing data in the original database are migrated to the target database as the second moment; and write incremental data to the original database within the time interval from the first moment to the second moment.
[0113] In some embodiments of the present application, based on the aforementioned scheme, the writing unit is configured as follows: after the first moment, recording incremental data through the second data migration thread, and writing the recorded incremental data into the original database; at the second moment, the first data migration thread sends a second notification message of data migration completion to the second data migration thread; when the second data migration thread receives the second notification message, it stops recording incremental data.
[0114] In some embodiments of the present application, based on the aforementioned scheme, the second migration unit 1003 is configured as follows: the second data migration thread sends a third notification message of data migration to the first data migration thread; when the first data migration thread receives the third notification message, the first data migration thread sends a second confirmation message of data migration to the second data migration thread; when the second data migration thread receives the second confirmation message, the incremental data to be migrated is determined in the original database, and the incremental data in the original database is migrated to the target database through the second data migration thread.
[0115] In some embodiments of the present application, based on the aforementioned scheme, the target database includes at least two sub-databases, and both the existing data and the incremental data carry an attribution identifier that matches the corresponding sub-database; the first migration unit 1002 is also configured to: according to the attribution identifier carried by each piece of existing data, migrate the existing data to the sub-database that matches the attribution identifier through the first data migration thread; the second migration unit 1003 is also configured to: according to the attribution identifier carried by each piece of incremental data, migrate the incremental data to the sub-database that matches the attribution identifier through the second data migration thread.
[0116] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0117] It should be noted that Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0118] like Fig.11 As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1102 or the program loaded from the storage part 1108 to the random access memory (RAM) 1103, such as executing the method described in the above embodiment. In the RAM 1103, various programs and data required for system operation are also stored. The CPU 1101, the ROM 1102 and the RAM 1103 are connected to each other through the bus 1104. The input / output (I / O) interface 1105 is also connected to the bus 1104.
[0119] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom is installed into the storage section 1108 as needed.
[0120] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1109, and / or installed from a removable medium 1111. When the computer program is executed by a central processing unit (CPU) 1101, various functions defined in the system of the present application are executed.
[0121] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0122] The flowchart and block diagram in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0123] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0124] As another aspect, the present application further provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data migration method described in the above embodiment.
[0125] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the data migration method described in the above embodiment.
[0126] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0127] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0128] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0129] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A data migration method, characterized in that: The method comprises: Creating a first data migration thread and a second data migration thread, so as to alternately complete writing data into an original database and migrating data in the original database to a target database through the first data migration thread and the second data migration thread; Migrating the stock data in the original database to the target database through the first data migration thread includes: sending a first notification message of data migration by the first data migration thread to the second data migration thread; when the second data migration thread receives the first notification message, sending a first confirmation message of data migration by the second data migration thread to the first data migration thread, and determining the time when the second data migration thread receives the first notification message as the first time; when the first data migration thread receives the first confirmation message, determining the data written to the original database before the first time as the stock data to be migrated, and migrating the stock data in the original database to the target database through the first data migration thread, and determining the time when all the stock data in the original database is migrated to the target database as the second time; after the first time, recording incremental data through the second data migration thread, and writing the recorded incremental data to the original database; at the second time, sending a second notification message of data migration completion by the first data migration thread to the second data migration thread; when the second data migration thread receives the second notification message, stopping recording incremental data; Migrating the incremental data in the original database to the target database through the second data migration thread includes: the second data migration thread sends a third notification message of data migration to the first data migration thread; when the first data migration thread receives the third notification message, the first data migration thread sends a second confirmation message of data migration to the second data migration thread; when the second data migration thread receives the second confirmation message, determining the incremental data to be migrated in the original database, and migrating the incremental data in the original database to the target database through the second data migration thread; in the process of migrating the incremental data in the original database through the second data migration thread, recording the new incremental data through the first data migration thread, and writing the recorded new incremental data into the original database, until the second data migration thread migrates all the incremental data in the original database to the target database, and the first data migration thread stops recording the new incremental data.
2. The method according to claim 1, characterized in that The stock data corresponds to a data number, and the migrating the stock data in the original database to the target database through the first data migration thread includes: Exporting the stock data in batches according to the data serial number sequence of each stock data; Each batch of stock data is migrated to the target database in sequence through the first data migration thread.
3. The method according to claim 1, characterized in that The target database includes at least two sub-databases, and both the stock data and the incremental data carry attribution identifiers that match the corresponding sub-databases; The migrating the stock data in the original database to the target database by using the first data migration thread includes: according to the attribution identifier carried by each piece of stock data, migrating the stock data to a sub-database matching the attribution identifier by using the first data migration thread; The migrating the incremental data in the original database to the target database through the second data migration thread includes: according to the attribution identifier carried by each incremental data, migrating the incremental data to the sub-database matching the attribution identifier through the second data migration thread.
4. A data migration device, characterized in that: The device comprises: a creating unit, used to create a first data migration thread and a second data migration thread, so as to alternately complete writing data into an original database and migrating data in the original database to a target database through the first data migration thread and the second data migration thread; The first migration unit is used to migrate the stock data in the original database to the target database through the first data migration thread, including: the first data migration thread sends a first notification message of data migration to the second data migration thread; when the second data migration thread receives the first notification message, the second data migration thread sends a first confirmation message of data migration to the first data migration thread, and determines the time when the second data migration thread receives the first notification message as the first time; when the first data migration thread receives the first confirmation message, the data written to the original database before the first time is determined as the stock data to be migrated, and the stock data in the original database is migrated to the target database through the first data migration thread, and the time when the stock data in the original database is completely migrated to the target database is determined as the second time; after the first time, the second data migration thread records the incremental data, and writes the recorded incremental data to the original database; at the second time, the first data migration thread sends a second notification message of data migration completion to the second data migration thread; when the second data migration thread receives the second notification message, it stops recording the incremental data; The second migration unit is used to migrate the incremental data in the original database to the target database through the second data migration thread, including: the second data migration thread sends a third notification message of data migration to the first data migration thread; when the first data migration thread receives the third notification message, the first data migration thread sends a second confirmation message of data migration to the second data migration thread; when the second data migration thread receives the second confirmation message, the incremental data to be migrated is determined in the original database, and the incremental data in the original database is migrated to the target database through the second data migration thread; in the process of migrating the incremental data in the original database through the second data migration thread, the new incremental data is recorded through the first data migration thread, and the recorded new incremental data is written into the original database, until the second data migration thread migrates all the incremental data in the original database to the target database, and the first data migration thread stops recording the new incremental data.
5. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium and are suitable for being read and executed by a processor, so that a computer device having the processor executes the data migration method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program code, and the at least one program code is loaded and executed by a processor to implement the operations performed by the data migration method according to any one of claims 1 to 3.
7. An electronic device, characterized in that: The electronic device includes one or more processors and one or more memories, wherein the one or more memories store at least one program code, and the at least one program code is loaded and executed by the one or more processors to implement the operations performed by the data migration method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Data migration method, data migration system, computer system and storage medium
CN111881116A
Data migration method and device
CN114116681A