Mirror image file synchronization method and device and computer readable storage medium

文档序号:1952560 发布日期:2021-12-10 浏览:16次 中文

阅读说明:本技术 镜像文件同步方法、装置及计算机可读存储介质 (Mirror image file synchronization method and device and computer readable storage medium ) 是由 王春磊 于 2021-09-17 设计创作,主要内容包括:本发明涉及计算机技术领域,具体提供一种镜像文件同步方法、方法及计算机可读存储介质,旨在解决如何提升镜像同步效率的问题。本发明的镜像文件同步方法包括:根据不同节点之间的通信效率确定节点同步路径,所有节点同步路径中的首个节点是同一个节点,首个节点是主节点,其它节点是从节点;控制主节点响应接收到的镜像文件,根据节点同步路径确定下一级从节点并发送镜像文件;针对每个从节点,控制从节点在接收到镜像文件后,根据从节点所属的节点同步路径确定从节点的下一级从节点并发送镜像文件。基于上述方式,只需向主节点发送镜像文件,就可以根据节点同步路径自动且快速地将这个镜像文件发送至每个节点,从而极大地提高了镜像同步效率。(The invention relates to the technical field of computers, in particular to a method and a method for synchronizing mirror image files and a computer readable storage medium, and aims to solve the problem of improving mirror image synchronization efficiency. The mirror image file synchronization method comprises the following steps: determining node synchronization paths according to communication efficiency among different nodes, wherein the first node in all the node synchronization paths is the same node, the first node is a master node, and other nodes are slave nodes; the control main node responds to the received mirror image file, determines a next-stage slave node according to the node synchronization path and sends the mirror image file; and for each slave node, after receiving the image file, the control slave node determines the next-level slave node of the slave node according to the node synchronization path to which the slave node belongs and sends the image file. Based on the mode, the mirror image file can be automatically and quickly sent to each node according to the node synchronization path only by sending the mirror image file to the main node, so that the mirror image synchronization efficiency is greatly improved.)

1. An image file synchronization method is applied to a distributed cluster system, the system comprises a plurality of nodes, and the method comprises the following steps:

determining a plurality of node synchronization paths according to the communication efficiency among different nodes, wherein the first node in all the node synchronization paths is the same node, the first node is a main node of each node synchronization path, and other nodes are slave nodes;

controlling the main node to respond to the received mirror image file, determining a next-level slave node of the main node according to a node synchronization path, and sending the mirror image file to the next-level slave node;

and for each slave node, controlling the slave node to determine a next-level slave node of the slave node according to a node synchronization path to which the slave node belongs and sending the image file to the next-level slave node after the slave node receives the image file.

2. The image file synchronization method according to claim 1, wherein the step of determining a plurality of node synchronization paths according to communication efficiency between different nodes specifically comprises:

step S1: the method comprises the steps that a control main node sends control information to all slave nodes, the time length for each slave node to carry out information feedback according to the control information is obtained, the communication efficiency between the main node and each slave node is determined according to the time length, a plurality of slave nodes with the highest communication efficiency are selected and used as next-level slave nodes of the main node in parallel, and a plurality of initial node synchronization paths are constructed according to the main node and each next-level slave node;

step S2: for each initial node synchronization path, updating the initial node synchronization path by:

taking the slave nodes which are not selected from all the slave nodes as target slave nodes;

controlling the last-stage slave node in the initial node synchronization path to send control information to the target slave nodes, acquiring the time length for each target slave node to perform information feedback according to the control information, determining the communication efficiency of the last-stage slave node and each target slave node according to the time length, and selecting a plurality of target slave nodes with the highest communication efficiency to be parallel as the next-stage slave nodes of the last-stage slave nodes;

updating the initial node synchronization path according to the next-stage slave node, and taking the next-stage slave node as the updated last-stage slave node;

step S3: and repeatedly executing the step S2 until all the slave nodes are selected, and finishing the updating of the initial node synchronization path to obtain a final node synchronization path.

3. The image file synchronization method of claim 2,

when the control information is ping value confirmation information, the time length for the slave node to feed back according to the control information is a ping value;

when the control information is the time for copying the same group of data information to other slave nodes, the time for the slave nodes to feed back according to the control information is the time required for finishing copying the data information.

4. The image file synchronization method according to claim 1, wherein the master node is provided with an image master repository, and each slave node is provided with an image slave repository; the mirror image master warehouse and the mirror image slave warehouse are respectively configured to store mirror image files;

and/or the like and/or,

the master node and each slave node are provided with a docker engine capable of running mirror image files;

and/or the like and/or,

different nodes in the distributed cluster system are communicated through respective domain names;

and/or the like and/or,

the main node is also provided with a database;

the database is configured to record node information of all nodes and the node synchronization path, wherein the node information at least comprises domain names of the nodes.

5. An image file synchronization apparatus applied to a distributed cluster system, the system comprising a plurality of nodes, the apparatus comprising:

a synchronous path determining module configured to determine a plurality of node synchronous paths according to communication efficiency between different nodes, wherein a first node in all the node synchronous paths is the same node, the first node is a master node of each node synchronous path, and other nodes are slave nodes;

a first mirror image synchronization module configured to control the master node to determine a next-level slave node of the master node according to a node synchronization path and to transmit the mirror image file to the next-level slave node in response to the received mirror image file;

and the second image synchronization module is configured to control the slave nodes to determine the next-level slave nodes of the slave nodes according to the node synchronization paths to which the slave nodes belong and send the image files to the next-level slave nodes after receiving the image files.

6. The image file synchronization apparatus of claim 5, wherein the synchronization path determination module is further configured to:

step S1: the method comprises the steps that a control main node sends control information to all slave nodes, the time length for each slave node to carry out information feedback according to the control information is obtained, the communication efficiency between the main node and each slave node is determined according to the time length, a plurality of slave nodes with the highest communication efficiency are selected to be arranged in parallel to serve as next-level slave nodes of the main node, and a plurality of initial node synchronization paths are constructed according to the main node and each next-level slave node;

step S2: for each initial node synchronization path, updating the initial node synchronization path by:

taking the slave nodes which are not selected from all the slave nodes as target slave nodes;

controlling the last-stage slave node in the initial node synchronization path to send control information to the target slave nodes, acquiring the time length for each target slave node to perform information feedback according to the control information, determining the communication efficiency of the last-stage slave node and each target slave node according to the time length, and selecting a plurality of target slave nodes with the highest communication efficiency to be parallel as the next-stage slave nodes of the last-stage slave nodes;

updating the initial node synchronization path according to the next-stage slave node, and taking the next-stage slave node as the updated last-stage slave node;

step S3: and repeatedly executing the step S2 until all the slave nodes are selected, and finishing the updating of the initial node synchronization path to obtain a final node synchronization path.

7. The image file synchronization apparatus of claim 5,

when the control information is ping value confirmation information, the time length for the slave node to feed back according to the control information is a ping value;

when the control information is the time for copying the same group of data information to other slave nodes, the time for the slave nodes to feed back according to the control information is the time required for finishing copying the data information.

8. The image file synchronization device according to claim 1, wherein the master node is provided with a mirror master repository, and each slave node is provided with a mirror slave repository; the mirror image master warehouse and the mirror image slave warehouse are respectively configured to store mirror image files;

and/or the like and/or,

the master node and each slave node are provided with a docker engine capable of running mirror image files;

and/or the like and/or,

different nodes in the distributed cluster system are communicated through respective domain names;

and/or the like and/or,

the main node is also provided with a database;

the database is configured to record node information of all nodes and the node synchronization path, wherein the node information at least comprises domain names of the nodes.

9. A control apparatus comprising a processor and a storage device adapted to store a plurality of program codes, wherein said program codes are adapted to be loaded and run by said processor to perform the image file synchronization method of any of claims 1 to 4.

10. A computer-readable storage medium having stored therein a plurality of program codes, wherein the program codes are adapted to be loaded and executed by a processor to perform the image file synchronization method according to any one of claims 1 to 4.

Technical Field

The invention relates to the technical field of computers, and particularly provides a method and a device for synchronizing mirror image files and a computer readable storage medium.

Background

The image file is a single file made of a specific series of files according to a certain format, and is convenient for a user to download and use. In daily use, the image files are generally stored in an image repository to complete daily deployment and release, team collaboration, and the like. However, in a real production environment, a large number of image files are often generated, and a lot of tedious and repeated deployment and control work such as deployment, storage, distribution and use is accompanied regardless of a third-party image file or a self-built image file. In a scene where a part of sites using the image files are far away from sites storing the image files, the synchronization efficiency of the image files needs to be considered.

Accordingly, there is a need in the art for a new image file synchronization scheme to address the above-mentioned problems.

Disclosure of Invention

The present invention is directed to solve the above technical problem, that is, how to improve the synchronization efficiency of the mirror image file.

In a first aspect, the present invention provides a method for synchronizing mirror image files, which is applied to a distributed cluster system, where the system includes a plurality of nodes, and the method includes:

determining a plurality of node synchronization paths according to the communication efficiency among different nodes, wherein the first node in all the node synchronization paths is the same node, the first node is a main node of each node synchronization path, and other nodes are slave nodes;

controlling the main node to respond to the received mirror image file, determining a next-level slave node of the main node according to a node synchronization path, and sending the mirror image file to the next-level slave node;

and for each slave node, controlling the slave node to determine a next-level slave node of the slave node according to a node synchronization path to which the slave node belongs and sending the image file to the next-level slave node after the slave node receives the image file.

In one technical solution of the above method for synchronizing image files, "determining synchronization paths of a plurality of nodes according to communication efficiency between different nodes" specifically includes:

step S1: the method comprises the steps that a control main node sends control information to all slave nodes, the time length for each slave node to carry out information feedback according to the control information is obtained, the communication efficiency between the main node and each slave node is determined according to the time length, a plurality of slave nodes with the highest communication efficiency are selected to be arranged in parallel to serve as next-level slave nodes of the main node, and a plurality of initial node synchronization paths are constructed according to the main node and each next-level slave node;

step S2: for each initial node synchronization path, updating the initial node synchronization path by:

taking the slave nodes which are not selected from all the slave nodes as target slave nodes;

controlling the last-stage slave node in the initial node synchronization path to send control information to the target slave nodes, acquiring the time length for each target slave node to perform information feedback according to the control information, determining the communication efficiency of the last-stage slave node and each target slave node according to the time length, and selecting a plurality of target slave nodes with the highest communication efficiency to be parallel as the next-stage slave nodes of the last-stage slave nodes;

updating the initial node synchronization path according to the next-stage slave node, and taking the next-stage slave node as the updated last-stage slave node;

step S3: and repeatedly executing the step S2 until all the slave nodes are selected, and finishing the updating of the initial node synchronization path to obtain a final node synchronization path.

In one aspect of the above-mentioned image file synchronization method,

when the control information is ping value confirmation information, the time length for the slave node to feed back according to the control information is a ping value;

when the control information is the time for copying the same group of data information to other slave nodes, the time for the slave nodes to feed back according to the control information is the time required for finishing copying the data information.

In one technical solution of the above method for synchronizing mirror image files, the master node is provided with a mirror image master warehouse, and each slave node is provided with a mirror image slave warehouse;

the mirror image master warehouse and the mirror image slave warehouse are respectively configured to store mirror image files;

and/or the like and/or,

the master node and each slave node are provided with a docker engine capable of running mirror image files;

and/or the like and/or,

different nodes in the distributed cluster system are communicated through respective domain names;

and/or the like and/or,

the main node is also provided with a database;

the database is configured to record node information of all nodes and the node synchronization path, wherein the node information at least comprises domain names of the nodes.

In a second aspect, the present invention provides an image file synchronization apparatus, applied to a distributed cluster system, where the system includes a plurality of nodes, and the apparatus includes:

a synchronous path determining module configured to determine a plurality of node synchronous paths according to communication efficiency between different nodes, wherein a first node in all the node synchronous paths is the same node, the first node is a master node of each node synchronous path, and other nodes are slave nodes;

a first mirror image synchronization module configured to control the master node to determine a next-level slave node of the master node according to a node synchronization path and to transmit the mirror image file to the next-level slave node in response to the received mirror image file;

and the second image synchronization module is configured to control the slave nodes to determine the next-level slave nodes of the slave nodes according to the node synchronization paths to which the slave nodes belong and send the image files to the next-level slave nodes after receiving the image files.

In an aspect of the image file synchronization apparatus, the synchronization path determining module is further configured to perform the following operations:

step S1: the method comprises the steps that a control main node sends control information to all slave nodes, the time length for each slave node to carry out information feedback according to the control information is obtained, the communication efficiency between the main node and each slave node is determined according to the time length, a plurality of slave nodes with the highest communication efficiency are selected to be arranged in parallel to serve as next-level slave nodes of the main node, and a plurality of initial node synchronization paths are constructed according to the main node and each next-level slave node;

step S2: for each initial node synchronization path, updating the initial node synchronization path by:

taking the slave nodes which are not selected from all the slave nodes as target slave nodes;

controlling the last-stage slave node in the initial node synchronization path to send control information to the target slave nodes, acquiring the time length for each target slave node to perform information feedback according to the control information, determining the communication efficiency of the last-stage slave node and each target slave node according to the time length, and selecting a plurality of target slave nodes with the highest communication efficiency to be parallel as the next-stage slave nodes of the last-stage slave nodes;

updating the initial node synchronization path according to the next-stage slave node, and taking the next-stage slave node as the updated last-stage slave node;

step S3: and repeatedly executing the step S2 until all the slave nodes are selected, and finishing the updating of the initial node synchronization path to obtain a final node synchronization path.

In one embodiment of the above-mentioned image file synchronization apparatus,

when the control information is ping value confirmation information, the time length for the slave node to feed back according to the control information is a ping value;

when the control information is the time for copying the same group of data information to other slave nodes, the time for the slave nodes to feed back according to the control information is the time required for finishing copying the data information.

In one technical solution of the above mirror image file synchronization apparatus, the master node is provided with a mirror image master warehouse, and each slave node is provided with a mirror image slave warehouse;

the mirror image master warehouse and the mirror image slave warehouse are respectively configured to store mirror image files;

and/or the like and/or,

the master node and each slave node are provided with a docker engine capable of running mirror image files;

and/or the like and/or,

different nodes in the distributed cluster system are communicated through respective domain names;

and/or the like and/or,

the main node is also provided with a database;

the database is configured to record node information of all nodes and the node synchronization path, wherein the node information at least comprises domain names of the nodes.

In a third aspect, a control device is provided, which includes a processor and a storage device, where the storage device is adapted to store a plurality of program codes, and the program codes are adapted to be loaded and run by the processor to execute the image file synchronization method according to any one of the above-mentioned aspects of the image file synchronization method.

In a fourth aspect, a computer-readable storage medium is provided, in which a plurality of program codes are stored, and the program codes are adapted to be loaded and run by a processor to execute the image file synchronization method according to any one of the above-mentioned aspects of the image file synchronization method.

Under the condition of adopting the technical scheme, the invention can determine a plurality of node synchronization paths according to the communication efficiency among different nodes, wherein the first node in all the node synchronization paths is the same node, the first node is the master node of each node synchronization path, other nodes are slave nodes, when the mirror image file is required to be synchronized, the master node is controlled to respond to the received mirror image file, then the next-level slave node corresponding to the master node is determined according to the node synchronization paths, the mirror image file is sent to the next-level slave node, for each slave node, the slave node is controlled to determine the next-level slave node of the slave node according to the node synchronization path to which the slave node belongs after receiving the mirror image file, then the mirror image file is sent to the next-level slave node, and only the mirror image file is required to be sent to the master node through the steps, the image file can be automatically and quickly sent to each node according to the node synchronization path, so that the synchronization efficiency of the image file is greatly improved.

Drawings

The disclosure of the present invention will become more readily understood with reference to the accompanying drawings. As is readily understood by those skilled in the art: these drawings are for illustrative purposes only and are not intended to constitute a limitation on the scope of the present invention. Moreover, in the drawings, like numerals are used to indicate like parts, and in which:

FIG. 1 is a flow chart illustrating the main steps of a method for synchronizing an image file according to an embodiment of the present invention;

FIG. 2 is a flowchart illustrating a method for determining a node synchronization path according to an embodiment of the present invention;

FIG. 3 is a block diagram illustrating the main structure of an image file synchronization apparatus according to an embodiment of the present invention;

FIG. 4 is a schematic flowchart of a distributed cluster system for setting up an application scenario of the image file synchronization method according to an embodiment of the present invention;

FIG. 5 is a schematic diagram of a node synchronization path of a distributed cluster system of an application scenario of the image file synchronization method according to an embodiment of the present invention;

FIG. 6 is a node synchronization path diagram of an image file synchronization method according to an embodiment of the present invention.

FIG. 7 is a diagram of a distributed cluster system for a method for synchronizing an image file according to an embodiment of the present invention.

List of reference numerals

31: a synchronization path determination module; 32: a first mirror synchronization module; 33: a second mirror synchronization module.

Detailed Description

Some embodiments of the invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only for explaining the technical principle of the present invention, and are not intended to limit the scope of the present invention.

In the description of the present invention, a "module" or "processor" may include hardware, software, or a combination of both. A module may comprise hardware circuitry, various suitable sensors, communication ports, memory, may comprise software components such as program code, or may be a combination of software and hardware. The processor may be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and/or signal processing functionality. The processor may be implemented in software, hardware, or a combination thereof. Non-transitory computer readable storage media include any suitable medium that can store program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random-access memory, and the like. The term "a and/or B" denotes all possible combinations of a and B, such as a alone, B alone or a and B. The term "at least one A or B" or "at least one of A and B" means similar to "A and/or B" and may include only A, only B, or both A and B. The singular forms "a", "an" and "the" may include the plural forms as well.

Some terms to which the present invention relates are explained first.

Docker is an open source application container engine implemented in the Go language that can easily create and use containers. The container is a lightweight and flexible virtualization processing mode, all the items required by an application program are packaged together, in short, one or more image files are run in the container, and the container contains the environment required by running the image files. It should be noted that docker and container are conventional technical means in the computer field, and therefore the working principle of docker and container will not be explained in more detail here.

Referring to fig. 1, fig. 1 is a flow chart illustrating the main steps of a method for synchronizing an image file according to an embodiment of the present invention. As shown in fig. 1, the method for synchronizing an image file according to the embodiment of the present invention mainly includes the following steps S101 to S103.

Step S101: and determining a plurality of node synchronization paths according to the communication efficiency among different nodes, wherein the first node in all the node synchronization paths is the same node, the first node is a main node of each node synchronization path, and other nodes are slave nodes.

In one embodiment of the present embodiment, a plurality of node synchronization paths may be determined through steps S1 to S4 as shown in fig. 2:

step S1: the control master node sends control information to all slave nodes, the time length for each slave node to feed back information according to the control information is obtained, the communication efficiency between the master node and each slave node is determined according to the time length, a plurality of slave nodes with the highest communication efficiency are selected and used in parallel as next-level slave nodes of the master node, and a plurality of initial node synchronization paths are constructed according to the master node and the next-level slave nodes.

Step S2: the initial node synchronization paths are updated for each initial node synchronization path. Specifically, the initial node synchronization path may be updated for each initial node synchronization path through the following steps S21-S23:

step S21: and taking the slave nodes which are not selected from all the slave nodes as target slave nodes.

Step S22: the method comprises the steps of controlling the last-stage slave node in an initial node synchronization path to send control information to target slave nodes, obtaining the time length of each target slave node for information feedback according to the control information, determining the communication efficiency of the last-stage slave node and each target slave node according to the time length, and selecting a plurality of target slave nodes with the highest communication efficiency to be arranged in parallel to serve as the next-stage slave nodes of the last-stage slave nodes.

Step S23: and updating the initial node synchronization path according to the next-stage slave node, and taking the next-stage slave node as the updated last-stage slave node.

Step S3: and judging whether all the slave nodes are selected, if so, executing the step S4, otherwise, returning to the step S2.

Step S4: and finishing updating the initial node synchronization path to obtain a final node synchronization path.

In one implementation of this embodiment, when the control information is ping value confirmation information, the time duration for the slave node to feed back according to the control information is a ping value.

When the control information is the time for copying the same group of data information to other slave nodes, the time for the slave nodes to feed back according to the control information is the time required for finishing copying the data information.

Taking the example that the control information is a ping value, assuming that a certain distributed cluster system includes a master node and 10 slave nodes, and assuming that the code of the master node is a, and the code of each slave node is b, c, d, e, f, g, h, i, j and k, first, the master node a may be controlled to transmit control information to the slave nodes b, c, d, e, f, g, h, i, j and k, and determine that the communication ping values between the master node a and the slave nodes b, c, d, e, f, g, h, i, j and k are 10, 20, 30, 40 and 50, respectively, and it can be seen that the communication efficiency between the master node a and the slave nodes b, c and d is the highest, so that the slave nodes b, c and d may be the next-stage slave node of the master node a to construct 3 initial node synchronization paths. For the slave nodes b, c, d, the slave nodes b, c, d are controlled to transmit control information to the slave nodes e, f, g, h, i, j, k, respectively, the communication ping values between the slave node b and the slave nodes e, f, g, h, i, j, k are determined to be 10, 20, 30, respectively, the communication ping values between the slave node c and the slave nodes e, f, g, h, i, j, k are determined to be 20, 10, 40, respectively, the communication ping values between the slave node d and the slave nodes e, f, g, h, i, j, k are determined to be 50, 10, respectively, so that the slave nodes e, f can be set as the next-level slave nodes of the slave node b, the slave nodes g, h, i can be set as the next-level slave nodes of the slave node b, the slave nodes j, k can be set as the next-level slave nodes j, k are set as the next-level slave nodes of the slave nodes d, the resulting final node synchronization path is shown in fig. 6, i.e., the final node synchronization path is a data structure in the form of a binary tree.

It should be noted that, although the embodiment of the present invention only provides a specific implementation manner of two control information, that is, the ping value confirmation information and the same group of data information are copied to other slave nodes, and a specific implementation manner of a time length that the node feeds back according to the control information is a time length that the slave nodes feed back according to the control information, that is, a time length that is required for completing the copying of the data information and the ping value. However, it is understood by those skilled in the art that the type of the control information and the type of the time length for the feedback from the node according to the control information may be modified or replaced by those skilled in the art without departing from the technical principle of the present invention, and the modified or replaced scheme still falls within the protection scope of the present invention.

Step S102: and the control main node responds to the received mirror image file, determines the next-level slave node of the main node according to the node synchronization path and sends the mirror image file to the next-level slave node.

Continuing with the example in step S101, when the mirror image file needs to be synchronized, the master node a may be controlled to determine, according to the node synchronization path, that the slave nodes at the next level of the master node a are b, c, and d in response to the received mirror image file, and send the mirror image file to the slave nodes b, c, and d.

Step S103: and for each slave node, after receiving the image file, the control slave node determines the next-level slave node of the slave node according to the node synchronization path to which the slave node belongs and sends the image file to the next-level slave node.

With reference to the example in step S101, after receiving the image file, the control slave nodes b, c, and d determine that the slave nodes b and f are the next slave nodes according to the node synchronization path, so the control slave node b sends the image file to the slave nodes e and f, and determines that the slave nodes c and g are the next slave nodes g, h, and i, so the control slave node c sends the image file to the slave nodes g, h, and i, and determines that the slave node d and j and k are the next slave nodes, so the control slave node d sends the image file to the slave nodes j and k. For the example in step S101, after the transmission is completed, the image file may be synchronized to all nodes in the distributed cluster system.

In one embodiment of this embodiment, the master node is provided with a mirrored master repository and each slave node is provided with a mirrored slave repository.

The mirror master repository and the mirror slave repository are each configured to hold mirror files.

After the mirror image file is synchronized to the master node or the slave node, the mirror image file can be saved by using a mirror image master warehouse or a mirror image slave warehouse.

In one embodiment of the present embodiment, the master node and each slave node are provided with a docker engine capable of running an image file.

The Docker engine is used for creating a container for running the image file, and after the Docker engine is arranged, the master node and each slave node can run the image file.

In an implementation manner of this embodiment, different nodes in the distributed cluster System communicate with each other through respective Domain Names (DNS).

By configuring different domain names, each node in the distributed cluster system can communicate with other nodes, send image files and the like.

In one embodiment of this embodiment, the master node is further provided with a database.

The database is configured to record node information and node synchronization paths of all nodes, wherein the node information at least comprises domain names of the nodes.

The database may be configured to record all information in the entire distributed cluster system, such as a name of each node, domain name information of each node, a node synchronization path, and the like, and only the master node may communicate with the database, and a communication manner between the master node and the database is not limited to domain name communication, and it should be understood by those skilled in the art that a communication manner may be freely selected according to actual needs.

In addition, if each slave node needs to control the distributed cluster system, it needs to send a control request to the master node, and the cluster can be controlled after obtaining a control permission instruction fed back by the master node, where the control request may include an object requesting to control, for example, a request to control a certain node, and may also include content requesting to control, for example, a request to query an image file in a certain node, and the like.

In an example of an application scenario of the present invention, a company has a plurality of office locations and is engaged in development of an application, so that it is necessary to frequently synchronize image files of the developed application to different office locations, a distributed cluster system may be configured through steps S401 to S404 as shown in fig. 4, and then the image file synchronization method according to an embodiment of the present invention is used to synchronize the image file to all nodes in the distributed cluster system:

step S401: a master node is set.

Specifically, one node in the distributed cluster system is selected as a master node master, a mirror image warehouse (docker _ ware house) is arranged on the master node and is used as a mirror image master warehouse, a docker engine capable of running mirror image files is arranged on the master node, a database is arranged on the master node, and then the master node is started. Wherein the database is configured to store node information for each node in the distributed cluster system.

Step S402: the slave node is set.

Specifically, taking other nodes except the master node in the distributed cluster system as slave nodes, a mirror image warehouse (docker _ ware house) may be respectively set on each slave node as a mirror image slave warehouse, and then a docker engine capable of running a mirror image file is set on the slave node.

Step S403: and starting the slave node and controlling the slave node to communicate with the master node.

In particular, the slave node may be registered with the master node by a domain name to enable the slave node to communicate with the master node.

Step S404: a node synchronization path is determined.

Specifically, the method described in steps S1 to S4 in the foregoing method embodiment may be adopted to obtain the communication efficiency between all nodes (including the master node and the slave node), and then determine the node synchronization path according to the communication efficiency, assuming that the determined node synchronization path is as shown in fig. 5.

After determining the node synchronization path, the distributed cluster system is completed, assuming as shown in fig. 7.

After a new application program is developed on a certain day, the developed application program can be made into an image file, whether the image file normally runs is tested, the image file is sent to a master node master after the image file can normally run is determined and stored to an image master warehouse corresponding to the master node master, the master node master is controlled to determine that slave nodes at the next level of the master node master are slave1, slave2 and slave5 according to a node synchronization path after receiving the image file, and the image file is sent to slave nodes of slave1, slave2 and slave5 and stored to image slave nodes corresponding to the slave nodes of the warehouses.

Aiming at the slave1 and the slave2, after receiving the image files, the slave1 and the slave2 are controlled to determine that the next-level slave node of the slave1 is the slave4 and the next-level slave node corresponding to the slave2 is the slave3 according to the node synchronization paths to which the slave1 and the slave2 belong, and the image files are respectively sent to the slave4 and the slave3 and are respectively stored in the slave warehouses corresponding to the slave4 and the slave warehouses corresponding to the slave 3. And finally, synchronizing the mirror image file to all the main nodes and the slave nodes, namely synchronizing the mirror image file to the whole distributed cluster system.

Based on the above steps S101 to S103, when the mirror image file needs to be synchronized, the master node may be controlled to send the mirror image file to the next-stage slave node corresponding to the master node according to the node synchronization path, and then, for each slave node, the slave node is controlled to determine the next-stage slave node according to the node synchronization path to which the slave node determines after receiving the mirror image file, and then the slave node is controlled to send the mirror image file to the next-stage slave node, thereby finally synchronizing the mirror image file to all nodes.

It should be noted that, although the foregoing embodiments describe each step in a specific sequence, those skilled in the art will understand that, in order to achieve the effect of the present invention, different steps do not necessarily need to be executed in such a sequence, and they may be executed simultaneously (in parallel) or in other sequences, and these changes are all within the protection scope of the present invention.

Furthermore, the invention also provides a mirror image file synchronizing device.

Referring to fig. 3, fig. 3 is a main structural block diagram of an image file synchronization apparatus according to an embodiment of the present invention. As shown in fig. 3, the image file synchronization apparatus in the embodiment of the present invention mainly includes a synchronization path determination module 31, a first image synchronization module 32, and a second image synchronization module 33. In some embodiments, one or more of the synchronization path determination module 31, the first mirror synchronization module 32, and the second mirror synchronization module 33 may be combined together into one module. In some embodiments, the synchronization path determining module 31 may be configured to determine a plurality of node synchronization paths according to communication efficiency between different nodes, where a first node in all the node synchronization paths is the same node, the first node is a master node of each node synchronization path, and other nodes are slave nodes. The first mirror synchronization module 32 may be configured to control the master node to determine a next-level slave node of the master node according to the node synchronization path and to transmit the mirror file to the next-level slave node in response to the received mirror file. The second mirror synchronization module 33 may be configured to control the slave node to determine a next-level slave node of the slave node according to a node synchronization path to which the slave node belongs and to transmit the mirror file to the next-level slave node after receiving the mirror file for each slave node. In one embodiment, the description of the specific implementation function may refer to the description of step S101 to step S103.

In one embodiment, the synchronization path determination module is further configured to:

step S1: the control master node sends control information to all slave nodes, the time length for each slave node to feed back information according to the control information is obtained, the communication efficiency between the master node and each slave node is determined according to the time length, a plurality of slave nodes with the highest communication efficiency are selected and used in parallel as next-level slave nodes of the master node, and a plurality of initial node synchronization paths are constructed according to the master node and each next-level slave node.

Step S2: for each initial node synchronization path, updating the initial node synchronization path by:

and taking the slave nodes which are not selected from all the slave nodes as target slave nodes.

The method comprises the steps of controlling the last-stage slave node in an initial node synchronization path to send control information to target slave nodes, obtaining the time length of each target slave node for information feedback according to the control information, determining the communication efficiency of the last-stage slave node and each target slave node according to the time length, and selecting a plurality of target slave nodes with the highest communication efficiency to be arranged in parallel to serve as the next-stage slave nodes of the last-stage slave nodes.

And updating the initial node synchronization path according to the next-stage slave node, and taking the next-stage slave node as the updated last-stage slave node.

Step S3: and step S2 is repeatedly executed until all the slave nodes are selected, and the initial node synchronization path is updated to obtain the final node synchronization path.

In one embodiment, when the control information is ping value confirmation information, the time period for the slave node to feed back according to the control information is a ping value.

When the control information is the time for copying the same group of data information to other slave nodes, the time for the slave nodes to feed back according to the control information is the time required for finishing copying the data information.

In one embodiment, the master node is provided with a mirrored master repository and each slave node is provided with a mirrored slave repository.

The mirror master repository and the mirror slave repository are each configured to hold mirror files.

In one embodiment, the master node and each slave node are provided with a docker engine capable of running an image file.

In one embodiment, different nodes in the distributed cluster system communicate with each other via respective domain names.

In one embodiment, the master node is also provided with a database.

The database is configured to record node information and node synchronization paths of all nodes, wherein the node information at least comprises domain names of the nodes.

The technical principles, the solved technical problems and the generated technical effects of the mirror image file synchronization apparatus for executing the embodiment of the mirror image file synchronization method shown in fig. 1 are similar, and it can be clearly understood by those skilled in the art that for convenience and conciseness of description, the specific working process and related description of the mirror image file synchronization apparatus may refer to the contents described in the embodiment of the mirror image file synchronization method, and are not repeated herein.

It will be understood by those skilled in the art that all or part of the flow of the method according to the above-described embodiment may be implemented by a computer program, which may be stored in a computer-readable storage medium and used to implement the steps of the above-described embodiments of the method when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying said computer program code, media, usb disk, removable hard disk, magnetic diskette, optical disk, computer memory, read-only memory, random access memory, electrical carrier wave signals, telecommunication signals, software distribution media, etc. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.

Furthermore, the invention also provides a control device. In an embodiment of the control device according to the present invention, the control device comprises a processor and a storage device, the storage device may be configured to store a program for executing the image file synchronization method of the above-mentioned method embodiment, and the processor may be configured to execute a program in the storage device, the program including but not limited to a program for executing the image file synchronization method of the above-mentioned method embodiment. For convenience of explanation, only the parts related to the embodiments of the present invention are shown, and details of the specific techniques are not disclosed. The control device may be a control device apparatus formed including various electronic apparatuses.

Further, the invention also provides a computer readable storage medium. In one computer-readable storage medium embodiment according to the present invention, a computer-readable storage medium may be configured to store a program that executes the image file synchronization method of the above-described method embodiment, and the program may be loaded and executed by a processor to implement the above-described image file synchronization method. For convenience of explanation, only the parts related to the embodiments of the present invention are shown, and details of the specific techniques are not disclosed. The computer readable storage medium may be a storage device formed by including various electronic devices, and optionally, the computer readable storage medium is a non-transitory computer readable storage medium in the embodiment of the present invention.

Further, it should be understood that, since the configuration of each module is only for explaining the functional units of the apparatus of the present invention, the corresponding physical devices of the modules may be the processor itself, or a part of software, a part of hardware, or a part of a combination of software and hardware in the processor. Thus, the number of individual modules in the figures is merely illustrative.

Those skilled in the art will appreciate that the various modules in the apparatus may be adaptively split or combined. Such splitting or combining of specific modules does not cause the technical solutions to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or combining will fall within the protection scope of the present invention.

So far, the technical solutions of the present invention have been described in connection with the preferred embodiments shown in the drawings, but it is easily understood by those skilled in the art that the scope of the present invention is obviously not limited to these specific embodiments. Equivalent changes or substitutions of related technical features can be made by those skilled in the art without departing from the principle of the invention, and the technical scheme after the changes or substitutions can fall into the protection scope of the invention.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:BIM数据管理的方法和装置、电子设备、计算机可读介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!