CN115941704A - Mirror image synchronization method and device, electronic equipment and storage medium - Google Patents

Mirror image synchronization method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115941704A
CN115941704A CN202211564998.9A CN202211564998A CN115941704A CN 115941704 A CN115941704 A CN 115941704A CN 202211564998 A CN202211564998 A CN 202211564998A CN 115941704 A CN115941704 A CN 115941704A
Authority
CN
China
Prior art keywords
mirror image
warehouse
target
mirror
synchronization
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211564998.9A
Other languages
Chinese (zh)
Inventor
吴亚军
刘大伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hillstone Networks Co Ltd
Original Assignee
Hillstone Networks Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hillstone Networks Co Ltd filed Critical Hillstone Networks Co Ltd
Priority to CN202211564998.9A priority Critical patent/CN115941704A/en
Publication of CN115941704A publication Critical patent/CN115941704A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a mirror image synchronization method and device, electronic equipment and a storage medium. Wherein, the method comprises the following steps: receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized; and responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to the local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse. The invention solves the technical problem that the mirror synchronization can not be realized for the same-name mirror warehouse in the related technology.

Description

Mirror image synchronization method and device, electronic equipment and storage medium
Technical Field
The invention relates to the field of mirror image storage, in particular to a mirror image synchronization method and device, electronic equipment and a storage medium.
Background
The synchronization of the mirror image warehouse is a relatively common requirement in the micro service testing and deploying process, a relatively stable mirror image can be generated in the research and development testing stage, the mirror image exists in the mirror image warehouse of the research and development testing environment, the mirror image also needs to exist in the research and development testing environment when the production environment is deployed, the synchronization of the mirror image warehouse is needed at the moment, in addition, a plurality of public network IPs exist under the domain name of one mirror image warehouse, the public network IPs are mutually independent, and the mirror image warehouse need to be mutually synchronized at the moment.
In the related art, the synchronization of the mirror images is based on mirror image warehouses with different names, the mirror images are pushed to the mirror image warehouses with other names by monitoring the source mirror image warehouse, and when the mirror image warehouses with the same names exist, the mirror image synchronization cannot be realized.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a mirror image synchronization method and device, electronic equipment and a storage medium, which at least solve the technical problem that mirror image synchronization cannot be realized for a mirror image warehouse with the same name in the related technology.
According to an aspect of the embodiments of the present invention, there is provided a mirror synchronization method, applied to a transit server that establishes a connection relationship with each mirror repository in advance, including: receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized; and responding to the mirror image synchronization request, pulling a target mirror image in a source warehouse to a local cache space, pushing the target mirror image from the local cache space to a target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
Optionally, before receiving the mirror synchronization request, the method further includes: acquiring a task execution list, wherein the task execution list comprises the number of tasks to be executed; entering a mirror image synchronization process under the condition that the task quantity of the tasks to be executed contained in the task execution list is a first parameter; and under the condition that the number of the tasks to be executed in the task execution list is greater than or equal to the first parameter, ending the mirror image synchronization process and returning an error report.
Optionally, before receiving the mirror synchronization request, the method further includes: controlling the transfer server to send a link request to each mirror image warehouse; and after the mirror image warehouse responds to the link request, acquiring the read-write access authority of the mirror image warehouse.
Optionally, the step of receiving a mirror synchronization request includes: opening an external network service interface of the transfer server; monitoring network messages by adopting the external network service interface; and under the condition that the message type of the network message is a mirror image synchronous message, analyzing the mirror image synchronous message to obtain the mirror image synchronous request.
Optionally, the mirror synchronization request further carries: the IP address and the open port of the transit server.
Optionally, the step of pulling the target image in the source repository to the local cache space in response to the image synchronization request includes: modifying a Domain Name Server (DNS) mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the source warehouse indicated by the source warehouse identifier; and pulling the target mirror image indicated by the mirror image identification in the source warehouse to a local cache space based on the IP address of the source warehouse.
Optionally, the step of pushing the target image from the local cache space to the target repository includes: modifying a Domain Name System (DNS) mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the target warehouse indicated by the target warehouse identification; and pushing the target mirror image from the local cache space to the target warehouse based on the IP address of the target warehouse.
According to another aspect of the embodiments of the present invention, there is also provided a mirror synchronization apparatus, including: a receiving unit, configured to receive a mirror image synchronization request, where the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized; and the response unit is used for responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to a local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
Optionally, the mirror image synchronization apparatus further includes: the system comprises a first acquisition module, a second acquisition module and a task execution module, wherein the first acquisition module is used for acquiring a task execution list, and the task execution list comprises the task number of tasks to be executed; the first entering module is used for entering a mirror image synchronization process under the condition that the task quantity of the tasks to be executed contained in the task execution list is a first parameter; and the first ending module is used for ending the mirror image synchronization process and returning an error report under the condition that the task quantity of the tasks to be executed contained in the task execution list is greater than or equal to the first parameter.
Optionally, the mirror image synchronization apparatus further includes: the first control module is used for controlling the transfer server to send a link request to each mirror image warehouse; and the second acquisition module is used for acquiring the read-write access authority of the mirror image warehouse after the mirror image warehouse responds to the link request.
Optionally, the receiving unit includes: the first starting module is used for starting an external network service interface of the transit server; the first monitoring module is used for monitoring the network message by adopting the external network service interface; and the first analysis module is used for analyzing the mirror image synchronous message to obtain the mirror image synchronous request under the condition that the message type of the network message is the mirror image synchronous message.
Optionally, the mirror synchronization request further carries: the IP address and the open port of the transit server.
Optionally, the response unit includes: the first modification module is used for modifying the domain name DNS mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the source warehouse indicated by the source warehouse identifier; and the first pulling module is used for pulling the target mirror image indicated by the mirror image identifier in the source warehouse to a local cache space based on the IP address of the source warehouse.
Optionally, the response unit further includes: a second modification module, configured to modify a domain name DNS mapped by the IP address of the transit server, so as to point the address of the mirror memory to the IP address of the target repository indicated by the target repository identifier; and the first pushing module is used for pushing the target mirror image to the target warehouse from the local cache space based on the IP address of the target warehouse.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform any of the mirror synchronization methods via execution of the executable instructions.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, which includes a stored computer program, wherein when the computer program runs, the apparatus where the computer-readable storage medium is located is controlled to execute any one of the image synchronization methods.
In the present disclosure, the following steps are employed: receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identifier, a target warehouse identifier and a mirror image identifier of a target mirror image to be synchronized; and responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to the local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse. According to the method and the device, the pulled homonymous mirror image is stored in any local cache space based on the mirror image synchronization request, and the mirror image is pushed to the target warehouse, so that the aim of mirror image synchronization of the homonymous warehouse is fulfilled, and the technical problem that mirror image synchronization cannot be achieved for the homonymous mirror warehouse in the related technology is solved.
In the disclosure, in combination with a DNS domain name system, a designated docker mirror can be synchronized from one docker mirror repository to another docker mirror repository, and names or identification information of the two mirror repositories may be consistent.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention and do not constitute a limitation of the invention. In the drawings:
FIG. 1 is a flow diagram of an alternative mirror synchronization method according to an embodiment of the present invention;
FIG. 2 is an alternative module relationship diagram according to an embodiment of the invention;
FIG. 3 is a flow diagram of an alternative transit service process according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an alternative mirror synchronization apparatus according to an embodiment of the present invention;
fig. 5 is a block diagram of a hardware structure of an electronic device (or mobile device) of a mirror synchronization method according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
To facilitate understanding of the invention by those skilled in the art, the following explanation is made for some terms or nouns referred to in the embodiments of the invention:
mirror image, a file storage form, where data on one disk has an identical copy on another disk, i.e. a mirror image.
The Domain Name System, DNS for short, serves as a distributed database on the internet in which Domain names and IP addresses are mapped to each other.
Docker, an open source application container engine, developers can package applications and dependency packages into a portable image and then release onto the operating system's machines.
The docker image, a special file system, provides files of programs, libraries, resources, configuration, etc. required by the container runtime, and also contains configuration parameters (e.g., anonymous volumes, environment variables, users, etc.) prepared for the runtime.
A docker mirror image warehouse, a warehouse for docker mirror image storage.
It should be noted that relevant information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for presentation, analyzed data, etc.) referred to in the present disclosure are information and data that are authorized by the user or sufficiently authorized by various parties. For example, an interface is provided between the system and the relevant user or organization, before obtaining the relevant information, an obtaining request needs to be sent to the user or organization through the interface, and after receiving the consent information fed back by the user or organization, the relevant information is obtained.
The invention can be applied to various file storage systems (such as a distributed file storage system) and mirror image synchronization systems/products/devices, and realizes mirror image synchronization of the same-name mirror image warehouse by pulling and pushing mirror images in a domain name switching mode.
The present invention will be described in detail with reference to examples.
Example one
In accordance with an embodiment of the present invention, there is provided a method embodiment of mirror synchronization, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
FIG. 1 is a flowchart of an alternative mirror synchronization method according to an embodiment of the present invention, as shown in FIG. 1, the method includes the following steps:
step S102, receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized;
and step S104, responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to a local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
Through the steps, a mirror image synchronization request is received, wherein the mirror image synchronization request at least carries: and the source warehouse identification, the target warehouse identification and the mirror image identification of the target mirror image to be synchronized, then the mirror image synchronization request is responded, the target mirror image in the source warehouse is pulled to the local cache space, the target mirror image is pushed to the target warehouse from the local cache space, and the mirror image synchronization operation is completed, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse. In this embodiment, based on the mirror synchronization request, the mirror is pulled and pushed through the local cache space, so that the purpose of mirror synchronization of the same-name warehouse is achieved, and the technical problem that mirror synchronization cannot be achieved for the same-name mirror warehouse in the related art is solved.
The following describes embodiments of the present invention in detail with reference to the above-mentioned steps.
It should be noted that, in this embodiment, the mirror name format is set as dock _ REGISTRY/repo/name: tag, where dock _ REGISTRY is a uniform DOCKER registration address of an enterprise, a company, an organization, etc., and is generally a Domain Name (DNS); repo is a mirror path, which is used to manage a certain type of mirror; name: specific name of a certain mirror image, tag: a mirror image of a particular label. By a mirror repository of the same name, it is meant that the dock _ registers of both mirror repositories are identical.
Fig. 2 is an optional module relationship diagram according to an embodiment of the present invention, as shown in fig. 2, a transit service may access a warehouse a, a warehouse B, and a warehouse C, where the warehouse a, the warehouse B, and the warehouse C are mirror image warehouses with the same name, and the warehouses such as warehouse A, B, C may be mirror images synchronized with each other, in this embodiment, when performing mirror image synchronization, the transit service first switches a DNS so that an IP address of dock _ registration entry points to the warehouse a, pulls the mirror image of the warehouse a, then switches the DNS so that the IP address of dock _ registration points to the warehouse B, and finally, the transit service pushes the mirror image to the warehouse B.
In the embodiment of the present invention, before performing mirror synchronization, it is required to ensure that no task is currently synchronized, including: acquiring a task execution list, wherein the task execution list comprises the number of tasks to be executed; entering a mirror image synchronization process under the condition that the task quantity of the tasks to be executed contained in the task execution list is a first parameter; and under the condition that the number of the tasks to be executed in the task execution list is greater than or equal to the first parameter, ending the mirror image synchronization process and returning an error report.
It should be noted that, under the condition that no task is currently synchronized, mirror synchronization may be performed, if a task is currently synchronized and the number of tasks to be synchronized is greater than or equal to the threshold (corresponding to the first parameter), an error is returned, the process is ended, and if a task is currently synchronized and does not reach the threshold, the process continues to try after waiting for a specified time (e.g., 1 second, 1 minute), where the first parameter is the maximum number of tasks to be processed set according to the device capacity and the network operating speed.
In this embodiment of the present invention, before receiving the mirror synchronization request, the method further includes: controlling a transfer server to send a link request to each mirror image warehouse; and after the mirror image warehouse responds to the link request, acquiring the read-write access authority of the mirror image warehouse.
It should be noted that, the transit server in this embodiment provides a network service to the outside, such as a web service, and includes an outward interface, the transit server needs to have read-write access permissions of each mirror warehouse to obtain the schematic description of the warehouse a and the warehouse B, and the corresponding access account number is:
Figure BDA0003986243970000061
Figure BDA0003986243970000071
wherein, repo indicates mirror image warehouse, username represents account name, password is password, and IP refers to virtual IP address.
After the transfer server acquires the access authority of each mirror image warehouse, mirror images can be pulled and pushed between the local and each warehouse, and therefore mirror image synchronization of the warehouses with the same names is achieved.
Step S102, receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification, and a mirror identification of a target mirror to be synchronized.
In this embodiment of the present invention, step S102 may include: opening an external network service interface of the transit server; monitoring network messages by adopting an external network service interface; and under the condition that the message type of the network message is a mirror image synchronous message, analyzing the mirror image synchronous message to obtain a mirror image synchronous request.
The mirror synchronization request also carries: the IP address and the open port of the transit server.
It should be noted that the mirror synchronization request parameters are:
{
Image:image_name,
From:reponame1,
To:reponame2
};
the Image parameter is the name of the mirror Image, IP and port are the IP and open port of the transfer server, the parameter carried after From is the name of the source mirror Image warehouse, and the parameter carried after To is the name of the target mirror Image warehouse.
And step S104, responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to a local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
In this embodiment of the present invention, step S104 may include: modifying a Domain Name System (DNS) mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the source warehouse indicated by the source warehouse identification; and pulling the target mirror image indicated by the mirror image identifier in the source warehouse to a local cache space based on the IP address of the source warehouse.
In the embodiment of the present invention, the step of pushing the target mirror image from the local cache space to the target warehouse includes: modifying a domain name DNS mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the target warehouse indicated by the target warehouse identifier; and pushing the target mirror image to the target warehouse from the local cache space based on the IP address of the target warehouse.
It should be noted that the transit service modifies the local DNS to make the IP address accurately point to the source repository, and pulls the mirror image to the local, and then uses the same manner to make the IP address accurately point to the target repository, so that the source repository can be quickly and accurately synchronized with the target repository having the same name as the source repository.
Through the embodiment, the transfer service is connected with the warehouses, the mirror image is pulled from the source warehouse and pushed to the target warehouse by switching a Domain Name Server (DNS), only one synchronous task is allowed to be processed through a synchronous lock mechanism, and normal operation of the task is guaranteed.
The invention is illustrated below with reference to a more specific example.
In this embodiment, a DOCKER mirror warehouse is schematically illustrated, and a naming format of the DOCKER mirror is DOCKER _ REGISTRY/repo/name: tag, where the DOCKER _ REGISTRY is a uniform DOCKER registration address of an enterprise and is generally a domain name; repo is a mirror path, which is used to manage a certain type of mirror; name: specific name of a certain mirror image, tag: a mirror image of a particular label.
As shown in fig. 2, the relay service is connected to warehouse a, warehouse B, warehouse C, etc., and can access each warehouse, warehouse a, warehouse B, warehouse C are homonymous warehouses, and have the same DOCKER _ REGISTRY, warehouse A, B, C, etc., and can synchronize DOCKER images with each other, now taking synchronous DOCKER images from warehouse a to warehouse B as an example, the relay service switches DNS first, so that the IP address of DOCKER _ REGISTRY points to warehouse a, the relay service pulls the DOCKER image of warehouse a, then switches DNS, so that the IP address of DOCKER _ REGISTRY points to warehouse B, and finally the relay service pushes the DOCKER image to warehouse B.
Fig. 3 is a flowchart of an alternative transit service processing flow according to an embodiment of the present invention, and as shown in fig. 3, the transit service processing flow includes:
the method comprises the following steps: starting;
the transfer service needs to have read-write access rights of each warehouse, taking warehouse a and warehouse B as examples, and the account numbers are respectively:
Figure BDA0003986243970000091
wherein, repo indicates the mirror image warehouse, username represents the account name, password is password, IP refers to the virtual IP address.
The transfer service provides web service externally, when each warehouse needs to perform mirror image synchronization, a mirror image synchronization request is sent to the transfer service, and the request parameters are as follows:
{
Image:image_name,
From:reponame1,
To:reponame2
},
the Image parameter is the name of the docker mirror Image, the IP and the port are the IP and the exposed port of the transfer server, the parameter carried after From is the name of the source docker warehouse, and the parameter carried after To is the name of the target docker warehouse.
Step two: judging whether a synchronous task exists at present, if so, executing a third step, and if not, executing a sixth step;
before performing mirror synchronization, it is necessary to ensure that no task is currently in synchronization.
Step three: and judging whether the number of the tasks to be processed is greater than NUM, wherein NUM is the maximum number of the tasks to be processed and is set according to the equipment capacity and the network transmission speed, if not, executing a fourth step, and if not, executing a fifth step.
If the current synchronous task exists and the number of the tasks to be synchronized is larger than the threshold value, returning error information and ending the process.
Step four: waiting for a specified time (e.g., 1 second, one minute), and then executing step two;
and if the current task is synchronous and does not reach the threshold value, continuing to try after waiting for a specified time.
Step five: an error is returned.
Step two to step five form a mechanism of synchronous lock, which can ensure that only one synchronous task is currently carried out, and avoid the confusion of the direction of DOCKER _ REGISTRY caused by modifying DNS.
Step six: modifying the DNS so that DOCKER _ REGISTRY points to the IP address of the source warehouse;
step seven: pulling a docker mirror image from a source warehouse to the local;
step eight: modifying the DNS so that the DOCKER _ REGISTRY points to the IP address of the target warehouse;
step nine: pushing the docker mirror image to a target warehouse;
when no task is in synchronization currently, a DOCKER mirror synchronization process can be entered, the DNS is modified firstly, so that the DOCKER _ REGISTRY points to the IP address of the source warehouse, the DOCKER mirror is pulled from the source warehouse to the local, then the DNS is continuously modified, so that the DOCKER _ REGISTRY points to the IP address of the target warehouse, and finally the DOCKER mirror is pushed to the target warehouse.
Step ten: and (6) ending.
In the embodiment, the local Domain Name System (DNS) is modified to enable the IP address to accurately point to the source warehouse, the mirror image to be synchronized is pulled to the local cache space, then the same mode is used to enable the IP address to accurately point to the target warehouse, and the mirror image to be synchronized in the local cache space is pushed to the target warehouse, so that mirror image synchronization between the warehouses with the same name is realized, meanwhile, a synchronization lock mechanism is introduced, only one synchronization task is allowed to be processed at the current moment, and normal operation of the task is guaranteed.
The invention is described below in connection with an alternative embodiment.
Example two
The present embodiment provides a mirror image synchronization apparatus, which includes a plurality of implementation units, each implementation unit corresponding to each implementation step in the first embodiment.
FIG. 4 is a schematic diagram of an alternative mirror synchronizer according to an embodiment of the present invention, as shown in FIG. 4, the mirror synchronizer includes: a receiving unit 42, a response unit 44, wherein,
a receiving unit 42, configured to receive a mirror image synchronization request, where the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized;
and the response unit 44 is configured to respond to the mirror image synchronization request, pull the target mirror image in the source repository to the local cache space, and push the target mirror image from the local cache space to the target repository, so as to complete mirror image synchronization operation, where a repository name of the source repository is the same as a repository name of the target repository.
The mirror image synchronization apparatus receives a mirror image synchronization request through the receiving unit 42, where the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized; and responding to the mirror image synchronization request through the response unit 44, pulling the target mirror image in the source warehouse to the local cache space, and pushing the target mirror image from the local cache space to the target warehouse to complete mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse. In this embodiment, based on the mirror image synchronization request, the mirror image is pulled and pushed through the local cache space, so that the purpose of mirror image synchronization of the same-name warehouse is achieved, and the technical problem that mirror image synchronization cannot be achieved for the same-name mirror image warehouse in the related art is solved.
It should be noted that, the mirror name format is dock _ REGISTRY/repo/name: tag, where dock _ REGISTRY is a uniform DOCKER REGISTRY address of enterprises, companies, organizations, etc., and is generally a Domain Name (DNS); repo is a mirror path, which is used to manage a certain type of mirror; name: specific name of a certain mirror image, tag: a mirror image specific label. The mirror warehouse with the same name means that the DOCKER _ registration of the two mirror warehouses are the same.
In the embodiment, when performing mirror synchronization, schematically illustrated by the synchronous mirror of the warehouse a and the warehouse B, the transit service switches the DNS first, so that the IP address of the dock _ registration points to the warehouse a, the transit service pulls the mirror of the warehouse a, and then switches the DNS again, so that the IP address of the dock _ registration points to the warehouse B, and finally the transit service pushes the mirror to the warehouse B.
Optionally, the mirror synchronization apparatus further includes: the system comprises a first acquisition module, a second acquisition module and a task execution module, wherein the first acquisition module is used for acquiring a task execution list, and the task execution list comprises the task number of tasks to be executed; the first entering module is used for entering a mirror image synchronization process under the condition that the task quantity of the tasks to be executed contained in the task execution list is a first parameter; and the first ending module is used for ending the mirror image synchronization process and returning an error report under the condition that the task quantity of the tasks to be executed contained in the task execution list is greater than or equal to the first parameter.
It should be noted that, under the condition that no task is currently synchronized, mirror synchronization may be performed, if a task is currently synchronized and the number of tasks to be synchronized is greater than or equal to the threshold (corresponding to the first parameter), an error is returned, the process is ended, and if a task is currently synchronized and does not reach the threshold, the process continues to try after waiting for a certain time, where the first parameter is the maximum number of tasks to be processed, which is set according to the device capacity and the network operating speed.
Optionally, the mirror synchronization apparatus further includes: the first control module is used for controlling the transfer server to send a link request to each mirror image warehouse; and the second acquisition module is used for acquiring the read-write access authority of the mirror image warehouse after the mirror image warehouse responds to the link request.
It should be noted that the transfer service provides a web service to the outside, and includes an interface, the transfer service needs to have read-write access rights of each mirror warehouse to obtain the schematic description of the warehouse a and the warehouse B, and the corresponding access account number is:
Figure BDA0003986243970000121
wherein, repo indicates mirror image warehouse, username represents account name, password is password, and IP refers to virtual IP address.
After the transfer service acquires the access authority of each mirror image warehouse, mirror images can be pulled and pushed between the local and each warehouse, and therefore mirror image synchronization of the warehouses with the same names is achieved.
Optionally, the receiving unit includes: the first starting module is used for starting an external network service interface of the transit server; the first monitoring module is used for monitoring the network message by adopting an external network service interface; and the first analysis module is used for analyzing the mirror image synchronous message to obtain a mirror image synchronous request under the condition that the message type of the network message is the mirror image synchronous message.
Optionally, the mirror synchronization request further carries: the IP address and the open port of the transit server.
It should be noted that the mirror synchronization request parameters are:
{
Image:image_name,
From:reponame1,
To:reponame2
};
the Image parameter is the name of the mirror Image, IP and port are the IP and exposed port of the transfer server, the parameter carried after From is the name of the source mirror Image warehouse, and the parameter carried after To is the name of the target mirror Image warehouse.
Optionally, the response unit comprises: the first modification module is used for modifying the Domain Name System (DNS) mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the source warehouse indicated by the source warehouse identifier; and the first pulling module is used for pulling the target mirror image indicated by the mirror image identifier in the source warehouse to the local cache space based on the IP address of the source warehouse.
Optionally, the response unit further comprises: the second modification module is used for modifying the domain name DNS mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the target warehouse indicated by the target warehouse identifier; and the first pushing module is used for pushing the target mirror image to the target warehouse from the local cache space based on the IP address of the target warehouse.
It should be noted that the transit service modifies the local DNS to make the IP address accurately point to the source repository, and pulls the mirror image to the local, and then uses the same manner to make the IP address accurately point to the target repository, so that the source repository can be quickly and accurately synchronized with the target repository having the same name as the source repository.
The mirror image synchronization apparatus may further include a processor and a memory, the receiving unit 42, the responding unit 44, and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor comprises a kernel, and the kernel calls a corresponding program unit from the memory. The kernel can be set to one or more, and the mirror image between the same-name warehouses is synchronized by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including: a processor; and a memory for storing executable instructions for the processor; wherein the processor is configured to perform any of the mirror synchronization methods via execution of executable instructions.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, which includes a stored computer program, wherein when the computer program runs, the apparatus in which the computer-readable storage medium is located is controlled to execute any one of the image synchronization methods.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device: receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized; and responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to the local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
Fig. 5 is a block diagram of a hardware structure of an electronic device (or mobile device) of a mirror synchronization method according to an embodiment of the present invention. As shown in fig. 5, the electronic device may include one or more processors 502 (shown with 502a, 502b, … …,502 n) 502 (the processors 502 may include, but are not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 504 for storing data. In addition, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a keyboard, a power supply, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 5 is only an illustration and is not intended to limit the structure of the electronic device. For example, the electronic device may also include more or fewer components than shown in FIG. 5, or have a different configuration than shown in FIG. 5.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A mirror image synchronization method is applied to a transfer server which establishes a connection relationship with each mirror image warehouse in advance, and comprises the following steps:
receiving a mirror image synchronization request, wherein the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized;
and responding to the mirror image synchronization request, pulling a target mirror image in a source warehouse to a local cache space, pushing the target mirror image from the local cache space to a target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
2. The mirror synchronization method of claim 1, further comprising, prior to receiving the mirror synchronization request:
acquiring a task execution list, wherein the task execution list comprises the number of tasks to be executed;
entering a mirror image synchronization process under the condition that the task quantity of the tasks to be executed contained in the task execution list is a first parameter;
and under the condition that the number of the tasks to be executed in the task execution list is greater than or equal to the first parameter, ending the mirror image synchronization process and returning an error report.
3. The mirror synchronization method of claim 1, further comprising, prior to receiving the mirror synchronization request:
controlling the transfer server to send a link request to each mirror image warehouse;
and after the mirror image warehouse responds to the link request, acquiring the read-write access authority of the mirror image warehouse.
4. The mirror synchronization method of claim 1, wherein the step of receiving a mirror synchronization request comprises:
opening an external network service interface of the transit server;
monitoring network messages by adopting the external network service interface;
and under the condition that the message type of the network message is a mirror image synchronous message, analyzing the mirror image synchronous message to obtain the mirror image synchronous request.
5. The mirror synchronization method according to any one of claims 1 to 4, wherein the mirror synchronization request further carries: the IP address and the open port of the transit server.
6. The mirror synchronization method according to claim 5, wherein the step of pulling the target mirror in the source repository to the local cache space in response to the mirror synchronization request comprises:
modifying a Domain Name System (DNS) mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the source warehouse indicated by the source warehouse identification;
and pulling the target mirror image indicated by the mirror image identification in the source warehouse to a local cache space based on the IP address of the source warehouse.
7. The image synchronization method of claim 5, wherein the step of pushing the target image from the local cache space into the target repository comprises:
modifying a Domain Name Server (DNS) mapped by the IP address of the transit server so as to point the address of the mirror image memory to the IP address of the target warehouse indicated by the target warehouse identifier;
and pushing the target mirror image to the target warehouse from the local cache space based on the IP address of the target warehouse.
8. A mirror image synchronizer is characterized in that the mirror image synchronizer is applied to a transfer server which establishes connection relations with mirror image warehouses in advance, and comprises:
a receiving unit, configured to receive a mirror image synchronization request, where the mirror image synchronization request at least carries: a source warehouse identification, a target warehouse identification and a mirror image identification of a target mirror image to be synchronized;
and the response unit is used for responding to the mirror image synchronization request, pulling the target mirror image in the source warehouse to a local cache space, pushing the target mirror image from the local cache space to the target warehouse, and completing mirror image synchronization operation, wherein the warehouse name of the source warehouse is the same as the warehouse name of the target warehouse.
9. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the mirror synchronization method of any of claims 1-7 via execution of the executable instructions.
10. A computer-readable storage medium, comprising a stored computer program, wherein the computer program when executed controls an apparatus in which the computer-readable storage medium is located to perform the mirror synchronization method of any one of claims 1 to 7.
CN202211564998.9A 2022-12-07 2022-12-07 Mirror image synchronization method and device, electronic equipment and storage medium Pending CN115941704A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211564998.9A CN115941704A (en) 2022-12-07 2022-12-07 Mirror image synchronization method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211564998.9A CN115941704A (en) 2022-12-07 2022-12-07 Mirror image synchronization method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115941704A true CN115941704A (en) 2023-04-07

Family

ID=86655177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211564998.9A Pending CN115941704A (en) 2022-12-07 2022-12-07 Mirror image synchronization method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115941704A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117077218A (en) * 2023-10-07 2023-11-17 之江实验室 Synchronization method, device, medium and equipment for mirror images of multi-center medical institution

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117077218A (en) * 2023-10-07 2023-11-17 之江实验室 Synchronization method, device, medium and equipment for mirror images of multi-center medical institution
CN117077218B (en) * 2023-10-07 2024-01-26 之江实验室 Synchronization method, device, medium and equipment for mirror images of multi-center medical institution

Similar Documents

Publication Publication Date Title
US9229759B2 (en) Virtual machine provisioning using replicated containers
CN107066242B (en) Method and system for determining identification of software in software container
CN107203419B (en) Method, device and system for calling among modules in application program
CN111726399B (en) Docker container secure access method and device
US10013491B2 (en) Methods and systems of workload mobility across divergent platforms
CN106201566B (en) Benefit wins the hot upgrade method of big special software and equipment
US10592312B2 (en) Message oriented middleware with integrated rules engine
CN111901294A (en) Method for constructing online machine learning project and machine learning system
JP2018537783A (en) Run the application using pre-generated components
US20210064351A1 (en) Packaging support system and packaging support method
US11531526B1 (en) Creating portable serverless applications
JP2015180991A (en) Image forming apparatus, control method of image forming apparatus, and program
CN115941704A (en) Mirror image synchronization method and device, electronic equipment and storage medium
CN110417741B (en) Method and device for filtering security group
CN106462442A (en) System and method of loading virtual machines
CN111881209A (en) Data synchronization method and device for heterogeneous database, electronic equipment and medium
CN114661375A (en) Application integration method and device
US20110138452A1 (en) Cross security-domain identity context projection within a computing environment
US11494184B1 (en) Creation of transportability container files for serverless applications
US10956413B2 (en) Action set translation
EP3276914A1 (en) Data sharing method and device for virtual desktop
US11513833B1 (en) Event listener interface for container-based execution of serverless functions
CN111857959B (en) Method, system, equipment and medium for Docker mirror image synchronization of cross-local area network
CN113420306A (en) Resource sharing method and device, computing equipment and computer readable storage medium
CN114090188A (en) Method for realizing independent multi-user system based on android system virtualization and application

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination