A distributed migration method for object storage
By deploying distributed clusters in object storage migration and utilizing the automatic screening and task allocation mechanism of primary nodes and secondary nodes, the problem of low migration efficiency in the existing technology is solved, efficient and safe object storage migration is achieved, and manual labor is reduced. Operation and maintenance work.
Patent Information
- Application Number
- CN202010882876.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-28
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-08-28
AI Technical Summary
Existing object storage migration tools are inefficient and deployed on a single machine. They cannot increase speed through clustering and cannot efficiently and safely migrate objects from one object storage system to another.
Deploy a distributed cluster, including a primary node and multiple secondary nodes. Filter nodes by object name, storage type, storage permissions, object size or creation time period, and automatically assign tasks during the migration process to ensure the efficiency of migration. and security.
It achieves efficient and safe migration of objects from one object storage system to another, minimizes manual operation and maintenance work, and improves migration speed and reliability.
Smart Images

Figure CN112035064B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing and object storage migration, and in particular to a distributed migration method for object storage. Background Art
[0002] Object storage is a distributed storage product that can natively support HTTP / HTTPS protocols. As long as you are connected to the Internet, you can directly use the object storage service. With the development and maturity of object storage, more and more Internet websites and apps are beginning to store some static resources in object storage services, which not only reduces the pressure on the server, but also reduces costs.
[0003] There are many different object storage service providers. When users want to change object storage service providers or want to do security redundancy in multiple object storage service providers, they will have the need to migrate object storage. However, the existing migration tools are inefficient and often deployed on a single machine, and cannot achieve the purpose of speeding up by establishing a cluster.
[0004] In order to efficiently and safely migrate objects from one object storage system to another object storage system, the present invention proposes a distributed migration method for object storage. Summary of the invention
[0005] In order to overcome the defects of the prior art, the present invention provides a simple and efficient distributed migration method for object storage.
[0006] The present invention is achieved through the following technical solutions:
[0007] A distributed migration method for object storage, characterized in that: a distributed cluster is deployed, including a master node and several slave nodes, each node is screened by object name, storage type, storage permission, object size or creation time period, and only nodes that meet the requirements are migrated;
[0008] When a bad node is found in the migration object during the migration process, the tasks of the bad node can be assigned to the remaining surviving nodes in the migration object.
[0009] The following steps are involved:
[0010] S1. Preparation of the original object storage service
[0011] Create a migration-specific folder in the bucket to be migrated in the original object storage service, and create a migration information file under it to store the target object storage bucket information and migration object screening rules;
[0012] From the start of migration to the end of migration, objects in the original object storage bucket can be added but not deleted, and added objects will not be migrated.
[0013] S2. Preparation and startup of migration nodes
[0014] The migration node sets startup parameters before startup;
[0015] After connecting to the original object storage bucket, all nodes in the distributed cluster first check whether there is a file named master in the migration folder to determine the primary node and the secondary node; the secondary node reads the content of the master file and sends a registration request to the primary node according to the host and IP information recorded in the master file; after the initialization is completed, the primary node also sends a registration request to itself to start the migration task of its own node;
[0016] After receiving the registration request, the master node creates a task file named after the registered node host and a log file named after the node host.log in the migration folder; the task file is responsible for saving the assigned tasks and the IP address of the secondary node, and the log file is responsible for saving the progress that the node has executed;
[0017] S3. New node joining and migration task execution
[0018] Migration tasks are stored in the file named after the node host in the bucket in the form of an Etag prefix. When a new node registers to join the distributed cluster, the master node takes out the appropriate Etag prefix from the existing node, puts it into the task file of the new node, and identifies the node from which the task comes in the file. Then, the master node deletes the taken Etag prefix from the task file of the existing node.
[0019] When the master node creates a log file for a new node, it adds the latest logs with the Etag prefix from the old node to the log file of the new node. The new node continues the task based on the Etag prefix in the log file.
[0020] The new node starts with the task with the least number of objects retrieved. If the object list retrieved by the task contains the end mark of other tasks, the other tasks corresponding to the end mark are started and migrated in parallel with the task, and so on, until all tasks assigned to the new node are carried out together;
[0021] When a node executes a migration task, it takes out a batch of object lists from the original object storage bucket each time, then checks its own task list to obtain its latest task prefix, and then transfers the filtered migration objects to the new object storage bucket according to the migration object screening rule and Etag prefix. After the batch of objects is transferred, the end mark of the object list that has been taken out, the total number of objects that have been taken out, and the Etag prefix of this screening are recorded;
[0022] S4. Node self-management
[0023] Both the master node and the slave node provide health check interfaces to the outside world;
[0024] The master node periodically checks the health of the slave nodes. When a slave node is found to be down, the master node immediately distributes the tasks of the downed slave node evenly to other surviving slave nodes.
[0025] The secondary node also regularly checks the health of the primary node. When the primary node is found to be down, the oldest secondary node other than the primary node automatically becomes the primary node, rewrites the IP and host in the master file to its own, and then executes the task of the primary node to maintain the cluster;
[0026] S5. End of Migration Task
[0027] When the end mark of the task log is null, it means that the task has traversed all existing objects, all migration objects of the task have been migrated, the task has ended, and the task will no longer be assigned to the new node when the new node joins;
[0028] When all migration tasks of the distributed cluster are completed, the master node prints the end log to indicate that the migration task is completed.
[0029] In the step S1, the target object storage bucket information is stored, including the access-key, secret-key, endpoint and bucket name information of the target object storage bucket; the node connects to the new object storage bucket by reading the migration information file, and puts the object into the new object storage bucket.
[0030] In step S2, the startup parameters include the folder name of the migration-specific folder, the file name of the migration information file, the node name of the migration node (which must be unique in the entire migration cluster), the access-key, secret-key, and endpoint and bucket name information of the object storage to be migrated.
[0031] In step S2, if the distributed cluster node does not find a file named master in the migration folder after connecting to the original object storage bucket, it creates a master file and modifies the content of the master file to its own host name and IP address, indicating that the node is a master node;
[0032] If there is a file named master in the migration folder, it means that there is a master node in the distributed cluster and you are the slave node.
[0033] In step S1, the migration information file may also set an upper limit on the size of the cluster, which is 16 to the power of n;
[0034] In step S3, tasks are assigned according to the first m characters of the Etag of the migration object, and the tasks are divided into 16 m copies, m is a natural number obtained according to the cluster size n in the migration information file;
[0035] When the master node receives a registration request for the first time, it writes all prefixes into the task file of the registering node.
[0036] If m is 1, that is, the first character of Etag is used for allocation, the task is divided into 16 parts; if m is 2, that is, the first two characters of Etag are used for allocation, the task is divided into 256 parts, and so on.
[0037] In step S3, the master node periodically checks whether each node has duplicate tasks, and if duplicate tasks are found, deletes the duplicate tasks of the node with more tasks.
[0038] In step S4, when the oldest slave node and the master node in the distributed cluster hang up at the same time, the IP and host in the master file remain unchanged as the original master node until the health check of the slave node on the master node fails continuously, then the second oldest slave node becomes the master node; if the health check of the slave node on the master node still fails continuously, the next oldest slave node becomes the master node, and so on.
[0039] In step S5, after the secondary node completes all its tasks, it automatically resets and joins the cluster as a new node to seek new tasks.
[0040] The beneficial effects of the present invention are as follows: the distributed migration method for object storage, based on the characteristics of the object storage S3 protocol, deploys a migration cluster that can be automatically assembled and maintained, efficiently and safely migrates objects from one object storage system to another object storage system, and minimizes manual operation and maintenance work. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Attached Figure 1 The figure is a schematic diagram of the relationship between each node and each file in the distributed migration system for object storage of the present invention.
[0043] Attached Figure 2 This is a schematic diagram of the system flow for adding a new node to the present invention.
[0044] Attached Figure 3 The figure is a schematic diagram of the distributed migration process for object storage according to the present invention.
[0045] Attached Figure 4 It is a schematic diagram of the method for the primary node to manage the secondary node of the present invention.
[0046] Attached Figure 5 Schematic diagram of the method for checking the master node by the slave node of the present invention. DETAILED DESCRIPTION
[0047] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0048] The distributed migration method for object storage deploys a distributed cluster, including a master node and several slave nodes, and screens each node by object name, storage type, storage permission, object size or creation time period, and only migrates nodes that meet the requirements;
[0049] When a bad node is found in the migration object during the migration process, the tasks of the bad node can be assigned to the remaining surviving nodes in the migration object.
[0050] The following steps are involved:
[0051] S1. Preparation of the original object storage service
[0052] Create a migration-specific folder in the bucket to be migrated in the original object storage service, and create a migration information file under it to store the target object storage bucket information and migration object screening rules;
[0053] From the start of migration to the end of migration, objects in the original object storage bucket can be added but not deleted, and added objects will not be migrated;
[0054] Bucket is the name of the storage space in object storage. Migration is done in buckets.
[0055] An object is the smallest storage unit in object storage, and a bucket can contain up to millions of objects.
[0056] S2. Preparation and startup of migration nodes
[0057] The migration node sets startup parameters before startup;
[0058] After connecting to the original object storage bucket, all nodes in the distributed cluster first check whether there is a file named master in the migration folder to determine the primary node and the secondary node; the secondary node reads the content of the master file and sends a registration request to the primary node according to the host and IP information recorded in the master file; after the initialization is completed, the primary node also sends a registration request to itself to start the migration task of its own node;
[0059] After receiving the registration request, the master node creates a task file named after the registered node host and a log file named after the node host.log in the migration folder; the task file is responsible for saving the assigned tasks and the IP address of the secondary node, and the log file is responsible for saving the progress that the node has executed;
[0060] S3. New node joining and migration task execution
[0061] Etag is a hexadecimal string. Etag is calculated based on the file content and time, so it can act as a hash. Each object has its own Etag.
[0062] Migration tasks are stored in the file named after the node host in the bucket in the form of an Etag prefix. When a new node registers to join the distributed cluster, the master node takes out the appropriate Etag prefix from the existing node, puts it into the task file of the new node, and identifies the node from which the task comes in the file. Then, the master node deletes the taken Etag prefix from the task file of the existing node.
[0063] When the master node creates a log file for a new node, it adds the latest logs with the Etag prefix from the old node to the log file of the new node. The new node continues the task based on the Etag prefix in the log file.
[0064] The new node starts with the task with the least number of objects retrieved. If the object list retrieved by the task contains the end mark of other tasks, the other tasks corresponding to the end mark are started and migrated in parallel with the task, and so on, until all tasks assigned to the new node are carried out together;
[0065] For example, a new node takes out four tasks a, b, c, and d from other nodes and arranges them in order from small to large according to the number of objects transferred. Task a is performed first. When the list of objects taken out by task a contains the end mark of task b, task b is also started and transmitted in parallel with task a. After that, if the end mark of task c is encountered, task c is started, and so on, until the four tasks a, b, c, and d assigned to the new node are all performed together.
[0066] When a node executes a migration task, it takes out a batch of object lists (such as 1,000) from the original object storage bucket each time, then checks its own task list to obtain its latest task prefix, and then transfers the filtered migration objects to the new object storage bucket according to the migration object screening rule and Etag prefix; after the batch of objects is transferred, the end mark of the taken object list (through which the next batch of objects can be taken), the total number of objects taken out, and the Etag prefix of this screening are recorded;
[0067] S4. Node self-management
[0068] Both the master node and the slave node provide health check interfaces to the outside world;
[0069] The master node periodically checks the health of the slave nodes. When a slave node is found to be down, the master node immediately distributes the tasks of the downed slave node to other surviving slave nodes. The distribution process is as follows: Figure 2 described.
[0070] The secondary node also regularly checks the health of the primary node. When the primary node is found to be down, the oldest secondary node other than the primary node automatically becomes the primary node, rewrites the IP and host in the master file to its own, and then executes the task of the primary node to maintain the cluster;
[0071] S5. End of Migration Task
[0072] When getting the list of objects in the bucket, if the list is not reached at the end, the last object name will be used as the end marker. The next time you get it, you will pass this marker as a parameter to continue getting the remaining objects. If the list is reached at the end, the end marker will be null.
[0073] When the end mark of the task log is null, it means that the task has traversed all existing objects, all migration objects of the task have been migrated, the task has ended, and the task will no longer be assigned to the new node when the new node joins;
[0074] When all migration tasks of the distributed cluster are completed, the master node prints the end log to indicate that the migration task is completed.
[0075] In the step S1, the target object storage bucket information is stored, including the access-key, secret-key, endpoint and bucket name information of the target object storage bucket; the node connects to the new object storage bucket by reading the migration information file, and puts the object into the new object storage bucket.
[0076] In step S2, the startup parameters include the folder name of the migration-specific folder, the file name of the migration information file, the node name of the migration node (which must be unique in the entire migration cluster), the access-key, secret-key, and endpoint and bucket name information of the object storage to be migrated.
[0077] Access-key, secret-key and endpoint, that is, the key and address. With these three pieces of information, you can connect to the object storage service and perform operations such as upload, download, and management.
[0078] In step S2, if the distributed cluster node does not find a file named master in the migration folder after connecting to the original object storage bucket, it creates a master file and modifies the content of the master file to its own host name and IP address, indicating that the node is a master node;
[0079] If there is a file named master in the migration folder, it means that there is a master node in the distributed cluster and you are the slave node.
[0080] In step S1, the migration information file may also set an upper limit on the size of the cluster, which is 16 to the power of n;
[0081] In step S3, tasks are assigned according to the first m characters of the Etag of the migration object, and the tasks are divided into 16 m copies, m is a natural number obtained according to the cluster size n in the migration information file;
[0082] When the master node receives a registration request for the first time, it writes all prefixes into the task file of the registering node.
[0083] If m is 1, that is, the first character of Etag is used for allocation, the task is divided into 16 parts; if m is 2, that is, the first two characters of Etag are used for allocation, the task is divided into 256 parts, and so on.
[0084] In step S3, the master node periodically checks whether each node has duplicate tasks, and if duplicate tasks are found, deletes the duplicate tasks of the node with more tasks.
[0085] In step S4, when the oldest slave node and the master node in the distributed cluster hang up at the same time, the IP and host in the master file remain unchanged as the original master node until the health check of the slave node on the master node fails continuously, then the second oldest slave node becomes the master node; if the health check of the slave node on the master node still fails continuously, the next oldest slave node becomes the master node, and so on.
[0086] In step S5, after the secondary node completes all its tasks, it automatically resets and joins the cluster as a new node to seek new tasks.
[0087] The embodiment described above is only one specific implementation of the present invention. Common changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A distributed migration method for object storage, characterized in that: Based on the characteristics of the object storage S3 protocol, deploy a distributed cluster that can be automatically formed and maintained to efficiently and securely migrate objects from one object storage system to another; The distributed cluster consists of a master node and several slave nodes. Each node is screened by object name, storage type, storage permission, object size or creation time period, and only nodes that meet the requirements are migrated; When a bad node is found in the migration object during the migration process, the tasks of the bad node are assigned to the remaining surviving nodes in the migration object; The following steps are involved: S1. Preparation of the original object storage service Create a migration-specific folder in the bucket to be migrated in the original object storage service, and create a migration information file under it to store the target object storage bucket information and migration object screening rules; From the start of the migration to the end of the migration, objects in the original object storage bucket can only be added but not deleted, and added objects will not be migrated; S2. Preparation and startup of migration nodes The migration node sets startup parameters before startup; After connecting to the original object storage bucket, all nodes in the distributed cluster first check whether there is a file named master in the migration folder to determine the primary node and the secondary node; the secondary node reads the content of the master file and sends a registration request to the primary node according to the host and IP information recorded in the master file; after the initialization is completed, the primary node also sends a registration request to itself to start the migration task of its own node; After receiving the registration request, the master node creates a task file named after the registered node host and a log file named after the node host.log in the migration folder; the task file is responsible for saving the assigned tasks and the IP address of the slave node, and the log file is responsible for saving the progress that the node has executed; S3. New node joining and migration task execution Migration tasks are stored in the file named after the node host in the bucket in the form of an Etag prefix. When a new node registers to join the distributed cluster, the master node takes out the appropriate Etag prefix from the existing node, puts it into the task file of the new node, and identifies the node from which the task comes in the file. Then, the master node deletes the taken Etag prefix from the task file of the existing node. When the master node creates a log file for a new node, it adds the latest logs with the Etag prefix from the old node to the log file of the new node. The new node continues the task based on the Etag prefix in the log file. The new node starts with the task with the least number of objects retrieved. If the object list retrieved by the task contains the end mark of other tasks, the other tasks corresponding to the end mark are started and migrated in parallel with the task, and so on, until all tasks assigned to the new node are carried out together; When a node executes a migration task, it takes out a batch of object lists from the original object storage bucket each time, then checks its own task list to obtain its latest task prefix, and then transfers the filtered migration objects to the new object storage bucket according to the migration object screening rule and Etag prefix. After the batch of objects is transferred, the end mark of the object list that has been taken out, the total number of objects that have been taken out, and the Etag prefix of this screening are recorded; S4. Node self-management Both the master node and the slave node provide health check interfaces to the outside world; The master node periodically checks the health of the slave nodes. When a slave node is found to be down, the master node immediately distributes the tasks of the downed slave node evenly to other surviving slave nodes. The secondary node also regularly checks the health of the primary node. When the primary node is found to be down, the oldest secondary node other than the primary node automatically becomes the primary node, rewrites the IP and host in the master file to its own, and then executes the task of the primary node to maintain the cluster; S5. End of Migration Task When the end mark of the task log is null, it means that the task has traversed all existing objects, all migration objects of the task have been migrated, the task has ended, and the task will no longer be assigned to the new node when the new node joins; When all migration tasks of the distributed cluster are completed, the master node prints the end log to indicate that the migration task is completed.
2. The distributed migration method for object storage according to claim 1, characterized in that: In the step S1, the target object storage bucket information is stored, including the access-key, secret-key, endpoint and bucket name information of the target object storage bucket; the node connects to the new object storage bucket by reading the migration information file, and puts the object into the new object storage bucket.
3. The distributed migration method for object storage according to claim 1, characterized in that: In step S2, the startup parameters include the folder name of the migration-specific folder, the file name of the migration information file, the node name of the migration node, the access-key, secret-key, and endpoint and bucket name information of the object storage to be migrated.
4. The distributed migration method for object storage according to claim 1, characterized in that: In step S2, if the distributed cluster node does not find a file named master in the migration folder after connecting to the original object storage bucket, it creates a master file and modifies the content of the master file to its own host name and IP address, indicating that the node is a master node; If there is a file named master in the migration folder, it means that there is a master node in the distributed cluster and you are the slave node.
5. The distributed migration method for object storage according to claim 4, characterized in that: In the step S1, the upper limit of the size of the cluster is set to 16 to the power of n in the migration information file; In step S3, tasks are assigned according to the first m characters of the Etag of the migration object, and the tasks are divided into 16 m share; When the master node receives a registration request for the first time, it first creates a task file named after the registration node host in the migration folder, and then writes all prefixes into the task file of the registration node.
6. The distributed migration method for object storage according to claim 1, characterized in that: In step S3, the master node periodically checks whether each node has duplicate tasks, and if duplicate tasks are found, deletes the duplicate tasks of the node with more tasks.
7. The distributed migration method for object storage according to claim 1, characterized in that: In step S4, when the oldest slave node and the master node in the distributed cluster hang up at the same time, the IP and host in the master file remain unchanged as the original master node until the health check of the slave node on the master node fails continuously, then the second oldest slave node becomes the master node; if the health check of the slave node on the master node still fails continuously, the next oldest slave node becomes the master node, and so on.
8. The distributed migration method for object storage according to claim 1, characterized in that: In step S5, after the secondary node completes all its tasks, it automatically resets and joins the cluster as a new node to seek new tasks.
