Data migration method and device
By traversing the directory file to obtain the directory node path and the data to be migrated, and assembling and storing it according to the format of the target storage system, it solves the problem of data migration between different storage systems and realizes the switching and upgrade of the service framework storage system.
Patent Information
- Application Number
- CN202110324765.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-26
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-03-26
AI Technical Summary
Data cannot be migrated directly between existing storage systems, making it impossible to switch or upgrade the service framework storage system.
By determining the directory file of the data to be migrated, traversing the directory file to obtain the directory node path, obtaining and assembling the data to be migrated, storing it according to the data format of the target storage system, and monitoring the directory node to process events, realizing the connection between different storage systems data migration.
It realizes data migration between different storage systems, allows direct switching or upgrade of the storage system of the service framework, and improves management and maintenance efficiency.
Smart Images

Figure CN113050890B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data migration method and device. Background Art
[0002] For the various services that can be provided under the service framework, the same storage system is often used to store the configuration information, domain name and other data of the service, so as to achieve unified management and maintenance of different services under the service framework.
[0003] With the development and progress of storage systems, in order to improve the management and maintenance efficiency of services, it is necessary to switch or upgrade the storage system currently used by the service framework. Since different storage systems use different data storage structures, it is necessary to migrate the data in the storage system before switching or upgrading the storage system. However, it is currently impossible to directly implement data migration between different storage systems, so it is also impossible to directly switch or upgrade the storage system of the service framework. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a data migration method and device, which can migrate data between different storage systems and realize the switching and upgrading of the service framework storage system.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a data migration method is provided, comprising:
[0006] Determine a directory file corresponding to the data to be migrated in the first storage system;
[0007] Traversing the directory file to obtain one or more directory node paths from the root directory to the directory node;
[0008] Obtain the data to be migrated stored in each directory node path;
[0009] Assembling the directory node path and the data to be migrated according to the data format of the second storage system;
[0010] The assembled directory node path and the data to be migrated are stored in the second storage system.
[0011] Optionally, the directory node path and the data to be migrated are assembled in a key-value format, wherein the directory node path is the key and the data to be migrated is the value.
[0012] Optionally, it also includes:
[0013] The directory node corresponding to each of the directory node paths is monitored, so as to process the directory node path and the data to be migrated stored in the second storage system according to the monitored events.
[0014] Optionally, the event includes any one or more of the following: a directory node creation event, a directory node deletion event, a directory node data change event, and a sub-directory node deletion event under a directory node.
[0015] Optionally, when a directory node data change event is monitored, updated data to be migrated stored under the directory node path is obtained from the first storage system to update the data to be migrated corresponding to the directory node path in the second storage system.
[0016] Optionally, when a directory node deletion event is monitored, monitoring of the directory node is canceled, and the directory node path and the data to be migrated corresponding to the directory node in the second storage system are deleted.
[0017] Optionally, when a directory node creation event is monitored, the directory node path corresponding to the created directory node and the data to be migrated are stored in the second storage system, and the created directory node is monitored.
[0018] Optionally, in case of monitoring a deletion event of a sub-directory node under a directory node, cancel monitoring of the directory node and the sub-directory nodes under the directory node;
[0019] All directory node paths containing the directory node and the to-be-migrated data corresponding to the directory node paths in the second storage system are deleted.
[0020] Optionally, the directory node path is stored in an array variable, so that the directory node corresponding to each directory node path is monitored by traversing the array variable.
[0021] Optionally, the first storage system is Zookeeper, and the second storage system is Etcd.
[0022] To achieve the above object, according to another aspect of an embodiment of the present invention, a data migration device is provided, comprising: a directory file determination module, a node path acquisition module, a migration data acquisition module, a data assembly module, and a data storage module: wherein,
[0023] The directory file determination module is used to determine the directory file corresponding to the data to be migrated in the first storage system;
[0024] The node path acquisition module is used to traverse the directory file to obtain one or more directory node paths from the root directory to the directory node;
[0025] The migration data acquisition module is used to acquire the data to be migrated stored in each directory node path;
[0026] The data assembly module is used to assemble the directory node path and the data to be migrated according to the data format of the second storage system;
[0027] The data storage module is used to store the assembled directory node path and the data to be migrated in the second storage system.
[0028] Optionally, the data assembly module is used to assemble the directory node path and the data to be migrated in a key-value format; wherein the directory node path is the key and the data to be migrated is the value.
[0029] Optionally, the data storage module is further used to:
[0030] The directory node corresponding to each of the directory node paths is monitored, so as to process the directory node path and the data to be migrated stored in the second storage system according to the monitored events.
[0031] Optionally, the event includes any one or more of the following: a directory node creation event, a directory node deletion event, a directory node data change event, and a sub-directory node deletion event under a directory node.
[0032] Optionally, the data storage module is further used to:
[0033] When a directory node data change event is monitored, the updated data to be migrated stored under the directory node path is obtained from the first storage system to update the data to be migrated corresponding to the directory node path in the second storage system.
[0034] Optionally, the data storage module is further used to:
[0035] In the case of monitoring a directory node deletion event, the monitoring of the directory node is canceled, and the directory node path and the to-be-migrated data corresponding to the directory node in the second storage system are deleted.
[0036] Optionally, the data storage module is further used to:
[0037] In the case of monitoring a directory node creation event, the directory node path corresponding to the created directory node and the data to be migrated are stored in the second storage system, and the created directory node is monitored.
[0038] Optionally, in case of monitoring a deletion event of a sub-directory node under a directory node, cancel monitoring of the directory node and the sub-directory nodes under the directory node;
[0039] All directory node paths containing the directory node and the to-be-migrated data corresponding to the directory node paths in the second storage system are deleted.
[0040] Optionally, the data storage module is used to store the directory node path into an array variable, so as to monitor the directory node corresponding to each directory node path by traversing the array variable.
[0041] Optionally, the first storage system is Zookeeper, and the second storage system is Etcd.
[0042] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, there is provided an electronic device for data migration, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods described in the above-mentioned data migration methods.
[0043] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the data migration methods described above is implemented.
[0044] An embodiment of the above invention has the following advantages or beneficial effects: by traversing the directory files in the first storage system, obtaining the directory node path from the directory node and the data to be migrated stored under the directory node path, and assembling the directory node path and the data to be migrated according to the data format of the second storage system to store them in the second storage system, data migration between the first storage system and the second storage system with different data storage structures is realized, and the first storage system can be directly switched to the second storage system.
[0045] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0047] Figure 1 is a schematic diagram of the main process of the data migration method according to an embodiment of the present invention;
[0048] Figure 2 is a schematic diagram of the main process of another data migration method according to an embodiment of the present invention;
[0049] Figure 3 is a schematic diagram of main modules of a data migration device according to an embodiment of the present invention;
[0050] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0051] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0053] Figure 1 is a schematic diagram of the main process of the data migration method according to an embodiment of the present invention. Figure 1 As shown, the data migration method may specifically include the following steps:
[0054] Step S101: determine a directory file corresponding to the data to be migrated in a first storage system.
[0055] That is to say, the first storage system uses a directory structure to store service configuration information, service port number, service domain name, and data to be migrated. Specifically, taking the first storage system as Zookeeper as an example, ZooKeeper, as an important component of Hadoop and Hbase, provides configuration maintenance, domain name services, distributed synchronization and other services for multiple application services. Therefore, the directory files stored therein have one or more directory nodes, including root directory nodes, sub-directory nodes, descendant directory nodes, etc. More specifically, the directory structure indicated by the directory file corresponding to the data to be migrated in Zookeeper is as follows:
[0056] / root_key: / / root directory
[0057] / level_1_key1: / / First level directory node 1
[0058] / level_2_key1: / / Second level directory node 1
[0059] / level_3_key1: / / Third level directory node 1
[0060] / level_4_key1: / / Fourth level directory node 1
[0061] / level_5_key1: / / Fifth level directory node 1
[0062] / level_5_key2: / / Fifth level directory node 2
[0063] / level_4_key2: / / Fourth level directory node 2
[0064] / level_3_key2: / / Third level directory node 2
[0065] / level_2_key2: / / Second level directory node 2
[0066] / level_1_key2: / / First level directory node 2
[0067] Among them, root_key, level_1_key1, level_1_key2, etc. are directory nodes; further, root_key is the root directory node, level_1_key1 and level_1_key2 are sub-directory nodes under the root directory, level_2_key1 is the sub-directory node under level_1_key1, and level_3_key1 is the sub-directory node under level_2_key1 or the descendant directory node under level_1_key1. It can be seen that the same directory node can be a sub-directory node of another directory node or a descendant directory node of another directory node. In other words, for any directory node, it may have a sub-directory node at the next level, or it may not have a sub-directory node at the next level; in addition, each directory node may store service configuration information, service port number, service domain name, and data waiting to be migrated, or the corresponding data to be migrated may be empty.
[0068] Step S102, traverse the directory file to obtain one or more directory node paths from the root directory to the directory node.
[0069] Specifically, still taking the directory file in the above Zookeeper as an example, the directory node path traversed from the root directory node to any directory node can be obtained. For example, taking the directory node level_1_key1 as an example, the corresponding directory node path is / root_key / level_1_key1, and taking the directory node level_2_key1 as an example, the corresponding directory node path is / root_key / level_1_key1 / leve2_1_key1. Further, one or more directory node paths obtained after traversing the directory file are as follows:
[0070] / root_key
[0071] / root_key / level_1_key1
[0072] / root_key / level_1_key1 / level_2_key1
[0073] / root_key / level_1_key1 / level_2_key1 / level_3_key1
[0074] / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1
[0075] / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1 / level_5_key1
[0076] / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1 / level_5_key2
[0077] / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key2
[0078] / root_key / level_1_key1 / level_2_key1 / level_3_key2
[0079] / root_key / level_1_key1 / level_2_key2
[0080] / root_key / level_1_key2
[0081] Step S103, obtaining the data to be migrated stored in each directory node path.
[0082] Specifically, the corresponding data to be migrated can be obtained by directly reading the data stored in the directory node path. Since each directory node may store service configuration information, service port number, service domain name, and data to be migrated, and the corresponding data to be migrated may be empty, in order to ensure the normal management and maintenance of the service after migration, when the data to be migrated is read to be empty, the corresponding directory path node is still retained, and the corresponding data to be migrated is directly recorded as empty or blank.
[0083] Step S104: assemble the directory node path and the data to be migrated according to the data format of the second storage system.
[0084] Specifically, taking the second storage system as Etcd as an example, compared with Zookeeper, in terms of function implementation, Etcd only needs to call the watch operation once to capture all events, which greatly simplifies the workload of client developers; in terms of code development, Etcd uses the Go language and Google's gRPC protocol, while ZooKeeper uses the Java language and its own TCP protocol. Therefore, developers are limited by the SDK officially provided by ZooKeeper and can only directly use Java and C languages for development, which has low flexibility. Therefore, in some business scenarios, consider using Etcd to replace Zookeeper to store configuration information, etc. to manage and maintain services. Since Etcd uses a distributed key-value database to store metadata such as configuration information to coordinate and manage services, when Etcd is used to replace Zookeeper, the directory node path and the data to be migrated are assembled in the form of key-value; wherein, the directory node path is key, and the data to be migrated is value. Based on this, examples of assembled directory node paths and data to be migrated are as follows:
[0085] ( / root_key,root_key_value)
[0086] ( / root_key / level_1_key1,level_1_key1_value)
[0087] ( / root_key / level_1_key1 / level_2_key1,level_2_key1_value)
[0088] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1,level_3_key1_value)
[0089] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1,level_4_key1_value)
[0090] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1 / level_5_key1,level_5_key1_value)
[0091] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1 / level_5_key2,level_5_key2_value)
[0092] Step S105: storing the assembled directory node path and the data to be migrated in the second storage system.
[0093] In other words, by synchronizing the assembled directory node path in key-value format and the data to be migrated to the second storage system Etcd, the configuration information and other data stored in the first storage system Zookeeper are migrated to the second storage system Etcd. Based on this, Etcd can be used instead of Zookeeper to manage and maintain application services.
[0094] It is understandable that in the process of migrating data from the first storage system to the second storage system at one time, or before switching the first storage system to the second storage system, the directory nodes and the data to be migrated in the first storage system may still change. Therefore, in order to ensure the high availability of the second storage system, in an optional implementation, it also includes: monitoring the directory nodes corresponding to each of the directory node paths, so as to process the directory node paths and the data to be migrated stored in the second storage system according to the monitored events.
[0095] The events include any one or more of the following: directory node creation events, directory node deletion events, directory node data changes, and directory node sub-directory node deletion events. Specifically, there are the following events that can be monitored (watched) in Zookeeper:
[0096] EventNodeCreated: Directory node creation event
[0097] EventNodeDeleted: Directory node deletion event
[0098] EventNodeDataChanged: Directory node data change event
[0099] EventNodeChildrenChanged: Subdirectory node change event under the directory node
[0100] Among them, the sub-directory node change event under the directory node specifically includes sub-directory node creation, sub-directory node deletion, and sub-directory node data change. However, since the above directory node creation event, directory node deletion event, and directory node data change event are monitored for each directory node including but not limited to the root directory, sub-directory node, and descendant directory node in the embodiment of the present invention, in order to avoid duplication with the sub-directory node change event under the directory node, only the monitoring of the sub-directory node deletion event under the directory node is retained.
[0101] More specifically, one or more directory node paths obtained by traversing the directory file can be stored in an array variable, so that the directory node corresponding to each directory node path can be monitored by traversing the array variable. It is understandable that monitoring can also be performed by writing the directory node path into a file or a table.
[0102] In an optional implementation, when a directory node data change event is monitored, the updated data to be migrated stored under the directory node path is obtained from the first storage system to update the data to be migrated corresponding to the directory node path in the second storage system.
[0103] In an optional implementation, when a directory node deletion event is monitored, monitoring of the directory node is canceled, and the directory node path and the data to be migrated corresponding to the directory node in the second storage system are deleted.
[0104] In an optional implementation, when a directory node creation event is monitored, the directory node path corresponding to the created directory node and the data to be migrated are stored in the second storage system, and the created directory node is monitored.
[0105] In an optional implementation, when a sub-directory node deletion event under a directory node is monitored, the monitoring of the directory node and the sub-directory nodes under the directory node is canceled; all directory node paths containing the directory node and the data to be migrated corresponding to the directory node paths in the second storage system are deleted.
[0106] Based on the above embodiment, by traversing the directory files in the first storage system, obtaining the directory node path from the directory node and the data to be migrated stored under the directory node path, and assembling the directory node path and the data to be migrated according to the data format of the second storage system to store them in the second storage system, data migration between the first storage system and the second storage system with different data storage structures is realized, and the first storage system can be directly switched to the second storage system.
[0107] See also Figure 2 Based on the above embodiment, the embodiment of the present invention provides another data migration method, which may specifically include the following steps:
[0108] Step S201: determine a directory file corresponding to the data to be migrated in the first storage system.
[0109] Step S202: traverse the directory file to obtain one or more directory node paths from the root directory to the directory node.
[0110] Step S203, obtaining the data to be migrated stored in each directory node path.
[0111] Step S204: assemble the directory node path and the data to be migrated according to the data format of the second storage system.
[0112] Step S205: storing the assembled directory node path and the data to be migrated in the second storage system.
[0113] Step S206, monitor the directory nodes corresponding to each directory node path. Specifically, if a directory node data change event is monitored, continue to execute the following step S207; if a directory node deletion event is monitored, continue to execute the following step S208; if a directory node creation event is monitored, continue to execute the following step S209; if a sub-directory node deletion event is monitored, continue to execute the following step S210.
[0114] Step S207: acquiring updated data to be migrated stored in the directory node path from the first storage system to update the data to be migrated corresponding to the directory node path in the second storage system.
[0115] Specifically, taking the example of monitoring the data change of the directory node level_1_key1 corresponding to the directory node path / root_key / level_1_key1, the latest data to be migrated (such as 152) stored under the directory node path / root_key / level_1_key1 is obtained from the first storage system, and the value in the key-value pair ( / root_key / level_1_key1, level_1_key1_value) stored in the second storage system is updated to 152.
[0116] Step S208, canceling the monitoring of the directory node, and deleting the directory node path and the data to be migrated corresponding to the directory node in the second storage system.
[0117] Specifically, taking the monitoring of a directory node deletion event corresponding to the directory node level_2_key1 as an example, the key-value pair ( / root_key / level_1_key1 / level_2_key1, level_2_key1_value) is deleted from the second storage system.
[0118] Step S209: store the directory node path corresponding to the created directory node and the data to be migrated in the second storage system, and monitor the created directory node.
[0119] Taking the example of monitoring the creation of a new directory node level_1_key3 under the directory node root_key, the directory node level_1_key3 is monitored for directory node creation events, directory node deletion events, directory node data changes, sub-directory node deletion events under the directory node, and other events. At the same time, the key-value pair ( / root_key / level_1_key3, level_1_key3_value) corresponding to the directory node level_1_key3 is stored in the second storage system.
[0120] Step S210, canceling monitoring of the directory node and the sub-directory nodes under the directory node, and deleting all directory node paths containing the directory node and the to-be-migrated data corresponding to the directory node paths in the second storage system.
[0121] Taking the monitoring of the sub-directory node deletion event under the directory node corresponding to level_1_key1 as an example for explanation, since the directory node paths corresponding to the directory node level_1_key1 and its corresponding sub-directory nodes level_2_key1, level_3_key1, level_4_key1, level_5_key1, etc. all include the directory node level_1_key1, therefore, the monitoring of the directory node level_1_key1 and its corresponding sub-directory nodes level_2_key1, level_3_key1, level_4_key1, level_5_key1, etc. is canceled; at the same time, the key-value pairs corresponding to the directory nodes level_1_key1, level_2_key1, level_3_key1, level_4_key1, level_5_key1, etc. are deleted in the second storage system, that is, the following key-value pairs are deleted from the second storage system:
[0122] ( / root_key / level_1_key1,level_1_key1_value)
[0123] ( / root_key / level_1_key1 / level_2_key1,level_2_key1_value)
[0124] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1,level_3_key1_value)
[0125] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1,level_4_key1_value)
[0126] ( / root_key / level_1_key1 / level_2_key1 / level_3_key1 / level_4_key1 / level_5_key1,level_5_key1_value)
[0127] In this way, after all the data in the first storage system is synchronized to the second storage system at one time, the real-time and effectiveness of the directory node path and the data to be migrated in the second storage system are guaranteed by monitoring the directory node, thereby improving the high availability of the second storage system.
[0128] See also Figure 3Based on the above embodiments, the present invention provides a data migration device 300, including: a directory file determination module 301, a node path acquisition module 302, a migration data acquisition module 303, a data assembly module 304, and a data storage module 305: wherein,
[0129] The directory file determination module 301 is used to determine the directory file corresponding to the data to be migrated in the first storage system;
[0130] The node path acquisition module 302 is used to traverse the directory file to obtain one or more directory node paths from the root directory to the directory node;
[0131] The migration data acquisition module 303 is used to acquire the data to be migrated stored in each directory node path;
[0132] The data assembly module 304 is used to assemble the directory node path and the data to be migrated according to the data format of the second storage system;
[0133] The data storage module 305 is used to store the assembled directory node path and the data to be migrated in the second storage system.
[0134] In an optional implementation, the data assembly module 304 is used to assemble the directory node path and the data to be migrated in a key-value format; wherein the directory node path is the key, and the data to be migrated is the value.
[0135] In an optional implementation, the data storage module 305 is further used to:
[0136] The directory node corresponding to each of the directory node paths is monitored, so as to process the directory node path and the data to be migrated stored in the second storage system according to the monitored events.
[0137] In an optional implementation, the event includes any one or more of the following: a directory node creation event, a directory node deletion event, a directory node data change event, and a sub-directory node deletion event under a directory node.
[0138] In an optional implementation, the data storage module 305 is further used to:
[0139] When a directory node data change event is monitored, the updated data to be migrated stored under the directory node path is obtained from the first storage system to update the data to be migrated corresponding to the directory node path in the second storage system.
[0140] In an optional implementation, the data storage module 305 is further used to:
[0141] In the case of monitoring a directory node deletion event, the monitoring of the directory node is canceled, and the directory node path and the to-be-migrated data corresponding to the directory node in the second storage system are deleted.
[0142] In an optional implementation, the data storage module 305 is further used to:
[0143] In the case of monitoring a directory node creation event, the directory node path corresponding to the created directory node and the data to be migrated are stored in the second storage system, and the created directory node is monitored.
[0144] In an optional implementation, when a sub-directory node deletion event under a directory node is monitored, the monitoring of the directory node and the sub-directory nodes under the directory node is canceled; all directory node paths containing the directory node and the data to be migrated corresponding to the directory node paths in the second storage system are deleted.
[0145] In an optional implementation, the data storage module 305 is used to store the directory node path into an array variable, so as to monitor the directory node corresponding to each directory node path by traversing the array variable.
[0146] In an optional implementation, the first storage system is Zookeeper, and the second storage system is Etcd.
[0147] Figure 4 An exemplary system architecture 400 is shown to which the data migration method or data migration apparatus according to the embodiment of the present invention can be applied.
[0148] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0149] The user can use the terminal devices 401, 402, 403 to interact with the server 405 through the network 404 to receive or send messages, etc. Various applications, such as visualization applications, can be installed on the terminal devices 401, 402, 403 to display the progress of data migration.
[0150] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0151] The server 405 may be a server that provides various services, such as a background management server that processes data migration requests sent by users using the terminal devices 401 , 402 , and 403 , and feeds back the data migration progress to the terminal devices.
[0152] It should be noted that the data migration method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the data migration device is generally disposed in the server 405 .
[0153] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0154] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device suitable for implementing an embodiment of the present invention. Figure 5 The terminal 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 invention.
[0155] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0156] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0157] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include 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 the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0158] It should be noted that the computer-readable medium shown in the present invention 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 or 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 invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal 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 a program 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, wire, optical cable, RF, etc., or any suitable combination of the above.
[0159] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a 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 flow chart, and the combination of the boxes in the block diagram or flow chart 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.
[0160] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor including a directory file determination module, a node path acquisition module, a migration data acquisition module, a data assembly module, and a data storage module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the directory file determination module may also be described as a "module for determining a directory file corresponding to the data to be migrated in the first storage system."
[0161] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: determining the directory file corresponding to the data to be migrated in the first storage system; traversing the directory file to obtain one or more directory node paths from the root directory to the directory node; obtaining the data to be migrated stored under each of the directory node paths; assembling the directory node path and the data to be migrated according to the data format of the second storage system; and storing the assembled directory node path and the data to be migrated in the second storage system.
[0162] According to the technical solution of the embodiment of the present invention, by traversing the directory files in the first storage system, obtaining the directory node path from the directory node and the data to be migrated stored under the directory node path, and assembling the directory node path and the data to be migrated according to the data format of the second storage system to store them in the second storage system, data migration between the first storage system and the second storage system with different data storage structures is realized, and the first storage system can be directly switched to the second storage system.
[0163] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data migration method, characterized in that: include: Determine a directory file corresponding to the data to be migrated in the first storage system; Traversing the directory file to obtain one or more directory node paths from the root directory to the directory node; Obtain the data to be migrated stored in each directory node path; Assembling the directory node path and the data to be migrated according to the data format of the second storage system; Assembling the directory node path and the data to be migrated in a key-value format; wherein the directory node path is the key and the data to be migrated is the value; storing the assembled directory node path and the data to be migrated into the second storage system; The directory node corresponding to each of the directory node paths is monitored, so as to process the directory node path and the data to be migrated stored in the second storage system according to the monitored events.
2. The data migration method according to claim 1, characterized in that: The event includes any one or more of the following: a directory node creation event, a directory node deletion event, a directory node data change event, and a sub-directory node deletion event under a directory node.
3. The data migration method according to claim 2, characterized in that: When a directory node data change event is monitored, the updated data to be migrated stored under the directory node path is obtained from the first storage system to update the data to be migrated corresponding to the directory node path in the second storage system.
4. The data migration method according to claim 2, characterized in that: In the case of monitoring a directory node deletion event, the monitoring of the directory node is canceled, and the directory node path and the to-be-migrated data corresponding to the directory node in the second storage system are deleted.
5. The data migration method according to claim 2, characterized in that: In the case of monitoring a directory node creation event, the directory node path corresponding to the created directory node and the data to be migrated are stored in the second storage system, and the created directory node is monitored.
6. The data migration method according to claim 2, characterized in that: In case of monitoring a deletion event of a sub-directory node under a directory node, canceling monitoring of the directory node and the sub-directory nodes under the directory node; All directory node paths containing the directory node and the to-be-migrated data corresponding to the directory node paths in the second storage system are deleted.
7. The data migration method according to claim 1, characterized in that: The directory node path is stored in an array variable, so as to monitor the directory node corresponding to each directory node path by traversing the array variable.
8. The data migration method according to claim 1, characterized in that: The first storage system is Zookeeper, and the second storage system is Etcd.
9. A data migration device, characterized in that: include: Directory file determination module, node path acquisition module, migration data acquisition module, data assembly module, data storage module: Among them, The directory file determination module is used to determine the directory file corresponding to the data to be migrated in the first storage system; The node path acquisition module is used to traverse the directory file to obtain one or more directory node paths from the root directory to the directory node; The migration data acquisition module is used to acquire the data to be migrated stored in each directory node path; The data assembly module is used to assemble the directory node path and the data to be migrated according to the data format of the second storage system; assemble the directory node path and the data to be migrated in the form of key-value; wherein the directory node path is the key and the data to be migrated is the value; The data storage module is used to store the assembled directory node path and the data to be migrated in the second storage system; and is also used to monitor the directory nodes corresponding to each directory node path, so as to process the directory node path and the data to be migrated stored in the second storage system according to the monitored events.
10. An electronic device for data migration, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
File level hierarchical storage management system, method, and apparatus
CN102667772A
Method and device for data migration
CN105530273A
