CN112052067A - Virtualized container startup and information maintenance method, electronic device and storage medium - Google Patents
Virtualized container startup and information maintenance method, electronic device and storage medium Download PDFInfo
- Publication number
- CN112052067A CN112052067A CN202010727944.4A CN202010727944A CN112052067A CN 112052067 A CN112052067 A CN 112052067A CN 202010727944 A CN202010727944 A CN 202010727944A CN 112052067 A CN112052067 A CN 112052067A
- Authority
- CN
- China
- Prior art keywords
- container
- startup
- identifier
- dependent
- storage space
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45575—Starting, stopping, suspending or resuming virtual machine instances
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
- G06F2009/45591—Monitoring or debugging support
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明实施例提供了一种虚拟化容器启动和信息维护方法、电子设备和存储介质,对每一容器均配置启动工具。启动工具获取到其所在的任一容器的依赖容器的标识后,或者通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询到任一容器的依赖容器的标识后,若通过该启动前回调接口从共享存储空间中查询到该依赖容器的标识映射完成启动标识,则通过执行回调接口启动该任一容器。通过由任一容器所属的容器集合共享的共享存储空间,使得启动工具能够通过统一的接口实现依赖容器的查询、依赖容器启动状态的查询,以及写入容器的启动状态,从而无需针对容器封装不同的脚本,实现了容器启动流程的标准化,简化了容器顺序启动的实现过程。
Embodiments of the present invention provide a virtualized container startup and information maintenance method, an electronic device, and a storage medium, and a startup tool is configured for each container. After the startup tool obtains the identity of the dependent container of any container where it is located, or queries the identity of the dependent container of any container from the dependent container relationship stored in the shared storage space through the pre-start callback interface, if the startup tool passes the startup The pre-callback interface queries the shared storage space to the identity mapping of the dependent container and completes the start-up identity, and then any container is started by executing the callback interface. Through the shared storage space shared by the container set to which any container belongs, the startup tool can implement container-dependent query, container startup status query, and write container startup status through a unified interface, so that there is no need to encapsulate different containers for different containers. , which standardizes the container startup process and simplifies the implementation process of container sequential startup.
Description
技术领域technical field
本发明涉虚拟化容器技术领域,尤其是涉及一种虚拟化容器启动和信息维护方法、电子设备和存储介质。The present invention relates to the technical field of virtualized containers, and in particular, to a virtualized container startup and information maintenance method, electronic device and storage medium.
背景技术Background technique
目前虚拟化容器的启动存在两种方式。第一种方式:在Docker Compose中,使用脚本等工具封装容器的启动命令。然而,由于脚本不具有通用性,对每一容器均需要重新编写进行封装的脚本,封装过程复杂。第二种方式仅适用于容器进行初始化的过程中。在容器进行初始化的过程中,需要保证前一容器进行初始化启动完成再退出后,后一容器才能进行初始化启动。然而在实际业务运行的过程中,通常需要多个容器同时运行,因此第二种方式并不适用于业务运行过程中控制容器的启动过程。There are currently two ways to start a virtualized container. The first way: In Docker Compose, use tools such as scripts to encapsulate the startup command of the container. However, since the script is not universal, the script for encapsulation needs to be rewritten for each container, and the encapsulation process is complicated. The second method is only applicable during the initialization of the container. In the process of container initialization, it is necessary to ensure that the latter container can be initialized and started only after the previous container is initialized and started and then exits. However, in the process of actual business operation, multiple containers are usually required to run at the same time, so the second method is not suitable for controlling the startup process of the container during the business operation process.
可见,现有技术中容器的启动需要依赖对每一容器封装的脚本,由于对各容器封装的脚本不同,实现过程复杂。It can be seen that in the prior art, the startup of a container needs to rely on a script encapsulated for each container. Since the scripts encapsulated for each container are different, the implementation process is complicated.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供一种虚拟化容器启动和信息维护方法、电子设备和存储介质,用以解决现有技术中容器的启动需要依赖对每一容器封装的脚本,由于对各容器封装的脚本不同,实现过程复杂的问题。Embodiments of the present invention provide a virtualized container startup and information maintenance method, an electronic device, and a storage medium, so as to solve the problem that in the prior art, the startup of a container needs to rely on a script packaged for each container, because the scripts packaged for each container are different. , the implementation process is complex.
针对以上技术问题,第一方面,本发明实施例提供一种虚拟化容器启动方法,包括:In view of the above technical problems, in a first aspect, an embodiment of the present invention provides a method for starting a virtualized container, including:
任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识,或者根据所述任一容器的标识,通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询所述任一容器的依赖容器的标识;其中,所述依赖容器为启动顺序在所述任一容器之前,且启动顺序与所述任一容器相邻的容器;所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器;所述依赖容器关系中,记录有所述容器集合中容器的标识,以及相应的启动顺序;The startup tool configured in any container obtains the identifier of the dependent container of any container from the configuration file of any container, or according to the identifier of any container, obtains the identifier from the shared storage space through the pre-start callback interface Query the identifier of the dependent container of the any container in the stored dependency container relationship; wherein, the dependent container is a container whose startup order is before any of the containers, and the startup order is adjacent to the any of the containers; The shared storage space is shared by the container set to which any container belongs; the container set includes at least two containers with a startup sequence; in the container-dependent relationship, the identifier of the container in the container set is recorded, and the corresponding startup sequence;
根据所述依赖容器的标识,以及由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,通过执行回调接口向所述任一容器发送启动命令,否则,不向所述任一容器发送所述启动命令。According to the identifier of the dependent container and the mapping relationship between the identifier of the start-up completed and the identifier of the container that has completed the start-up written into the shared storage space by the container that has completed the startup in the container set, the pre-start callback The interface queries whether the identifier of the dependent container is mapped to the startup identifier, and sends a startup command to any of the containers through the execution callback interface until the identifier of the dependent container is queried and mapped to the startup identifier, otherwise, it does not send a startup command to any of the containers. A container sends the start command.
可选地,启动所述待启动容器之后,还包括:Optionally, after starting the to-be-started container, the method further includes:
在检测到所述任一容器启动完成后,通过通知回调接口向所述共享存储空间中所述任一容器所在的文件夹中写入预设格式的文件,以所述预设格式的文件作为所述任一容器映射的完成启动标识。After detecting that the startup of any container is completed, write a file in a preset format to the folder where the any container is located in the shared storage space through a notification callback interface, and use the file in the preset format as the The completion startup identifier of any of the container mappings.
可选地,所述通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,包括:Optionally, the querying, through the pre-start callback interface, whether the identity of the dependent container is mapped to the start-up identity, until the start-up identity of the dependent container is queried after the identity mapping is completed, includes:
每隔预设时长通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识。It is queried through the pre-start callback interface whether the identification of the dependent container is mapped to the start-up identification every preset time period, until the identification of the dependent container is queried to complete the start-up identification mapping.
可选地,在所述任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识之前,包括:Optionally, before the startup tool configured in the any container obtains the identifier of the dependent container of the any container from the configuration file of the any container, it includes:
根据创建所述任一容器时配置的,启动所述任一容器依赖的依赖容器的标识,生成所述配置文件。The configuration file is generated according to the identifier of the dependent container that is configured when any container is created and depends on which any container is started.
第二方面,本发明实施例提供一种虚拟化容器信息维护方法,应用于共享存储空间,包括:In a second aspect, an embodiment of the present invention provides a method for maintaining virtualized container information, which is applied to a shared storage space, including:
获取通过交互界面对容器集合中的任一容器配置的,启动所述容器集合中各容器时,所述任一容器对应的启动顺序,将所述任一容器的标识,以及所述任一容器对应的启动顺序存储到共享存储空间中的依赖容器关系中;Obtain the startup sequence corresponding to any container configured by the interactive interface for any container in the container set, when each container in the container set is started, the identifier of the any container, and the start sequence of the any container. The corresponding startup sequence is stored in the dependency container relationship in the shared storage space;
其中,所述任一容器对应的启动顺序根据创建所述容器集合中的每一容器时,对每一容器配置的启动每一容器所依赖的容器确定;其中,所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器。Wherein, the startup sequence corresponding to any one of the containers is determined according to the container on which each container is configured to start each container when each container in the container set is created; wherein, the shared storage space is determined by the It is shared by the container set to which any container belongs; the container set includes at least two containers in a startup order.
可选地,还包括:Optionally, also include:
接收任一容器中配置的启动工具通过启动前回调接口发送的第一查询请求;所述第一查询请求用于请求根据所述任一容器的标识查询所述任一容器的依赖容器的标识;Receive a first query request sent by the startup tool configured in any container through the pre-start callback interface; the first query request is used to request to query the identity of the dependent container of any container according to the identity of the container;
从所述共享存储空间中存储的依赖容器关系查询启动顺序与所述任一容器的启动顺序相邻,且在所述任一容器之前启动的容器的标识,将查询到的容器的标识作为所述任一容器的依赖容器的标识;The startup sequence of the dependent container relationship query stored in the shared storage space is adjacent to the startup sequence of any container, and the identifier of the container started before the any container is used as the identifier of the queried container. The identity of the dependent container of any of the above containers;
通过所述启动前回调接口向所述启动工具返回所述任一容器的依赖容器的标识。Return the identifier of the dependent container of any container to the startup tool through the pre-start callback interface.
可选地,还包括:Optionally, also include:
接收任一容器中配置的启动工具通过所述启动前回调接口发送的第二查询请求,所述第二查询请求用于请求查询所述任一容器的依赖容器的标识是否映射完成启动标识;Receive a second query request sent by the startup tool configured in any container through the pre-start callback interface, where the second query request is used to request to query whether the identifier of the dependent container of any container is mapped to the startup identifier;
根据由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,查询所述任一容器的依赖容器的标识是否映射完成启动标识,若是,则通过所述启动前回调接口向所述启动工具发送查询响应,否则,不向所述启动工具发送所述查询响应;所述查询响应用于指示查询到所述依赖容器的标识映射完成启动标识。According to the mapping relationship between the start completion identifier written into the shared storage space by the container that has completed startup in the container set and the identifier of the container that has completed startup, query whether the identifier of the dependent container of any container has been mapped. Startup identifier, if yes, send a query response to the startup tool through the pre-start callback interface, otherwise, do not send the query response to the startup tool; the query response is used to indicate that the dependency container is queried. Identity mapping completes the startup identity.
可选地,还包括:Optionally, also include:
接收任一容器中配置的启动工具通过通知回调接口发送的写入指令;所述写入指令用于指示对所述任一容器写入完成启动标识;Receive a write instruction sent by the startup tool configured in any container through the notification callback interface; the write instruction is used to indicate that the writing of the startup identifier to any of the containers is completed;
在所述共享存储空间中所述任一容器所在的文件夹中写入预设格式的文件,以所述预设格式的文件作为所述任一容器映射的完成启动标识。A file in a preset format is written in the folder where the any container is located in the shared storage space, and the file in the preset format is used as the completion startup identifier of the mapping of the any container.
第三方面,本发明实施例提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现以上所述的虚拟化容器启动方法或者虚拟化容器信息维护方法的步骤。In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, where the processor implements the above-mentioned virtual reality when executing the program. The steps of the method for starting the virtualized container or the method for maintaining the information of the virtualized container.
第四方面,本发明实施例提供一种非暂态可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以上任一项所述的虚拟化容器启动方法或者虚拟化容器信息维护方法的步骤。In a fourth aspect, an embodiment of the present invention provides a non-transitory readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements any of the above-described methods for starting a virtualized container or virtualization Steps of container information maintenance method.
本发明的实施例提供了一种虚拟化容器启动和信息维护方法、电子设备和存储介质,对每一容器均配置启动工具。启动工具获取到其所在的任一容器的依赖容器的标识后,或者通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询到任一容器的依赖容器的标识后,若通过该启动前回调接口从共享存储空间中查询到该依赖容器的标识映射完成启动标识,则通过执行回调接口启动该任一容器。通过由任一容器所属的容器集合共享的共享存储空间,使得启动工具能够通过统一的接口实现依赖容器的查询、依赖容器启动状态的查询,以及写入容器的启动状态,从而无需针对容器封装不同的脚本,实现了容器启动流程的标准化,简化了容器顺序启动的实现过程。Embodiments of the present invention provide a virtualized container startup and information maintenance method, an electronic device, and a storage medium, and a startup tool is configured for each container. After the startup tool obtains the identity of the dependent container of any container where it is located, or after querying the identity of the dependent container of any container from the dependent container relationship stored in the shared storage space through the pre-start callback interface, if the startup tool passes the startup After the pre-callback interface queries the shared storage space to the identity mapping of the dependent container and completes the start-up identity, any container is started by executing the callback interface. Through the shared storage space shared by the container set to which any container belongs, the startup tool can implement the container-dependent query, the container-dependent startup status query, and write the container startup status through a unified interface, so that there is no need to encapsulate different containers for different containers. , which standardizes the container startup process and simplifies the implementation process of container sequential startup.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.
图1是本发明实施例提供的虚拟化容器启动方法的流程示意图;1 is a schematic flowchart of a method for starting a virtualized container provided by an embodiment of the present invention;
图2是本发明另一实施例提供的启动工具控制容器启动的原理示意图;2 is a schematic diagram of the principle of a startup tool controlling the startup of a container provided by another embodiment of the present invention;
图3是本发明另一实施例提供的虚拟化容器信息维护方法的流程示意图;3 is a schematic flowchart of a method for maintaining virtualized container information provided by another embodiment of the present invention;
图4是本发明另一实施例提供的容器有序启动的实现流程示意图;FIG. 4 is a schematic flowchart of an implementation of orderly startup of containers provided by another embodiment of the present invention;
图5是本发明另一实施例提供的虚拟化容器启动装置的结构框图;5 is a structural block diagram of an apparatus for starting a virtualized container provided by another embodiment of the present invention;
图6是本发明另一实施例提供虚拟化容器信息维护装置的结构框图;6 is a structural block diagram of an apparatus for maintaining virtualized container information provided by another embodiment of the present invention;
图7是本发明另一实施例提供电子设备的实体结构示意图。FIG. 7 is a schematic diagram of a physical structure of an electronic device provided by another embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
在一些场景中,需要对虚拟化容器的启动顺序进行控制。为此,本申请提供了一种虚拟化容器启动方法,该虚拟化容器启动方法由任一对虚拟化容器的启动进行管理的启动工具执行。其中,每一容器中均配置一个启动工具,用于对该容器的启动进行控制。In some scenarios, it is necessary to control the startup order of virtualized containers. To this end, the present application provides a method for starting a virtualized container, where the method for starting a virtualized container is executed by any starting tool that manages the starting of a virtualized container. A startup tool is configured in each container to control the startup of the container.
本申请提供的虚拟化容器启动方法可以应用于以下至少一种应用场景中:The virtualized container startup method provided by this application can be applied to at least one of the following application scenarios:
场景1:容器的启动需要依赖上一个容器提供的服务。如需要依赖上一个容器提供的服务为:Web Server和/或数据库,其中,Web Server必须等待数据库启动完成可用后才能启动。Scenario 1: The startup of a container needs to rely on the services provided by the previous container. If you need to rely on the services provided by the previous container: Web Server and/or database, where the Web Server must wait for the database to be started and available before it can be started.
场景2:容器需要为下一个容器或服务完成初始化配置。如需要为下一个容器采集必要的集群信息、节点信息、网络服务信息等预置到配置文件中,或者从远程Git仓库、文件系统中,下载所需的配置文件或数据文件等。Scenario 2: The container needs to complete the initial configuration for the next container or service. If you need to collect the necessary cluster information, node information, network service information, etc. for the next container and preset it into the configuration file, or download the required configuration file or data file from the remote Git repository or file system.
场景3:容器需要向远程服务发送Pod或服务的自注册信息,且注册完成后,才能启动所在Pod或服务内的其他容器。Scenario 3: The container needs to send the self-registration information of the Pod or service to the remote service, and after the registration is completed, other containers in the Pod or service can be started.
图1为本实施例提供的虚拟化容器启动方法的流程示意图,参见图1,该虚拟化容器启动方法包括如下步骤:FIG. 1 is a schematic flowchart of a method for starting a virtualized container provided by this embodiment. Referring to FIG. 1 , the method for starting a virtualized container includes the following steps:
步骤101:任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识,或者根据所述任一容器的标识,通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询所述任一容器的依赖容器的标识;其中,所述依赖容器为启动顺序在所述任一容器之前,且启动顺序与所述任一容器相邻的容器;所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器;所述依赖容器关系中,记录有所述容器集合中容器的标识,以及相应的启动顺序;Step 101: The startup tool configured in any container obtains the identifier of the dependent container of any container from the configuration file of any container, or according to the identifier of any container, obtains the identifier from the shared container through the pre-start callback interface. Query the identifier of the dependent container of the any container in the dependency container relationship stored in the storage space; wherein, the dependent container is the one whose startup order is before any one of the containers, and the startup order is adjacent to the any one of the containers. container; the shared storage space is shared by the container set to which any container belongs; the container set includes at least two containers with a startup sequence; in the container-dependent relationship, the container in the container set is recorded , and the corresponding startup sequence;
步骤102:根据所述依赖容器的标识,以及由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,通过执行回调接口向所述任一容器发送启动命令,否则,不向所述任一容器发送所述启动命令。Step 102: According to the identifier of the dependent container, and the mapping relationship between the identifier of the start-up completed written in the shared storage space by the container that has completed the startup in the container set and the identifier of the container that has completed the start-up, through the The callback interface before startup inquires whether the identifier of the dependent container is mapped to the startup identifier, and sends a startup command to any of the containers through the execution callback interface until the identifier of the dependent container is queried and the startup identifier is mapped and completed. The any container sends the start command.
图2为本实施例提供的启动工具控制容器启动的原理示意图,参见图2,容器集合中的每一容器中均配置一个启动工具,该启动工具循环地执行上述步骤101和步骤102,以启动其所在的容器。任一容器的依赖容器指的是,在任一容器启动时,必须已经完成启动的容器。FIG. 2 is a schematic diagram of the principle of the startup tool controlling the startup of a container provided in this embodiment. Referring to FIG. 2 , each container in the container set is configured with a startup tool, and the startup tool cyclically executes the
对于任一容器中配置的启动工具,首先通过步骤101中确定该任一容器的依赖容器的标识。存在两种获取途径:For the startup tool configured in any container, first determine the identifier of the dependent container of the any container through
途径1:从任一容器的配置文件中获取。其中,配置文件中包括创建该任一容器时,配置的启动顺序在该任一容器之前,且启动顺序与该任一容器相邻的容器(即任一容器的依赖容器)的标识。配置在任一容器中的启动工具通过get命令从任一容器的配置文件中获取该任一容器的依赖容器的标识。Approach 1: Obtain from the configuration file of any container. Wherein, the configuration file includes the identifiers of containers (ie, dependent containers of any container) whose startup sequence is configured before any container and whose startup sequence is adjacent to any container when any container is created. The startup tool configured in any container obtains the identifier of the dependent container of any container from the configuration file of any container through the get command.
途径2:启动工具根据其所在的任一容器的标识(任一容器的标识可以在将启动工具配置到任一容器中时写入该启动工具),通过对外提供的启动前回调接口从共享存储空间中存储的依赖容器关系中,查询得到该任一容器的依赖容器的标识。Approach 2: The startup tool, according to the identifier of any container it is in (the identifier of any container can be written to the startup tool when the startup tool is configured into any container), from the shared storage through the pre-start callback interface provided externally. In the dependent container relationship stored in the space, query to obtain the identifier of the dependent container of any container.
对于上述途径2,具体来说,启动工具将任一容器的标识和第一查询指令通过启动前回调接口发送到共享存储空间,以使得共享存储空间根据任一容器的标识从存储的依赖容器关系中查询得到该任一容器的依赖容器的标识,并通过启动前回调接口将该任一容器的依赖容器的标识返回给启动工具。其中,第一查询请求用于请求根据所述任一容器的标识查询所述任一容器的依赖容器的标识。For the
确定了任一容器的依赖容器的标识后,通过步骤102查询任一容器的依赖容器是否启动完成,若是,则通过执行回调接口对任一容器发送启动命令,实现任一容器的启动,否则,不向任一容器发送启动命令,使得任一容器处于等待启动的状态。After determining the identifier of the dependent container of any container, query whether the dependent container of any container has been started through
需要说明的是,容器集合中的任一完成了启动的容器,均在共享存储空间中存储了该完成了启动的容器的标识与完成启动标识之间的映射关系。因此,每一启动工具均能够通过该映射关系,从共享存储空间中查询到任一容器的依赖容器是否完成启动。It should be noted that, for any container in the container set that has completed the startup, the mapping relationship between the identifier of the container that has completed startup and the startup identifier is stored in the shared storage space. Therefore, each startup tool can query from the shared storage space whether the dependent container of any container has completed startup through the mapping relationship.
具体地,在上述步骤102中,启动工具将该任一容器的依赖容器的标识和第二查询请求通过启动前回调接口发送到共享存储空间,以使得共享存储空间根据任一容器的依赖容器的标识查询该任一容器的依赖容器是否映射完成启动标识,若是,则说明该任一容器的依赖容器启动完成,否则,该任一容器的依赖容器没有启动完成。其中,第二查询请求用于请求查询所述任一容器的依赖容器的标识是否映射完成启动标识。Specifically, in the
在本实施例中,对每一容器配置启动工具,启动工具通过启动前回调接口通过共享存储空间查询容器的依赖容器,以及依赖容器的启动状态,通过执行回调接口向所在的容器发送启动命令,完成容器的启动。启动工具能够通过统一的启动前回调接口,以及在容器完成启动后,写入启动完成标识的通知回调接口,从共享存储空间查询依赖容器的相关信息,并通过执行回调接口与容器交互完成启动的控制。可见,通过启动工具和共享存储卷的交互,以及启动工具和其所在的容器之间的交互,以统一的流程实现了容器的启动。本实施例将容器启动的流程标准化,相比于现有技术,无需对不同的容器封装不同的脚本,而仅由在容器中安装的启动工具,通过启动工具和共享存储空间的交互即可实现容器启动。容器启动流程的标准化有利于简化容器顺序启动的实现过程。In this embodiment, a startup tool is configured for each container, the startup tool queries the dependent container of the container through the shared storage space through the pre-start callback interface, and the startup status of the dependent container, and sends the startup command to the container through the execution callback interface, Finish starting the container. The startup tool can query the relevant information of the dependent container from the shared storage space through the unified pre-start callback interface and write the notification callback interface of the startup completion mark after the container completes startup, and interact with the container through the execution callback interface to complete the startup. control. It can be seen that through the interaction between the startup tool and the shared storage volume, as well as the interaction between the startup tool and the container where it is located, the startup of the container is realized in a unified process. This embodiment standardizes the process of container startup. Compared with the prior art, there is no need to encapsulate different scripts for different containers, and only the startup tool installed in the container can implement the interaction between the startup tool and the shared storage space. The container starts. The standardization of the container startup process is conducive to simplifying the implementation process of container sequential startup.
本实施例提供了一种虚拟化容器启动方法,对每一容器均配置启动工具。启动工具获取到其所在的任一容器的依赖容器的标识后,或者通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询到任一容器的依赖容器的标识后,若通过该启动前回调接口从共享存储空间中查询到该依赖容器的标识映射完成启动标识,则通过执行回调接口启动该任一容器。通过由任一容器所属的容器集合共享的共享存储空间,使得启动工具能够通过统一的接口实现依赖容器的查询、依赖容器启动状态的查询,以及写入容器的启动状态,从而无需针对容器封装不同的脚本,实现了容器启动流程的标准化,简化了容器顺序启动的实现过程。This embodiment provides a method for starting a virtualized container, and a starting tool is configured for each container. After the startup tool obtains the identity of the dependent container of any container where it is located, or after querying the identity of the dependent container of any container from the dependent container relationship stored in the shared storage space through the pre-start callback interface, if the startup tool passes the startup After the pre-callback interface queries the shared storage space to the identity mapping of the dependent container and completes the start-up identity, any container is started by executing the callback interface. Through the shared storage space shared by the container set to which any container belongs, the startup tool can implement the container-dependent query, the container-dependent startup status query, and write the container startup status through a unified interface, so that there is no need to encapsulate different containers for different containers. , which standardizes the container startup process and simplifies the implementation process of container sequential startup.
进一步地,在上述实施例的基础上,还包括:Further, on the basis of the foregoing embodiment, it also includes:
在检测到所述任一容器启动完成后,通过通知回调接口向所述共享存储空间中所述任一容器所在的文件夹中写入预设格式的文件,以所述预设格式的文件作为所述任一容器映射的完成启动标识。After detecting that the startup of any container is completed, write a file in a preset format to the folder where the any container is located in the shared storage space through a notification callback interface, and use the file in the preset format as the The completion startup identifier of any of the container mappings.
其中,配置在任一容器中的启动工具可以通过容器启动完成前和启动完成后的参数变化,判断该任一容器是否启动完成。Wherein, the startup tool configured in any container can judge whether the startup of any container is completed according to the parameter changes before and after the startup of the container is completed.
在检测到任一容器启动完成后,启动工具调用通知回调接口在共享存储卷中写入与该任一容器的标识映射的完成启动标识。需要说明的是,在本实施例中,启动完成标识指的是预设格式的文件。例如,预设格式的文件为finish.ok。例如,容器名为“容器名1”的容器启动完成后,该容器中配置的启动工具通过通知回调接口向共享存储空间中,该容器所在的文件下存储finish.ok的文件,以存储的finish.ok的文件所在的文件目录存在如下文件:“/服务名1/容器名1/finish.ok”。After detecting that the startup of any container is completed, the startup tool invokes the notification callback interface to write the completion startup identifier mapped with the identifier of the any container in the shared storage volume. It should be noted that, in this embodiment, the startup completion identifier refers to a file in a preset format. For example, the default format file is finish.ok. For example, after the container named "container name 1" is started, the startup tool configured in the container sends the file of finish.ok to the shared storage space through the notification callback interface. The file where the container is located stores the finish.ok file to store the finished The following file exists in the file directory where the .ok file is located: "/service name1/container name1/finish.ok".
具体地,启动工具在检测到任一容器启动完成后,通过通知回调接口向共享存储空间发送写入指令,以根据该写入指令在共享存储空间中该任一容器的文件夹中存储预设格式的文件,以该预设格式的文件作为该任一容器的启动完成标识。其中,写入指令中包括了该任一容器的标识。Specifically, after detecting that any container has been started, the startup tool sends a write instruction to the shared storage space through the notification callback interface, so as to store the preset in the folder of any container in the shared storage space according to the write instruction format file, and the preset format file is used as the startup completion identifier of any container. Wherein, the write instruction includes the identifier of any container.
本实施例中容器的启动工具在容器启动完成后,通过通知回调接口在共享存储空间中的容器的文件夹中存储预设格式的文件,以预设格式的文件作为启动完成标识。提供了一种简单的启动完成标识写入的方法,实现了对启动完成后的容器进行标识,提供了容器是否启动完成的判断依据。In this embodiment, after the container startup is completed, the container startup tool stores a file in a preset format in a folder of the container in the shared storage space through a notification callback interface, and uses the file in the preset format as a startup completion identifier. Provided is a simple method for writing a startup completion identifier, which realizes the identification of a container after startup is completed, and provides a basis for judging whether the startup of the container is completed.
进一步地,在上述各实施例的基础上,所述通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,包括:Further, on the basis of the above-mentioned embodiments, the querying through the pre-start callback interface whether the identification of the dependent container is mapped to the start-up identification, until after the identification of the dependent container is queried and the identification of the dependent container is mapped and completes the startup identification, including: :
每隔预设时长通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识。It is queried through the pre-start callback interface whether the identification of the dependent container is mapped to the start-up identification every preset time period, until the identification of the dependent container is queried to complete the start-up identification mapping.
启动工具在查询任一容器的依赖容器的标识是否映射完成启动标识的过程中,若第一次没有查询到依赖容器的标识映射完成启动标识,则继续每隔预设时长重复查询过程,直到查询到依赖容器的标识映射完成启动标识。其中,预设时长可以预先设定,例如,5秒。In the process of querying whether the identifier of the dependent container of any container has been mapped to the startup identifier, the startup tool will continue to repeat the query process every preset time period until the query is completed if the identifier of the dependent container is not queried for the first time. The identity mapping to the dependent container completes the startup identity. The preset duration may be preset, for example, 5 seconds.
本实施例通过对依赖容器的标识是否映射完成启动标识的反复查询,能够保证查询结果的及时性,及时在查询到依赖容器的启动完成标识后启动该任一容器,提高了对容器按顺序启动的控制效率。This embodiment can ensure the timeliness of the query result by repeatedly querying whether the identifier of the dependent container is mapped to complete the startup identifier, and start any container in time after the startup completion identifier of the dependent container is queried in time, which improves the ability to start the containers in sequence. control efficiency.
进一步地,在上述各实施例的基础上,在所述任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识之前,包括:Further, on the basis of the above embodiments, before the startup tool configured in the any container obtains the identifier of the dependent container of the any container from the configuration file of the any container, the method includes:
根据创建所述任一容器时配置的,启动所述任一容器依赖的依赖容器的标识,生成所述配置文件。The configuration file is generated according to the identifier of the dependent container that is configured when any container is created and depends on which any container is started.
任一容器创建的过程会配置该任一容器启动所依赖的依赖容器,配置文件中写入了在任一容器创建时配置的该任一容器启动所依赖的依赖容器的标识。任一容器的启动工具可以通过访问该配置文件确定该任一容器的依赖容器的标识。The process of creating any container configures the dependent container on which the startup of any container depends, and the configuration file writes the identifier of the dependent container on which the startup of any container depends, which is configured when any container is created. The startup tool of any container can determine the identity of the dependent container of any container by accessing the configuration file.
本实施例中,启动工具通过任一容器中的配置文件确定了任一容器的依赖容器的标识,从而根据任一容器的依赖容器的标识查询依赖容器的启动状态,实现对容器按照启动顺序启动的控制过程。In this embodiment, the startup tool determines the identifier of the dependent container of any container through the configuration file in any container, so as to query the startup status of the dependent container according to the identifier of the dependent container of any container, so as to realize the startup of the containers according to the startup sequence control process.
基于上述对启动工具对容器启动过程的控制,参见图2,本实施例提供的虚拟化容器启动方法,(1)将彼此之间有启动依赖关系的服务容器组成一个集合(例如,Container1、Container2……Containern),其中的给每一个容器都挂载并共享同一个共享存储卷(container.meta,即共享存储空间)。(2)提供统一的容器命令启动工具,该工具提供三个回调接口:Based on the above-mentioned control of the startup tool on the container startup process, referring to FIG. 2 , in the virtualized container startup method provided in this embodiment, (1) the service containers that have startup dependencies between each other are formed into a set (for example, Container1, Container2 ...Containern), in which each container is mounted and shared with the same shared storage volume (container.meta, that is, shared storage space). (2) Provide a unified container command startup tool, which provides three callback interfaces:
启动前回调接口为启动前依赖的回调接口,该接口返回当前容器启动依赖的其他服务容器列表,用于预判和等待依赖容器的启动完成。The callback interface before startup is the callback interface that depends on the startup. This interface returns the list of other service containers that the current container depends on to start, which is used to predict and wait for the startup of the dependent container to complete.
执行回调接口为启动命令的执行的回调接口,该接口返回当前容器的启动命令,用于启动容器。The execution callback interface is a callback interface for the execution of the start command, and the interface returns the start command of the current container, which is used to start the container.
通知回调接口为当前的待启动容器启动完成的通知回调接口,用于容器启动完成时,向指定的目录及文件进行登记注册。The notification callback interface is the notification callback interface for the startup completion of the current container to be started. It is used to register with the specified directory and file when the container startup is completed.
针对共享存储空间,在图2中还提供(3)一套运维WEB界面,后台通过读取共享存储卷的目录及文件,来展示容器间的启动依赖关系。具体地,图3为本实施例提供的一种虚拟化容器信息维护方法的流程示意图,该虚拟化容器信息维护方法应用于共享存储空间,参见图3,该虚拟化容器信息维护方法包括:For the shared storage space, (3) a set of operation and maintenance WEB interface is also provided in Figure 2. The background displays the startup dependencies between containers by reading the directories and files of the shared storage volume. Specifically, FIG. 3 is a schematic flowchart of a method for maintaining information on a virtualized container provided in this embodiment. The method for maintaining information on a virtualized container is applied to a shared storage space. Referring to FIG. 3 , the method for maintaining information on a virtualized container includes:
步骤301:获取通过交互界面对容器集合中的任一容器配置的,启动所述容器集合中各容器时,所述任一容器对应的启动顺序,将所述任一容器的标识,以及所述任一容器对应的启动顺序存储到共享存储空间中的依赖容器关系中;Step 301: Acquire the startup sequence corresponding to any container in the container set configured through the interactive interface, when each container in the container set is started, the identifier of the any container, and the The startup sequence corresponding to any container is stored in the dependent container relationship in the shared storage space;
其中,所述任一容器对应的启动顺序根据创建所述容器集合中的每一容器时,对每一容器配置的启动每一容器所依赖的容器确定;其中,所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器。Wherein, the startup sequence corresponding to any one of the containers is determined according to the container on which each container is configured to start each container when each container in the container set is created; wherein, the shared storage space is determined by the It is shared by the container set to which any container belongs; the container set includes at least two containers in a startup order.
交互界面指的是人机交互界面(例如,WEB界面),用户可以通过交互界面写入容器的启动顺序,由共享存储空间将该启动顺序存储到依赖容器关系中。可理解的是,用户是按照创建容器时,对容器配置的依赖容器写入启动顺序的。若用户写入的启动顺序与根据对各容器配置的依赖容器确定的启动顺序不同,则会在启动过程中出现错误,导致按序启动的终止。The interactive interface refers to a human-computer interactive interface (for example, a WEB interface). The user can write the startup sequence of the container through the interactive interface, and the shared storage space stores the startup sequence in the dependent container relationship. It is understandable that the user writes the startup sequence of the container according to the container configuration dependency when the container is created. If the startup order written by the user is different from the startup order determined according to the dependent containers configured for each container, an error will occur during the startup process, resulting in the termination of the sequential startup.
本实施例中,通过交互界面对共享存储空间中的依赖容器关系进行存入和编辑,提供了用户对共享存储空间进行统一管理的途径,实现了对共享存储空间中依赖容器关系的管理。In this embodiment, the dependent container relationship in the shared storage space is stored and edited through the interactive interface, which provides a way for the user to manage the shared storage space in a unified manner, and realizes the management of the dependent container relationship in the shared storage space.
实施例提供了一种虚拟化容器信息维护方法,对每一容器均配置启动工具。启动工具获取到其所在的任一容器的依赖容器的标识后,或者通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询到任一容器的依赖容器的标识后,若通过该启动前回调接口从共享存储空间中查询到该依赖容器的标识映射完成启动标识,则通过执行回调接口启动该任一容器。通过由任一容器所属的容器集合共享的共享存储空间,使得启动工具能够通过统一的接口实现依赖容器的查询、依赖容器启动状态的查询,以及写入容器的启动状态,从而无需针对容器封装不同的脚本,实现了容器启动流程的标准化,简化了容器顺序启动的实现过程。The embodiment provides a method for maintaining virtualized container information, in which a startup tool is configured for each container. After the startup tool obtains the identity of the dependent container of any container where it is located, or after querying the identity of the dependent container of any container from the dependent container relationship stored in the shared storage space through the pre-start callback interface, if the startup tool passes the startup After the pre-callback interface queries the shared storage space to the identity mapping of the dependent container and completes the start-up identity, any container is started by executing the callback interface. Through the shared storage space shared by the container set to which any container belongs, the startup tool can implement the container-dependent query, the container-dependent startup status query, and write the container startup status through a unified interface, so that there is no need to encapsulate different containers for different containers. , which standardizes the container startup process and simplifies the implementation process of container sequential startup.
进一步地,在上述实施例的基础上,还包括:Further, on the basis of the foregoing embodiment, it also includes:
接收任一容器中配置的启动工具通过启动前回调接口发送的第一查询请求;所述第一查询请求用于请求根据所述任一容器的标识查询所述任一容器的依赖容器的标识;Receive a first query request sent by the startup tool configured in any container through the pre-start callback interface; the first query request is used to request to query the identity of the dependent container of any container according to the identity of the container;
从所述共享存储空间中存储的依赖容器关系查询启动顺序与所述任一容器的启动顺序相邻,且在所述任一容器之前启动的容器的标识,将查询到的容器的标识作为所述任一容器的依赖容器的标识;The startup sequence of the dependent container relationship query stored in the shared storage space is adjacent to the startup sequence of any container, and the identifier of the container started before the any container is used as the identifier of the queried container. The identity of the dependent container of any of the above containers;
通过所述启动前回调接口向所述启动工具返回所述任一容器的依赖容器的标识。Return the identifier of the dependent container of any container to the startup tool through the pre-start callback interface.
在实现容器按序启动的过程中,启动工具通过启动前回调接口与共享存储空间交互,实现对依赖容器的标识,以及依赖容器启动状态的查询。共享存储空间接收到第一查询请求后,根据任一容器的标识从依赖容器关系中查询该任一容器的依赖容器的标识,并将查询到的依赖容器的标识通过启动前回调接口返回给启动工具,使得启动工具根据依赖容器的标识对依赖容器的启动状态进行查询,从而在依赖容器完成启动后,再启动该任一容器,实现了容器按照启动顺序启动的控制。In the process of realizing the sequential startup of containers, the startup tool interacts with the shared storage space through the pre-start callback interface, and realizes the identification of the dependent container and the query of the startup status of the dependent container. After the shared storage space receives the first query request, it queries the identifier of the dependent container of any container from the dependent container relationship according to the identifier of any container, and returns the queried identifier of the dependent container to the startup through the pre-start callback interface. The tool enables the startup tool to query the startup status of the dependent container according to the identifier of the dependent container, so that any container can be started after the dependent container is started, which realizes the control that the containers are started according to the startup sequence.
进一步地,在上述各实施例的基础上,还包括:Further, on the basis of the above embodiments, it also includes:
接收任一容器中配置的启动工具通过所述启动前回调接口发送的第二查询请求,所述第二查询请求用于请求查询所述任一容器的依赖容器的标识是否映射完成启动标识;Receive a second query request sent by the startup tool configured in any container through the pre-start callback interface, where the second query request is used to request to query whether the identifier of the dependent container of any container is mapped to the startup identifier;
根据由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,查询所述任一容器的依赖容器的标识是否映射完成启动标识,若是,则通过所述启动前回调接口向所述启动工具发送查询响应,否则,不向所述启动工具发送所述查询响应;所述查询响应用于指示查询到所述依赖容器的标识映射完成启动标识。According to the mapping relationship between the start completion identifier written into the shared storage space by the container that has completed startup in the container set and the identifier of the container that has completed startup, query whether the identifier of the dependent container of any container has been mapped. Startup identifier, if yes, send a query response to the startup tool through the pre-start callback interface, otherwise, do not send the query response to the startup tool; the query response is used to indicate that the dependency container is queried. Identity mapping completes the startup identity.
任一容器的启动工具在确定了该任一容器的依赖容器的标识后,根据该依赖容器的标识向共享存储空间发送第二查询请求。共享存储空间接收到第二查询请求后,根据依赖容器的标识,通过预先对每一完成启动的容器存储的完成启动标识,查询该依赖容器是否完成启动。在共享存储空间确定该任一容器的依赖容器的标识映射了完成启动标识后,向启动工具返回查询响应,以使得该任一容器的启动工具在接收到该查询响应后对该任一容器进行启动控制。After determining the identifier of the dependent container of any container, the startup tool of any container sends a second query request to the shared storage space according to the identifier of the dependent container. After receiving the second query request, the shared storage space queries, according to the identifier of the dependent container, whether the dependent container has completed startup by storing the completed startup identifier of each container that has completed startup in advance. After the shared storage space determines that the identifier of the dependent container of any container is mapped with the completion startup identifier, a query response is returned to the startup tool, so that the startup tool of any container receives the query response. Launch control.
需要说明的是,当任一容器存在多个依赖容器时,只有接收到对应于每一依赖容器的查询响应后,才对该任一容器进行启动。It should be noted that when there are multiple dependent containers in any container, any container will be started only after receiving a query response corresponding to each dependent container.
本实施例中,通过启动前回调接口对依赖容器的启动状态的查询,在任一容器的启动工具接收到任一容器的每一依赖容器对应的查询响应后,控制该任一容器启动,实现了容器的按序启动。In this embodiment, by querying the startup status of the dependent container through the pre-start callback interface, after the startup tool of any container receives the query response corresponding to each dependent container of any container, it controls the startup of any container, thereby realizing Sequential startup of containers.
进一步地,在上述各实施例的基础上,还包括:Further, on the basis of the above embodiments, it also includes:
接收任一容器中配置的启动工具通过通知回调接口发送的写入指令;所述写入指令用于指示对所述任一容器写入完成启动标识;Receive a write instruction sent by the startup tool configured in any container through the notification callback interface; the write instruction is used to indicate that the writing of the startup identifier to any of the containers is completed;
在所述共享存储空间中所述任一容器所在的文件夹中写入预设格式的文件,以所述预设格式的文件作为所述任一容器映射的完成启动标识。A file in a preset format is written in the folder where the any container is located in the shared storage space, and the file in the preset format is used as the completion startup identifier of the mapping of the any container.
启动工具还提供了通知回调接口,当启动工具检测到任一容器启动完成后,通过该通知回调接口对该任一容器写入启动完成标识,以能够在任一容器完成启动后,通过共享存储卷查询到该任一容器的启动状态,从而在该任一容器作为其它容器的依赖容器时,能够查询到及时更新的正确的启动状态,保证后续容器的按序启动。The startup tool also provides a notification callback interface. When the startup tool detects that the startup of any container is completed, it writes the startup completion flag to any container through the notification callback interface, so that after any container finishes startup, the shared storage volume can be The startup status of any container can be queried, so that when any container is used as a dependent container of other containers, the correct startup status updated in time can be queried to ensure the sequential startup of subsequent containers.
本实施例中,通过通知回调接口实现了在任一容器完成启动后,对任一容器启动状态的及时更新,使得共享存储空间能够提供及时更新的容器状态,避免因启动状态更新不及时对启动过程的拖延,保证容器按序启动的启动效率。In this embodiment, the notification callback interface is used to realize the timely update of the startup status of any container after the startup of any container is completed, so that the shared storage space can provide the timely updated container status, and avoid the startup process due to the untimely update of the startup status. The delay ensures the startup efficiency of container startup in sequence.
总体来说,对于虚拟化容器启动和信息维护方法,包括如下几方面的信息:In general, for virtualized container startup and information maintenance methods, the following information is included:
在容器启动完成,进行回调时,启动工具需要向共享存储卷的指定目录,写入一个空文件finish.ok,对应目录路径如下:/服务名/容器名/finish.ok;并在共享存储卷的根目录的container.meta文件中更新自身的容器信息(容器的状态信息),如包括:容器及所依赖容器的状态、标志文件路径等。此处,标志文件及容器信息的存储,一方面用于判定容器是否已启动完成,一方面用于界面可视化展示和配置。When the container is started and called back, the startup tool needs to write an empty file finish.ok to the specified directory of the shared storage volume, and the corresponding directory path is as follows: /service name/container name/finish.ok; and in the shared storage volume Update its own container information (container status information) in the container.meta file in the root directory of the . Here, the storage of the flag file and the container information is used to determine whether the container has been started and completed, and it is used for the visual display and configuration of the interface on the other hand.
在容器启动前进行回调时,启动工具需要根据接口返回的依赖服务容器列表,读取指定服务下的指定容器目录下是否有finish.ok文件,有则,返回true,执行启动命令;无则,返回false,继续等待。When a callback is made before the container is started, the startup tool needs to read whether there is a finish.ok file in the specified container directory under the specified service according to the list of dependent service containers returned by the interface. If yes, return true and execute the startup command; if not, Return false to continue waiting.
图4为本实施例提供的容器有序启动的实现流程示意图,参见图4,该流程包括如下过程:FIG. 4 is a schematic diagram of the implementation flow of the container orderly startup provided by this embodiment. Referring to FIG. 4 , the flow includes the following processes:
1.用户通过可视化界面预置一个容器集合,并配置每个容器的启动依赖列表,具体实现方式上,可配置集合内各个容器的启动顺序,同一顺序可配置多个容器。1. The user presets a container collection through the visual interface, and configures the startup dependency list of each container. In the specific implementation method, the startup order of each container in the collection can be configured, and multiple containers can be configured in the same order.
2.可视化界面与共享存储区进行交互。通过解析用户的预置信息,得到集合内每个容器的启动依赖列表,然后将这些信息存储到共享存储区的container.meta文件中。2. The visual interface interacts with the shared storage area. By parsing the user's preset information, the startup dependency list of each container in the collection is obtained, and then the information is stored in the container.meta file in the shared storage area.
3.容器启动前,启动工具通过读取环境变量或容器内的指定配置文件,获得当前容器标识,如名称等。3. Before the container is started, the startup tool obtains the current container identifier, such as the name, by reading the environment variable or the specified configuration file in the container.
4.启动工具到共享存储区的container.meta文件中查询当前容器的依赖容器列表,若当前容器启动不依赖其他容器,则直接进入第6步,否则继续下面步骤。4. Start the tool in the container.meta file of the shared storage area to query the list of dependent containers of the current container. If the current container does not depend on other containers, go directly to step 6, otherwise continue to the following steps.
5.启动工具根据依赖容器列表,到共享存储区查找各个容器的完成标志文件finish.ok是否已存在,如果有一个不存在,则等待5S后,继续查询。5. According to the list of dependent containers, the startup tool goes to the shared storage area to find out whether the completion flag file finish.ok of each container already exists. If one does not exist, wait for 5S before continuing the query.
6.如果依赖容器的完成标志文件都存在,则调用容器的启动命令启动容器。6. If the completion flag files of the dependent container all exist, call the start command of the container to start the container.
7.容器启动完成后,通知启动工具。通知方式包括7. After the container startup is complete, notify the startup tool. Notification methods include
a.容器提供探针服务,由启动工具检测服务是否已启动完成;a. The container provides a probe service, and the startup tool detects whether the service has been started;
b.容器启动完成后,回调启动工具的通知接口等。b. After the container is started, the notification interface of the startup tool is called back.
8.启动工具接收到容器启动完成的指令后,向共享存储区写入该容器的启动完成标志文件,如“/服务名1/容器名1/finisho.ok”,并在container.meta文件中更新容器的自身信息,如容器及所依赖容器的状态、标志文件路径等。8. After the startup tool receives the container startup completion instruction, it writes the container startup completion flag file to the shared storage area, such as "/service name1/container name1/finisho.ok", and in the container.meta file Update the container's own information, such as the state of the container and its dependent containers, and the path of the flag file.
总结来说,本实施例提供的方法一方面通过统一的启动工具,封装容器的启动命令,标准化了容器的启动流程,另一方面,通过共享存储的通信方式,实现了容器启动依赖关系的判断等待与通知记录。To sum up, the method provided by this embodiment, on the one hand, standardizes the start process of the container by encapsulating the start command of the container through a unified start tool, and on the other hand, realizes the judgment of the container start dependency through the communication method of shared storage Wait and notify records.
可理解的是,上述各实施例提供的方法在Docker Compose、K8S上均适用,甚至不局限于Docker,只要容器提供启动命令回调接口实现,以及共享存储挂载即可。It is understandable that the methods provided by the above embodiments are applicable to Docker Compose and K8S, and are not even limited to Docker, as long as the container provides the implementation of the startup command callback interface and the shared storage mount.
相比于现有的Docker Compose中实现容器按序启动的方式,一方面本实施例提供的方法通过统一的启动工具,标准化了容器的启动流程(具体来说,本申请各实施例中的启动工具,对外暴露了三个接口回调,可以对容器的启动前依赖判断与等待、启动命令执行、启动完成通知与记录进行统一化、标准化回调处理)。另一方面本实施例提供的方法彼此依赖的容器共享同一个存储卷,通过存储卷目录文件并结合WEB展示的方式,管理启动依赖关系,更加简明直观,易于维护。Compared with the existing Docker Compose way of realizing the sequential startup of containers, on the one hand, the method provided by this embodiment standardizes the startup process of the container through a unified startup tool (specifically, the startup process in the embodiments of the present application is The tool exposes three interface callbacks, which can unify and standardize callback processing for container pre-start dependency judgment and waiting, startup command execution, startup completion notification and recording). On the other hand, in the method provided by this embodiment, containers that depend on each other share the same storage volume, and by storing the volume directory file and displaying it in combination with the WEB, the startup dependency is managed, which is more concise, intuitive, and easy to maintain.
相比于现有的Kubernetes的Init container方案相比,首先,本实施例提供的方法不要求容器启动完成就得退出服务。即在容器完成启动完成通知后,便可以进入持续地在线运行,并提供服务。其次,本实施例提供的方法实现可直接用于Pod内,实现pod内多容器的启动顺序,还可实现不同服务、不同pod内的容器启动顺序控制,控制粒度更精细。最后,本实施例提供的方法不需要依赖Kubernetes中采用的初始容器(init-container)概念,局限小,可跨平台运用。Compared with the existing Init container solution of Kubernetes, first of all, the method provided in this embodiment does not require that the container needs to exit the service after the start of the container is completed. That is, after the container completes the startup completion notification, it can enter continuous online operation and provide services. Secondly, the implementation of the method provided in this embodiment can be directly used in the Pod to realize the startup sequence of multiple containers in the pod, and can also realize the control of the startup sequence of different services and containers in different pods, and the control granularity is finer. Finally, the method provided in this embodiment does not need to rely on the concept of an initial container (init-container) adopted in Kubernetes, has small limitations, and can be used across platforms.
图5为本实施例提供的虚拟化容器启动装置的结构框图,所述虚拟化容器启动装置应用于启动工具,参见图5,所述虚拟化容器启动装置包括获取模块501和启动模块502,其中,FIG. 5 is a structural block diagram of a virtualized container startup device provided in this embodiment. The virtualized container startup device is applied to a startup tool. Referring to FIG. 5 , the virtualized container startup device includes an
获取模块501,用于从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识,或者根据所述任一容器的标识,通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询所述任一容器的依赖容器的标识;其中,所述依赖容器为启动顺序在所述任一容器之前,且启动顺序与所述任一容器相邻的容器;所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器;所述依赖容器关系中,记录有所述容器集合中容器的标识,以及相应的启动顺序;The obtaining
启动模块502,用于根据所述依赖容器的标识,以及由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,通过执行回调接口向所述任一容器发送启动命令,否则,不向所述任一容器发送所述启动命令。The
本实施例提供的虚拟化容器启动装置适用于上述各实施例提供的虚拟化容器启动方法,在此不再赘述。The virtualized container startup device provided in this embodiment is applicable to the virtualized container startup methods provided by the above embodiments, and details are not described herein again.
本发明的实施例提供了一种虚拟化容器启动和信息维护装置,对每一容器均配置启动工具。启动工具获取到其所在的任一容器的依赖容器的标识后,或者通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询到任一容器的依赖容器的标识后,若通过该启动前回调接口从共享存储空间中查询到该依赖容器的标识映射完成启动标识,则通过执行回调接口启动该任一容器。通过由任一容器所属的容器集合共享的共享存储空间,使得启动工具能够通过统一的接口实现依赖容器的查询、依赖容器启动状态的查询,以及写入容器的启动状态,从而无需针对容器封装不同的脚本,实现了容器启动流程的标准化,简化了容器顺序启动的实现过程。The embodiment of the present invention provides a virtualized container startup and information maintenance device, and a startup tool is configured for each container. After the startup tool obtains the identity of the dependent container of any container where it is located, or queries the identity of the dependent container of any container from the dependent container relationship stored in the shared storage space through the pre-start callback interface, if the startup tool passes the startup The pre-callback interface queries the shared storage space to the identity mapping of the dependent container and completes the start-up identity, and then any container is started by executing the callback interface. Through the shared storage space shared by the container set to which any container belongs, the startup tool can implement container-dependent query, container startup status query, and write container startup status through a unified interface, so that there is no need to encapsulate different containers for different containers. , which standardizes the container startup process and simplifies the implementation process of container sequential startup.
可选地,还包括:Optionally, also include:
在检测到所述任一容器启动完成后,通过通知回调接口向所述共享存储空间中所述任一容器所在的文件夹中写入预设格式的文件,以所述预设格式的文件作为所述任一容器映射的完成启动标识。After detecting that the startup of any container is completed, write a file in a preset format to the folder where the any container is located in the shared storage space through a notification callback interface, and use the file in the preset format as the The completion startup identifier of any of the container mappings.
可选地,所述通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,包括:Optionally, the querying, through the pre-start callback interface, whether the identity of the dependent container is mapped to the start-up identity, until the start-up identity of the dependent container is queried after the identity mapping is completed, includes:
每隔预设时长通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识。It is queried through the pre-start callback interface whether the identification of the dependent container is mapped to the start-up identification every preset time period, until the identification of the dependent container is queried to complete the start-up identification mapping.
可选地,在所述任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识之前,包括:Optionally, before the startup tool configured in the any container obtains the identifier of the dependent container of the any container from the configuration file of the any container, it includes:
根据创建所述任一容器时配置的,启动所述任一容器依赖的依赖容器的标识,生成所述配置文件。The configuration file is generated according to the identifier of the dependent container that is configured when any container is created and depends on which any container is started.
图6为本实施例提供的虚拟化容器信息维护装置的结构框图,所述虚拟化容器信息维护装置应用于共享存储空间,参见图6,所述虚拟化容器信息维护装置包括存储模块601,其中,FIG. 6 is a structural block diagram of an apparatus for maintaining virtualized container information provided in this embodiment. The apparatus for maintaining virtualized container information is applied to a shared storage space. Referring to FIG. 6 , the apparatus for maintaining virtualized container information includes a
存储模块601,用于获取通过交互界面对容器集合中的任一容器配置的,启动所述容器集合中各容器时,所述任一容器对应的启动顺序,将所述任一容器的标识,以及所述任一容器对应的启动顺序存储到共享存储空间中的依赖容器关系中;The
其中,所述任一容器对应的启动顺序根据创建所述容器集合中的每一容器时,对每一容器配置的启动每一容器所依赖的容器确定;其中,所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器。Wherein, the startup sequence corresponding to any one of the containers is determined according to the container on which each container is configured to start each container when each container in the container set is created; wherein, the shared storage space is determined by the It is shared by the container set to which any container belongs; the container set includes at least two containers in a startup order.
本实施例提供的虚拟化容器信息维护方法适用于上述各实施例提供的虚拟化容器信息维护方法,在此不再赘述。The method for maintaining virtualized container information provided in this embodiment is applicable to the methods for maintaining virtualized container information provided by the foregoing embodiments, and details are not described herein again.
本发明的实施例提供了一种虚拟化容器启动和信息维护装置,对每一容器均配置启动工具。启动工具获取到其所在的任一容器的依赖容器的标识后,或者通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询到任一容器的依赖容器的标识后,若通过该启动前回调接口从共享存储空间中查询到该依赖容器的标识映射完成启动标识,则通过执行回调接口启动该任一容器。通过由任一容器所属的容器集合共享的共享存储空间,使得启动工具能够通过统一的接口实现依赖容器的查询、依赖容器启动状态的查询,以及写入容器的启动状态,从而无需针对容器封装不同的脚本,实现了容器启动流程的标准化,简化了容器顺序启动的实现过程。The embodiment of the present invention provides a virtualized container startup and information maintenance device, and a startup tool is configured for each container. After the startup tool obtains the identity of the dependent container of any container where it is located, or after querying the identity of the dependent container of any container from the dependent container relationship stored in the shared storage space through the pre-start callback interface, if the startup tool passes the startup After the pre-callback interface queries the shared storage space to the identity mapping of the dependent container and completes the start-up identity, any container is started by executing the callback interface. Through the shared storage space shared by the container set to which any container belongs, the startup tool can implement the container-dependent query, the container-dependent startup status query, and write the container startup status through a unified interface, so that there is no need to encapsulate different containers for different containers. , which standardizes the container startup process and simplifies the implementation process of container sequential startup.
可选地,还包括:Optionally, also include:
接收任一容器中配置的启动工具通过启动前回调接口发送的第一查询请求;所述第一查询请求用于请求根据所述任一容器的标识查询所述任一容器的依赖容器的标识;Receive a first query request sent by the startup tool configured in any container through the pre-start callback interface; the first query request is used to request to query the identity of the dependent container of any container according to the identity of the container;
从所述共享存储空间中存储的依赖容器关系查询启动顺序与所述任一容器的启动顺序相邻,且在所述任一容器之前启动的容器的标识,将查询到的容器的标识作为所述任一容器的依赖容器的标识;The startup sequence of the dependent container relationship query stored in the shared storage space is adjacent to the startup sequence of any container, and the identifier of the container started before the any container is used as the identifier of the queried container. The identity of the dependent container of any of the above containers;
通过所述启动前回调接口向所述启动工具返回所述任一容器的依赖容器的标识。Return the identifier of the dependent container of any container to the startup tool through the pre-start callback interface.
可选地,还包括:Optionally, also include:
接收任一容器中配置的启动工具通过所述启动前回调接口发送的第二查询请求,所述第二查询请求用于请求查询所述任一容器的依赖容器的标识是否映射完成启动标识;Receive a second query request sent by the startup tool configured in any container through the pre-start callback interface, where the second query request is used to request to query whether the identifier of the dependent container of any container is mapped to the startup identifier;
根据由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,查询所述任一容器的依赖容器的标识是否映射完成启动标识,若是,则通过所述启动前回调接口向所述启动工具发送查询响应,否则,不向所述启动工具发送所述查询响应;所述查询响应用于指示查询到所述依赖容器的标识映射完成启动标识。According to the mapping relationship between the start completion identifier written into the shared storage space by the container that has completed startup in the container set and the identifier of the container that has completed startup, query whether the identifier of the dependent container of any container has been mapped. Startup identifier, if yes, send a query response to the startup tool through the pre-start callback interface, otherwise, do not send the query response to the startup tool; the query response is used to indicate that the dependency container is queried. Identity mapping completes the startup identity.
可选地,还包括:Optionally, also include:
接收任一容器中配置的启动工具通过通知回调接口发送的写入指令;所述写入指令用于指示对所述任一容器写入完成启动标识;Receive a write instruction sent by the startup tool configured in any container through the notification callback interface; the write instruction is used to indicate that the writing of the startup identifier to any of the containers is completed;
在所述共享存储空间中所述任一容器所在的文件夹中写入预设格式的文件,以所述预设格式的文件作为所述任一容器映射的完成启动标识。A file in a preset format is written in the folder where the any container is located in the shared storage space, and the file in the preset format is used as the completion startup identifier of the mapping of the any container.
图7示例了一种电子设备的实体结构示意图,如图7所示,该电子设备可以包括:处理器(processor)701、通信接口(Communications Interface)702、存储器(memory)703和通信总线704,其中,处理器701,通信接口702,存储器703通过通信总线704完成相互间的通信。处理器701可以调用存储器703中的逻辑指令,以执行如下方法:FIG. 7 illustrates a schematic diagram of the physical structure of an electronic device. As shown in FIG. 7 , the electronic device may include: a processor (processor) 701, a communication interface (Communications Interface) 702, a memory (memory) 703, and a
任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识,或者根据所述任一容器的标识,通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询所述任一容器的依赖容器的标识;其中,所述依赖容器为启动顺序在所述任一容器之前,且启动顺序与所述任一容器相邻的容器;所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器;所述依赖容器关系中,记录有所述容器集合中容器的标识,以及相应的启动顺序;根据所述依赖容器的标识,以及由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,通过执行回调接口向所述任一容器发送启动命令,否则,不向所述任一容器发送所述启动命令;The startup tool configured in any container obtains the identifier of the dependent container of any container from the configuration file of any container, or according to the identifier of any container, obtains the identifier from the shared storage space through the pre-start callback interface Query the identifier of the dependent container of the any container in the stored dependency container relationship; wherein, the dependent container is a container whose startup order is before any of the containers, and the startup order is adjacent to the any of the containers; The shared storage space is shared by the container set to which any container belongs; the container set includes at least two containers with a startup sequence; in the container-dependent relationship, the identifier of the container in the container set is recorded, and the corresponding startup sequence; according to the identifier of the dependent container, and the mapping relationship between the identifier of the completed startup written in the shared storage space by the container that has completed the startup in the container set and the identifier of the container that has completed the startup, Use the pre-start callback interface to query whether the identifier of the dependent container is mapped to the startup identifier, and send a startup command to any of the containers through the execution callback interface until the identifier of the dependent container is queried to complete the startup identifier. , do not send the start command to any of the containers;
或者,获取通过交互界面对容器集合中的任一容器配置的,启动所述容器集合中各容器时,所述任一容器对应的启动顺序,将所述任一容器的标识,以及所述任一容器对应的启动顺序存储到共享存储空间中的依赖容器关系中;其中,所述任一容器对应的启动顺序根据创建所述容器集合中的每一容器时,对每一容器配置的启动每一容器所依赖的容器确定;其中,所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器。Or, obtain the startup sequence corresponding to any container when starting each container in the container set configured through the interactive interface for any container in the container set, the identifier of any container, and the start sequence of each container in the container set. The startup sequence corresponding to a container is stored in the dependent container relationship in the shared storage space; wherein, the startup sequence corresponding to any container is based on the startup sequence configured for each container when each container in the container set is created. The container on which a container depends is determined; wherein, the shared storage space is shared by the container set to which the any container belongs; the container set includes at least two containers in a startup sequence.
此外,上述的存储器703中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the above-mentioned logic instructions in the
进一步地,本发明实施例公开一种计算机程序,所述计算机程序包括存储在非暂态可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,计算机能够执行上述各方法实施例所提供的方法,例如包括:Further, an embodiment of the present invention discloses a computer program, the computer program includes a computer program stored on a non-transitory readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, The computer can execute the methods provided by the above method embodiments, for example, including:
任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识,或者根据所述任一容器的标识,通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询所述任一容器的依赖容器的标识;其中,所述依赖容器为启动顺序在所述任一容器之前,且启动顺序与所述任一容器相邻的容器;所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器;所述依赖容器关系中,记录有所述容器集合中容器的标识,以及相应的启动顺序;根据所述依赖容器的标识,以及由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,通过执行回调接口向所述任一容器发送启动命令,否则,不向所述任一容器发送所述启动命令;The startup tool configured in any container obtains the identifier of the dependent container of any container from the configuration file of any container, or according to the identifier of any container, obtains the identifier from the shared storage space through the pre-start callback interface Query the identifier of the dependent container of the any container in the stored dependency container relationship; wherein, the dependent container is a container whose startup order is before any of the containers, and the startup order is adjacent to the any of the containers; The shared storage space is shared by the container set to which any container belongs; the container set includes at least two containers with a startup sequence; in the container-dependent relationship, the identifier of the container in the container set is recorded, and the corresponding startup sequence; according to the identifier of the dependent container, and the mapping relationship between the identifier of the completed startup written in the shared storage space by the container that has completed the startup in the container set and the identifier of the container that has completed the startup, Use the pre-start callback interface to query whether the identifier of the dependent container is mapped to the startup identifier, and send a startup command to any of the containers through the execution callback interface until the identifier of the dependent container is queried to complete the startup identifier. , do not send the start command to any of the containers;
或者,获取通过交互界面对容器集合中的任一容器配置的,启动所述容器集合中各容器时,所述任一容器对应的启动顺序,将所述任一容器的标识,以及所述任一容器对应的启动顺序存储到共享存储空间中的依赖容器关系中;其中,所述任一容器对应的启动顺序根据创建所述容器集合中的每一容器时,对每一容器配置的启动每一容器所依赖的容器确定;其中,所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器。Or, obtain the startup sequence corresponding to any container when starting each container in the container set configured through the interactive interface for any container in the container set, the identifier of any container, and the start sequence of each container in the container set. The startup sequence corresponding to a container is stored in the dependent container relationship in the shared storage space; wherein, the startup sequence corresponding to any container is based on the startup sequence configured for each container when each container in the container set is created. The container on which a container depends is determined; wherein, the shared storage space is shared by the container set to which the any container belongs; the container set includes at least two containers in a startup sequence.
另一方面,本发明实施例还提供一种非暂态可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各实施例提供的传输方法,例如包括:On the other hand, an embodiment of the present invention also provides a non-transitory readable storage medium on which a computer program is stored, and the computer program is implemented when executed by a processor to execute the transmission methods provided by the foregoing embodiments, for example, including:
任一容器中配置的启动工具从所述任一容器的配置文件中获取所述任一容器的依赖容器的标识,或者根据所述任一容器的标识,通过启动前回调接口从共享存储空间中存储的依赖容器关系中查询所述任一容器的依赖容器的标识;其中,所述依赖容器为启动顺序在所述任一容器之前,且启动顺序与所述任一容器相邻的容器;所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器;所述依赖容器关系中,记录有所述容器集合中容器的标识,以及相应的启动顺序;根据所述依赖容器的标识,以及由所述容器集合中完成启动的容器写入所述共享存储空间中的完成启动标识与完成启动的容器的标识之间的映射关系,通过所述启动前回调接口查询所述依赖容器的标识是否映射完成启动标识,直至查询到所述依赖容器的标识映射完成启动标识后,通过执行回调接口向所述任一容器发送启动命令,否则,不向所述任一容器发送所述启动命令;The startup tool configured in any container obtains the identifier of the dependent container of any container from the configuration file of any container, or according to the identifier of any container, obtains the identifier from the shared storage space through the pre-start callback interface Query the identifier of the dependent container of the any container in the stored dependency container relationship; wherein, the dependent container is a container whose startup order is before any of the containers, and the startup order is adjacent to the any of the containers; The shared storage space is shared by the container set to which any container belongs; the container set includes at least two containers with a startup sequence; in the container-dependent relationship, the identifier of the container in the container set is recorded, and the corresponding startup sequence; according to the identifier of the dependent container, and the mapping relationship between the identifier of the completed startup written in the shared storage space by the container that has completed the startup in the container set and the identifier of the container that has completed the startup, Use the pre-start callback interface to query whether the identifier of the dependent container is mapped to the startup identifier, and send a startup command to any of the containers through the execution callback interface until the identifier of the dependent container is queried to complete the startup identifier. , do not send the start command to any of the containers;
或者,获取通过交互界面对容器集合中的任一容器配置的,启动所述容器集合中各容器时,所述任一容器对应的启动顺序,将所述任一容器的标识,以及所述任一容器对应的启动顺序存储到共享存储空间中的依赖容器关系中;其中,所述任一容器对应的启动顺序根据创建所述容器集合中的每一容器时,对每一容器配置的启动每一容器所依赖的容器确定;其中,所述共享存储空间由所述任一容器所属的容器集合所共享;所述容器集合中包括存在启动顺序的至少两个容器。Or, obtain the startup sequence corresponding to any container when starting each container in the container set configured through the interactive interface for any container in the container set, the identifier of any container, and the start sequence of each container in the container set. The startup sequence corresponding to a container is stored in the dependent container relationship in the shared storage space; wherein, the startup sequence corresponding to any container is based on the startup sequence configured for each container when each container in the container set is created. The container on which a container depends is determined; wherein, the shared storage space is shared by the container set to which the any container belongs; the container set includes at least two containers in a startup sequence.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed over multiple network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on this understanding, the above-mentioned technical solutions can be embodied in the form of software products in essence or the parts that make contributions to the prior art. The computer software products can be stored in readable storage media, such as ROM/RAM, magnetic disks, etc. , optical disc, etc., including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the methods described in various embodiments or some parts of the embodiments.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be The technical solutions described in the foregoing embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010727944.4A CN112052067B (en) | 2020-07-23 | 2020-07-23 | Virtualized container startup and information maintenance method, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010727944.4A CN112052067B (en) | 2020-07-23 | 2020-07-23 | Virtualized container startup and information maintenance method, electronic device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112052067A true CN112052067A (en) | 2020-12-08 |
CN112052067B CN112052067B (en) | 2024-11-22 |
Family
ID=73601211
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010727944.4A Active CN112052067B (en) | 2020-07-23 | 2020-07-23 | Virtualized container startup and information maintenance method, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112052067B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114237626A (en) * | 2021-12-22 | 2022-03-25 | 四川新网银行股份有限公司 | Method, system and equipment for non-invasive dynamic editing of JVM (Java virtual machine) parameters |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107368339A (en) * | 2017-07-25 | 2017-11-21 | 上海携程商务有限公司 | Container entrance program operating method, system, equipment and storage medium |
US20180246729A1 (en) * | 2017-02-24 | 2018-08-30 | International Business Machines Corporation | Techniques for managing software container dependencies |
US20190065096A1 (en) * | 2017-08-25 | 2019-02-28 | Vmware, Inc. | Distributed file storage system supporting accesses from multiple container hosts |
CN110134496A (en) * | 2019-05-22 | 2019-08-16 | 中国联合网络通信集团有限公司 | Container monitoring method, device, equipment and computer-readable storage medium |
-
2020
- 2020-07-23 CN CN202010727944.4A patent/CN112052067B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180246729A1 (en) * | 2017-02-24 | 2018-08-30 | International Business Machines Corporation | Techniques for managing software container dependencies |
CN107368339A (en) * | 2017-07-25 | 2017-11-21 | 上海携程商务有限公司 | Container entrance program operating method, system, equipment and storage medium |
US20190065096A1 (en) * | 2017-08-25 | 2019-02-28 | Vmware, Inc. | Distributed file storage system supporting accesses from multiple container hosts |
CN110134496A (en) * | 2019-05-22 | 2019-08-16 | 中国联合网络通信集团有限公司 | Container monitoring method, device, equipment and computer-readable storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114237626A (en) * | 2021-12-22 | 2022-03-25 | 四川新网银行股份有限公司 | Method, system and equipment for non-invasive dynamic editing of JVM (Java virtual machine) parameters |
CN114237626B (en) * | 2021-12-22 | 2024-06-21 | 四川新网银行股份有限公司 | Method, system and equipment for non-invasively dynamically editing JVM parameters |
Also Published As
Publication number | Publication date |
---|---|
CN112052067B (en) | 2024-11-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10637796B2 (en) | Linking instances within a cloud computing environment | |
CN111279321B (en) | Binding backend service endpoints to API functions in an API registry | |
CN109634718B (en) | Method and system for creating mirror image by cloud platform | |
US10558649B2 (en) | Database server system monitoring | |
EP3803591A1 (en) | Managing hosted resources across different virtualization platforms | |
JP3307329B2 (en) | Network configuration managed access system and method | |
CN111641676A (en) | Method and device for constructing third-party cloud monitoring service | |
CN109814863A (en) | A processing method, device, computer equipment and computer storage medium for requesting returned data | |
CN102880542B (en) | Cloud computing service evaluation system and evaluation method | |
US20070050751A1 (en) | Automatic interoperation with legacy POS service and control objects | |
CN106559453A (en) | The external resource management method of cloud intercommunication, apparatus and system | |
CN116339756A (en) | Application program mounting method, device, equipment and storage medium | |
CN112235132A (en) | Method, device, medium and server for dynamically configuring service | |
CN113568603B (en) | Component object creating and interface method calling method, terminal and storage device | |
CN112052067A (en) | Virtualized container startup and information maintenance method, electronic device and storage medium | |
CN118192965A (en) | Page component processing method, device, computer equipment, storage medium and product | |
CN113672334A (en) | Container management method and device | |
WO2018028321A1 (en) | Method and apparatus for managing virtual external storage device, and terminal | |
CN111125007B (en) | Application packaging method, device and readable storage medium | |
WO2024255085A1 (en) | Business service establishment method and apparatus, computer device, and storage medium | |
CN117544641A (en) | Cloud host image uploading method and device | |
CN117439880A (en) | A product access method, device, equipment and storage medium | |
Yang | A self-configured WBEM architecture to upgrade the storage resource management | |
CN118276988A (en) | A method and server for business expansion | |
CN116340273A (en) | Method, device and equipment for synchronously extracting heterogeneous files based on different storage methods |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |