Control method, device, storage medium, and electronic device of container system
Patent Information
- Application Number
- CN202311255753.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2043-09-26
AI Technical Summary
[0004]本发明实施例提供了一种容器系统的控制方法、装置、存储介质及电子装置,以至少解决相关技术中存在的容器系统的切换时间较长导致效率较低的技术问题
[0018] This invention, upon receiving a target switchover instruction, issues a target control instruction to a first container system to instruct it to restart a first group of containers and a first group of external service processes. The target switchover instruction indicates a switchover to the first container system should a second container system fail. The first group of external service processes includes the external service processes corresponding to each container in the first group. Before receiving the target switchover instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes the external service processes corresponding to each container in the second group. In other words, when the second container system fails, a target control instruction is issued to the first container system, switching to it and controlling the first container system to restart the first group of containers and the first group of external service processes. Furthermore, since the second group of containers and the second group of external service processes in the first container system are pre-started before the switchover, this avoids the problem in related technologies where switching between different container systems requires starting all container services in each location, resulting in a long switchover time. Therefore, this invention solves the technical problem of long switchover times and low efficiency in related technologies, achieving the effect of improving container system switchover efficiency.
Smart Images

Figure CN117215837B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to a control method, apparatus, storage medium, and electronic device for a container system. Background Technology
[0002] With the rapid development of cloud-native technologies, more and more distributed systems are being developed based on container technology. When user traffic increases, local systems can quickly scale up to handle peak traffic and ensure continuous system availability. However, in the event of a campus or even regional disaster, container systems cannot recover quickly and require the use of off-site disaster recovery systems for rapid system recovery. Currently, there are several challenges in enabling off-site container systems: 1) Container management platforms in two different locations manage the systems separately, requiring cross-regional cooperation for system switchover; 2) The startup process of container systems involves a large number of services that are invoked and have dependencies; 3) Containers themselves have long startup times. In related technologies, when switching off-site container systems, all container services in each location are typically started through the container management platform in each location to achieve service takeover. Therefore, the current methods for rapid off-site switchover of container systems suffer from long switchover times.
[0003] There is currently no effective solution to the technical problem of low efficiency caused by long switching times in container systems. Summary of the Invention
[0004] This invention provides a control method, apparatus, storage medium, and electronic device for a container system, to at least solve the technical problem of low efficiency caused by long switching time in container systems in related technologies.
[0005] According to an embodiment of the present invention, a control method for a container system is provided, comprising: upon receiving a target switching instruction, issuing a target control instruction to a first container system to instruct the first container system to restart a first group of containers and a first group of external service processes, wherein the target switching instruction is used to instruct switching to the first container system in the event of a failure in a second container system, the first group of external service processes includes external service processes corresponding to each container in the first group of containers, and before receiving the target switching instruction, the first container system is configured to pre-start a second group of containers and a second group of external service processes, the second group of external service processes including external service processes corresponding to each container in the second group of containers.
[0006] In one exemplary embodiment, the method further includes: before receiving the target switching instruction, controlling the first container system to pre-start the second group of containers and the second group of external service processes.
[0007] In an exemplary embodiment, issuing a target control instruction to the first container system to instruct the first container system to restart a first group of containers and a first group of external service processes includes: issuing a first instruction to the first container system to instruct the first container system to configure a set of environment variables, wherein the set of environment variables includes environment variables of each container in a target container set in the first container system, the environment variables being used to represent the service status of the container, the target container set including the first group of containers and the second group of containers; upon receiving a target notification message sent by the first container system, sending a second instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables, wherein the target notification message is used to indicate that the first container system has completed the configuration of the set of environment variables, and the target control instruction includes the first instruction and the second instruction.
[0008] In one exemplary embodiment, the method further includes: upon receiving the target switching instruction, issuing a third instruction to the first database to instruct the first database to switch to a target state, wherein the first database is a database corresponding to the first container system, and the target state is used to indicate a state in which the first database is allowed to be read and written.
[0009] In one exemplary embodiment, the first set of containers includes an application container, and the second set of containers includes a public container, wherein the application container is used to provide application services, and the public container is used to provide public services.
[0010] According to another embodiment of the present invention, a control method for a container system is also provided, comprising: receiving a target control instruction issued by a target scheduling platform, wherein the target control instruction is issued by the target scheduling platform to a first container system upon receiving a target switching instruction, the target switching instruction being used to indicate switching to the first container system in the event of a failure in a second container system; restarting a first group of containers and a first group of external service processes based on the target control instruction, wherein the first group of external service processes includes external service processes corresponding to each container in the first group of containers, and before the target scheduling platform receives the target switching instruction, the first container system is configured to pre-start a second group of containers and a second group of external service processes, the second group of external service processes including external service processes corresponding to each container in the second group of containers.
[0011] In one exemplary embodiment, the method further includes: pre-starting the second group of containers and the second group of external service processes before receiving the target control instruction issued by the target scheduling platform.
[0012] In an exemplary embodiment, receiving the target control instruction issued by the target scheduling platform includes: receiving a first instruction issued by the target scheduling platform and configuring a set of environment variables based on the first instruction, wherein the set of environment variables includes environment variables of each container in the target container set of the first container system, the environment variables being used to represent the service status of the container, the target container set including the first group of containers and the second group of containers; sending a target notification message to the target scheduling platform when it is determined that the set of environment variables has been configured; receiving a second instruction issued by the target scheduling platform, wherein the second instruction is used to instruct the first container system to restart the first group of containers and the first group of external service processes, and to take effect the set of environment variables, the target control instruction including the first instruction and the second instruction; restarting the first group of containers and the first group of external service processes based on the target control instruction includes: restarting the first group of containers and the first group of external service processes based on the second instruction, and taking effect the set of environment variables.
[0013] In one exemplary embodiment, the first set of containers includes an application container, and the second set of containers includes a public container, wherein the application container is used to provide application services, and the public container is used to provide public services.
[0014] According to another embodiment of the present invention, a control device for a container system is also provided, comprising: a first control module, configured to issue a target control instruction to a first container system upon receiving a target switching instruction, to instruct the first container system to restart a first group of containers and a first group of external service processes, wherein the target switching instruction is configured to instruct a switch to the first container system in the event of a failure in a second container system, the first group of external service processes includes external service processes corresponding to each container in the first group of containers, and before receiving the target switching instruction, the first container system is configured to pre-start a second group of containers and a second group of external service processes, the second group of external service processes including external service processes corresponding to each container in the second group of containers.
[0015] According to another embodiment of the present invention, a control device for a container system is also provided, comprising: a receiving module, configured to receive a target control instruction issued by a target scheduling platform, wherein the target control instruction is issued by the target scheduling platform to a first container system upon receiving a target switching instruction, the target switching instruction being used to indicate switching to the first container system in the event of a failure in the second container system; and a restart module, configured to restart a first group of containers and a first group of external service processes based on the target control instruction, wherein the first group of external service processes includes external service processes corresponding to each container in the first group of containers, and before the target scheduling platform receives the target switching instruction, the first container system is configured to pre-start a second group of containers and a second group of external service processes, the second group of external service processes including external service processes corresponding to each container in the second group of containers.
[0016] According to yet another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0017] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0018] This invention, upon receiving a target switchover instruction, issues a target control instruction to a first container system to instruct it to restart a first group of containers and a first group of external service processes. The target switchover instruction indicates a switchover to the first container system should a second container system fail. The first group of external service processes includes the external service processes corresponding to each container in the first group. Before receiving the target switchover instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes the external service processes corresponding to each container in the second group. In other words, when the second container system fails, a target control instruction is issued to the first container system, switching to it and controlling the first container system to restart the first group of containers and the first group of external service processes. Furthermore, since the second group of containers and the second group of external service processes in the first container system are pre-started before the switchover, this avoids the problem in related technologies where switching between different container systems requires starting all container services in each location, resulting in a long switchover time. Therefore, this invention solves the technical problem of long switchover times and low efficiency in related technologies, achieving the effect of improving container system switchover efficiency. Attached Figure Description
[0019] Figure 1 This is a mobile terminal hardware structure block diagram of the control method of the container system according to an embodiment of the present invention;
[0020] Figure 2 This is a flowchart of a control method for a container system according to an embodiment of the present invention;
[0021] Figure 3 This is a flowchart of another control method for a container system according to an embodiment of the present invention;
[0022] Figure 4 This is a schematic diagram of the switching process for container-type systems according to an embodiment of the present invention;
[0023] Figure 5 This is a schematic diagram illustrating the arrangement of switching steps in a container-type system according to an embodiment of the present invention;
[0024] Figure 6 This is a structural block diagram of a control device for a container system according to an embodiment of the present invention;
[0025] Figure 7 This is a structural block diagram of a control device for a container system according to an embodiment of the present invention. Detailed Implementation
[0026] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0028] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a mobile terminal hardware structure block diagram of the control method for the container system according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1The different configurations shown.
[0029] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the control method of the container system in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0031] This embodiment provides a control method for a container system. Figure 2 This is a flowchart of a control method for a container system according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0032] Step S202: Upon receiving a target switching instruction, a target control instruction is sent to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes. The target switching instruction is used to instruct the system to switch to the first container system in the event of a failure in the second container system. The first group of external service processes includes the external service process corresponding to each container in the first group of containers. Before receiving the target switching instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes the external service process corresponding to each container in the second group of containers.
[0033] Through the above steps, upon receiving a target switchover instruction, a target control instruction is issued to the first container system to instruct it to restart the first group of containers and the first group of external service processes. The target switchover instruction indicates a switchover to the first container system should the second container system fail. The first group of external service processes includes the external service processes corresponding to each container in the first group. Before receiving the target switchover instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes the external service processes corresponding to each container in the second group. In other words, when the second container system fails, a target control instruction is issued to the first container system to switch to it and control the restart of the first group of containers and the first group of external service processes. Furthermore, the second group of containers and the second group of external service processes in the first container system are pre-started before the switchover, avoiding the problem of long switchover times caused by starting all container services in each local container system during cross-regional container system switchovers in related technologies. Therefore, this solves the technical problem of long switchover times and low efficiency in related technologies, achieving the effect of improving container system switchover efficiency.
[0034] The entity executing the above steps can be a platform, such as a switching scheduling platform, a device, or a controller, such as a controller or processor in a storage management device, or an application control program in the device, or a processor with human-computer interaction capabilities configured on the storage device, or a processing device or processing unit with similar processing capabilities, etc., but not limited to these.
[0035] In the above embodiments, taking the switching scheduling platform performing the above operations as an example, both the first container system (or the first container management platform) and the second container system (or the second container management platform) are uniformly scheduled by the switching scheduling platform. The first container system and the second container system can be container systems in different locations, such as container systems (or management platforms) belonging to different regions. When the switching scheduling platform receives the target switching instruction, it sends a target control instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes. The target switching instruction can be triggered when the second container system fails. For example, the target switching instruction can be triggered by the second container system and sent to the switching scheduling platform, or it can be sent to the switching scheduling platform when other monitoring systems or monitoring platforms detect that the second container system has failed. Before the switching scheduling platform receives the target switching instruction, the first container system is set to pre-start. The first container system pre-starts the second group of containers and the second group of external service processes when the second container system is functioning correctly. The second group of containers can be public containers, and the first group of containers can be application containers. Each container in the first group corresponds to one external service process, and similarly, each container in the second group also corresponds to one external service process. In this embodiment, the second group of containers and the second group of external service processes are pre-started in the first container system before the second container system fails. Therefore, when the second container system fails, and the switching scheduling platform issues a target control command to the first container system, the first container system only needs to restart the first group of containers and the first group of external service processes. This reduces the switching time and avoids the problem in related technologies where switching between different container systems requires starting all container services in each location, resulting in a long switching time. Therefore, this solves the technical problem of long switching times and low efficiency in related technologies, achieving the effect of improving the switching efficiency of container systems.
[0036] In an optional embodiment, the method further includes: controlling the first container system to pre-start the second group of containers and the second group of external service processes before receiving the target switching instruction. In this embodiment, taking the switching scheduling platform performing the above operation as an example, controlling the first container system to pre-start the second group of containers and the second group of external service processes before receiving the target switching instruction can be optionally achieved by the switching scheduling platform issuing instructions to the first container system to pre-start the second group of containers and the second group of external service processes. Alternatively, according to a pre-defined plan, the switching scheduling platform may not need to issue specific instructions; the first container system may automatically start the second group of containers and the second group of external service processes while the second container system is running normally. The second group of containers can be common containers within the first container system. Through this embodiment, controlling the first container system to pre-start the second group of containers and the second group of external service processes before the second container system fails allows for a rapid switch to the first container system and quick service startup in the event of a failure.
[0037] In an optional embodiment, issuing a target control instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes includes: issuing a first instruction to the first container system to instruct the first container system to configure a set of environment variables, wherein the set of environment variables includes environment variables of each container in the target container set of the first container system, the environment variables being used to represent the service status of the container, the target container set including the first group of containers and the second group of containers; upon receiving a target notification message sent by the first container system, sending a second instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables, wherein the target notification message is used to indicate that the first container system has completed the configuration of the set of environment variables, and the target control instruction includes the first instruction and the second instruction.
[0038] In the above embodiments, a first instruction can be issued to the first container system to instruct it to configure a set of environment variables. For example, the set of environment variables may include the environment variables of all containers in the first container system. The environment variables can represent the service status of the containers. For example, environment variable Y indicates service status (or production status), and environment variable N indicates disaster recovery status (or standby status). If the target container set in the first container system includes 100 containers, then the set of environment variables includes the environment variables corresponding to each of the 100 containers. After the first container system configures the above set of environment variables, it will send a target notification message to the switching scheduling platform. When the switching scheduling platform receives the target notification message, it issues a second instruction to the first container system to instruct the second container system to restart the first group of containers and the first group of external service processes, and simultaneously activate the above set of environment variables. In practical applications, when the first container system receives the second instruction, it can start the container through the tini process manager. This process will generate one and only one child process and wait for the child process to exit, harvest zombie processes, and perform signal forwarding. When the production state / disaster recovery state identifier changes, the tini process needs to be killed and the container restarted to make the flag take effect, and the container switches from disaster recovery state to production state. This embodiment achieves the purpose of controlling the configuration of a set of environment variables for the first container system, and restarting the first group of containers and the first group of external service processes to make the set of environment variables effective.
[0039] In an optional embodiment, the method further includes: upon receiving the target switching instruction, issuing a third instruction to the first database to instruct the first database to switch to the target state, wherein the first database is the database corresponding to the first container system, and the target state is used to indicate the state in which the first database is allowed to be read and written. In this embodiment, when the switching scheduling platform receives the target switching instruction, it can also issue a third instruction to the first database to instruct the first database to switch to the target state. In practical applications, a database (such as the first database mentioned above) is built on the first container system side, and a database (such as the second database) is also built on the second container system side. When the second container system does not fail, the second database is in production state (or service state), that is, the second database is in an enabled state, while the first database is in disaster recovery state (or standby state). When the second container system fails, the primary and standby roles between the first database and the second database can be swapped, that is, the first database is enabled, for example, the state of the first database is set to a read-write state. Through this embodiment, the purpose of enabling the first database is achieved by issuing a third instruction to the first database when the second container system fails.
[0040] In an optional embodiment, the first group of containers includes application containers, and the second group of containers includes public containers. The application containers are used to provide application services, and the public containers are used to provide public services. In this embodiment, the first group of containers can be application containers, for example, application containers are used to provide application-related services; the second group of containers can be public containers, for example, public containers provide public services such as security, monitoring, and batch scheduling for the system.
[0041] This embodiment also provides another control method for a container system. Figure 3 This is a flowchart of another control method for a container system according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:
[0042] Step S302: Receive target control instructions issued by the target scheduling platform, wherein the target control instructions are issued by the target scheduling platform to the first container system upon receiving a target switching instruction, and the target switching instruction is used to indicate switching to the first container system in the event of a failure in the second container system.
[0043] Step S304: Restart the first group of containers and the first group of external service processes based on the target control instruction. The first group of external service processes includes the external service process corresponding to each container in the first group of containers. Before the target scheduling platform receives the target switching instruction, the first container system is set to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes the external service process corresponding to each container in the second group of containers.
[0044] Through the above steps, by receiving target control instructions from the target scheduling platform—specifically, the target control instructions issued by the target scheduling platform upon receiving a target switchover instruction—the first container system restarts the first group of containers and the first group of external service processes based on the target control instructions. Before the target scheduling platform receives the target switchover instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. That is, when the second container system fails, the first container system receives the target control instructions from the target scheduling platform, which control the restart of the first group of containers and the first group of external service processes to switch to the first container system. Furthermore, the second group of containers and the second group of external service processes in the first container system are pre-started before the switchover, avoiding the problem of long switchover times caused by the need to start all container services in each local container system during cross-regional container system switchovers in related technologies. Therefore, this solves the technical problem of long switchover times and low efficiency in related technologies, achieving the effect of improving container system switchover efficiency.
[0045] The entity executing the above steps can be a container system, such as the first container system or the first container management platform, but is not limited to these.
[0046] In the above embodiments, taking the first container system performing the above operations as an example, both the first container system (or the first container management platform) and the second container system (or the second container management platform) are uniformly scheduled by the target scheduling platform. The first container system and the second container system can be container systems in different locations, such as container systems (or management platforms) belonging to different regions. When the target scheduling platform (or switching scheduling platform) receives the target switching instruction, it sends a target control instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes. The target switching instruction can be triggered when the second container system fails. For example, the target switching instruction can be triggered by the second container system and sent to the switching scheduling platform, or it can be sent to the target scheduling platform when other monitoring systems or monitoring platforms detect that the second container system has failed. Before the target scheduling platform receives the target switching instruction, the first container system is... The system is configured to pre-start the second group of containers and the second group of external service processes. That is, when the second container system is functioning correctly, the first container system has already pre-started the second group of containers and the second group of external service processes. The second group of containers can be public containers, and the first group of containers can be application containers. Each container in the first group corresponds to one external service process, and similarly, each container in the second group also corresponds to one external service process. In this embodiment, before the second container system fails, the first container system has already pre-started the second group of containers and the second group of external service processes. Therefore, when the second container system fails, and the target scheduling platform issues a target control command to the first container system, the first container system only needs to restart the first group of containers and the first group of external service processes. This reduces the switching time and avoids the problem in related technologies where switching between different container systems requires starting all container services in each location, resulting in a long switching time. Therefore, this solves the technical problem of long switching times and low efficiency in related technologies, achieving the effect of improving the switching efficiency of container systems.
[0047] In an optional embodiment, the method further includes: pre-starting the second group of containers and the second group of external service processes before receiving the target control instruction issued by the target scheduling platform. In this embodiment, the first container system pre-starts the second group of containers and the second group of external service processes before receiving the target control instruction issued by the target scheduling platform. Optionally, the target scheduling platform can control the first container system to pre-start the second group of containers and the second group of external service processes by issuing instructions to the first container system. Alternatively, according to a pre-defined plan, the target scheduling platform can be refrained from issuing specific instructions, and the first container system can automatically start the second group of containers and the second group of external service processes while the second container system is running normally. The second group of containers can be common containers within the first container system. Through this embodiment, the first container system pre-starts the second group of containers and the second group of external service processes before the second container system fails, thus enabling a rapid switch to the first container system and rapid service startup in the event of a failure.
[0048] In an optional embodiment, receiving the target control instruction issued by the target scheduling platform includes: receiving a first instruction issued by the target scheduling platform and configuring a set of environment variables based on the first instruction, wherein the set of environment variables includes environment variables of each container in the target container set of the first container system, the environment variables being used to represent the service status of the container, the target container set including the first group of containers and the second group of containers; sending a target notification message to the target scheduling platform when it is determined that the set of environment variables has been configured; receiving a second instruction issued by the target scheduling platform, wherein the second instruction is used to instruct the first container system to restart the first group of containers and the first group of external service processes, and to take effect the set of environment variables, the target control instruction including the first instruction and the second instruction; restarting the first group of containers and the first group of external service processes based on the target control instruction includes: restarting the first group of containers and the first group of external service processes based on the second instruction, and taking effect the set of environment variables.
[0049] In the above embodiment, the first container system first receives a first instruction issued by the target scheduling platform, and configures a set of environment variables based on the first instruction. For example, the set of environment variables may include the environment variables of all containers in the first container system. The environment variables may represent the service status of the containers. For example, environment variable Y indicates service status (or production status), and environment variable N indicates disaster recovery status (or standby status). If the target container set in the first container system includes 100 containers, then the set of environment variables includes the environment variables corresponding to each of the 100 containers. After the first container system has configured the above set of environment variables, it will send a target notification message to the target scheduling platform. When the target scheduling platform receives the target notification message, it issues a second instruction to the first container system. The second instruction is used to instruct the restart of the first group of containers and the first group of external service processes, and to take effect the above set of environment variables. The first container system restarts the first group of containers and the first group of external service processes based on the second instruction, and applies a set of environment variables. In practical applications, when the first container system receives the second instruction, it can start the container through the tini process manager. This process will generate one and only one child process, wait for the child process to exit, harvest zombie processes, and perform signal forwarding. When the production state and disaster recovery state identifiers change, it is necessary to kill the tini process and trigger the container restart to make the flags take effect, and the container switches from the disaster recovery state to the production state. Through this embodiment, the first container system achieves the purpose of configuring a set of environment variables based on the first instruction, and achieves the purpose of restarting the first group of containers and the first group of external service processes and applying a set of environment variables based on the second instruction.
[0050] In an optional embodiment, the first group of containers includes application containers, and the second group of containers includes public containers. The application containers are used to provide application services, and the public containers are used to provide public services. In this embodiment, the first group of containers can be application containers, for example, application containers are used to provide application-related services; the second group of containers can be public containers, for example, public containers provide public services such as security, monitoring, and batch scheduling for the system.
[0051] Obviously, the embodiments described above are only some embodiments of the present invention, and not all embodiments. The present invention will be specifically described below with reference to the embodiments.
[0052] In related technologies, off-site container switching uses a localized container management platform to start and stop pod-level services of the local container system, thereby stopping the service of the fault center container system (corresponding to the aforementioned second container system), starting the service of the disaster recovery center container system (corresponding to the aforementioned first container system), and taking over the service off-site.
[0053] Furthermore, the technical solutions in related technologies often complete the switchover by manually issuing commands to containers at both ends, lacking a unified command scheduling platform for issuing commands to locally managed clusters. During startup and shutdown, the container system is started and stopped at the service and pod levels. During service startup and shutdown, existing resources need to be released and the basic environment needs to be rebuilt. When restarting at the container level, some resources do not need to be rebuilt. When starting and stopping at the service or pod level, all containers under the pod service need to be started and stopped together, which lacks flexibility. Because some containers can remain running indefinitely during the switchover process without additional startup and shutdown operations, some containers with long startup times will slow down the overall service startup time, resulting in a longer switchover time.
[0054] To address the challenges in the switching process of related technologies, this invention proposes a method for rapid remote switching of containerized systems. By employing a unified scheduling platform, pre-configured switching procedures, and keeping disaster recovery containers running continuously, the switching time is optimized, ensuring that containerized systems can quickly switch to remote disaster recovery operation when they are unavailable locally.
[0055] To address system failures in regional disaster scenarios, containerized systems are built for off-site disaster recovery. Recovery Time Objective (RTO) is a crucial indicator for evaluating off-site disaster recovery capabilities. How to ensure rapid startup of containerized systems in disaster scenarios is a key concern. Currently, containerized system startup time includes application, database, and middleware startup times. To shorten container startup time, this paper analyzes the reasons for long startup times of specific nodes and designs a rapid container startup method.
[0056] (Describe the following aspects: 1. Shorten the switchover time by pre-starting the disaster recovery container but not starting external services. 2. The service startup time should be longer than the container restart time. Control the startup of the disaster recovery container to either disaster recovery or production state by modifying the configuration group environment variables and actively triggering the container restart process. 3. Describe the entire switchover process.)
[0057] The startup time of containerized systems includes: Service startup time: Application services include a common container (a sidecar container). The common container provides public services such as security, monitoring, and batch scheduling for the system. The application container provides application-related services. There is a dependency between the application container and the common container; the application container starts only after the common container starts successfully. Database switchover time: Containerized systems have databases built in two locations. Data synchronization between the databases is completed through a database synchronization mechanism. Under normal circumstances, the production database synchronizes data to the disaster recovery database. Normally, the production database is in a read-write state, while the disaster recovery database is read-only. During the switchover process, the disaster recovery database needs to be enabled and its state set to read-write.
[0058] Starting a containerized system involves two processes: starting the pod (POD) and starting the container. The former takes longer, while the latter is faster. To shorten the switchover time for containerized systems, disaster recovery containers are typically started in advance, but the processes providing services to the outside world are not started. During the switchover process, pre-starting can reduce the switchover time. During the switchover, it is not necessary to start the pod or restart the container to enable the service to start.
[0059] In failover scenarios, if some components function normally but the problem cannot be resolved under a single data center, it's necessary to stop some services on the faulty side to prevent data from being mistakenly forwarded to the fault center, causing service interruption. In drill scenarios, corresponding operations also need to be performed on production containers to prevent traffic from being mistakenly sent to the production site. Container management platforms are all in local management mode; failover requires calling services in both locations, necessitating the upstream system's ability to issue commands to both container management platforms. This system can issue commands to both container management clusters, and the failover scheduling platform can issue commands to the production container management platform, disaster recovery container management platform, and production / disaster recovery database cluster, completing the system database and application-level failover. This ensures rapid remote takeover under application and database failure conditions.
[0060] Figure 4 This is a schematic diagram of the switching process for container-type systems according to an embodiment of the present invention, such as... Figure 4 As shown, the container switching process mainly includes: modifying the container status under different services, setting application containers and public containers from daily disaster recovery state to production state. Production state indicates that external services are started, while disaster recovery state indicates that external services are not started, but both will have containers running. To make this flag effective, the container needs to be started via the tini process manager. This process will generate one and only one child process, wait for the child process to exit, harvest zombie processes, and perform signal forwarding. When the production or disaster recovery state flag changes, the tini process needs to be killed, triggering a container restart to make the flag effective, and the container switches from disaster recovery state to production state.
[0061] It should be noted that, Figure 4The switching scheduling platform issues instructions to the production-side container management platform (corresponding to the aforementioned second container system) to set the production-side containers to disaster recovery mode, and issues instructions to the disaster recovery-side container management platform (corresponding to the aforementioned first container system) to set the disaster recovery-side containers to production mode. The switching scheduling platform also issues instructions to the databases (including the first database and the second database), where the first database is the database built for the disaster recovery side and the second database is the database built for the production side. The timing of the switching scheduling platform issuing instructions to the production-side and disaster recovery-side container management platforms is not sequential; similarly, there is no strict order for issuing instructions to the databases. Subsequently, instructions are sent to the database to switch the primary / backup relationship between the first and second databases. For example, under normal circumstances, the containers managed by the production-side container management platform are in production mode, and the corresponding second database is in read-write mode. The first database, as the disaster recovery database, is normally in read-only mode, and data is synchronized from the production-side second database to the disaster recovery first database. However, when the production-side container management platform (or container system) fails, it is necessary to switch to the disaster recovery container management platform. At this time, the state of the first database needs to be changed to read-write mode, that is, the disaster recovery first database is activated.
[0062] Switching between containerized systems involves multiple steps. These steps are pre-programmed within the system and deployed to container management systems in both locations with a single click, enabling rapid switching. Key steps include: setting the production container service to disaster recovery mode, swapping the primary and backup roles of the database, and setting the disaster recovery service to production mode. Services include public service containers and application service containers, each with corresponding status indicators. Different containers within the same pod can have their status controlled independently, ensuring independent state control for each container within a pod and providing flexibility for different containers to be in different states. Figure 5 This is a schematic diagram of the switching steps for a container-type system according to an embodiment of the present invention, including:
[0063] S502, cease production application services and public services;
[0064] S504, Disaster recovery database status modified;
[0065] S506, Modify the public service status identifier and application service status identifier of the disaster recovery terminal;
[0066] S508, restart the public service container to start external services;
[0067] S510, restart the application service container to start external services.
[0068] In the above embodiments, a method for quickly switching between remote container systems is proposed, providing a switching control device that can pre-set the switching process within the device and distribute it to container management platforms in both locations; in addition, by starting containers through the tini process, the service status can be controlled at the container granularity, reducing startup time.
[0069] Through the embodiments of the present invention, it is possible to quickly switch containerized systems to remote disaster recovery operation when they are unavailable locally, thereby achieving the goal of rapid remote takeover.
[0070] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0071] This embodiment also provides a control device for a container system. Figure 6 This is a structural block diagram of a control device for a container system according to an embodiment of the present invention, such as... Figure 6 As shown, the device includes:
[0072] The first control module 602 is configured to issue a target control instruction to the first container system upon receiving a target switching instruction, instructing the first container system to restart the first group of containers and the first group of external service processes. The target switching instruction is used to instruct switching to the first container system in the event of a failure in the second container system. The first group of external service processes includes external service processes corresponding to each container in the first group of containers. Before receiving the target switching instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes external service processes corresponding to each container in the second group of containers.
[0073] In an optional embodiment, the above apparatus further includes: a second control module, configured to control the first container system to pre-start the second group of containers and the second group of external service processes before receiving the target switching instruction.
[0074] In an optional embodiment, the first control module 602 includes: a first processing unit, configured to issue a first instruction to the first container system to instruct the first container system to configure a set of environment variables, wherein the set of environment variables includes environment variables of each container in a target container set in the first container system, the environment variables being used to represent the service status of the container, and the target container set including the first group of containers and the second group of containers; and a second processing unit, configured to, upon receiving a target notification message sent by the first container system, send a second instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables, wherein the target notification message is used to indicate that the first container system has completed the configuration of the set of environment variables, and the target control instruction includes the first instruction and the second instruction. In this embodiment,
[0075] In an optional embodiment, the above apparatus further includes: a third control module, configured to issue a third instruction to the first database upon receiving the target switching instruction, to instruct the first database to switch to the target state, wherein the first database is a database corresponding to the first container system, and the target state is used to indicate the state in which the first database is allowed to be read and written.
[0076] In an optional embodiment, the first group of containers includes application containers, and the second group of containers includes public containers, wherein the application containers are used to provide application services, and the public containers are used to provide public services.
[0077] This embodiment also provides another control device for a container system. Figure 7 This is a structural block diagram of a control device for a container system according to an embodiment of the present invention, such as... Figure 7 As shown, the device includes:
[0078] The receiving module 702 is used to receive a target control instruction issued by the target scheduling platform. The target control instruction is issued by the target scheduling platform to the first container system when it receives a target switching instruction. The target switching instruction is used to indicate switching to the first container system in the event of a failure in the second container system.
[0079] The restart module 704 is used to restart the first group of containers and the first group of external service processes based on the target control instruction. The first group of external service processes includes external service processes corresponding to each container in the first group of containers. Before the target scheduling platform receives the target switching instruction, the first container system is set to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes external service processes corresponding to each container in the second group of containers.
[0080] In an optional embodiment, the above apparatus further includes: a startup module, configured to pre-start the second group of containers and the second group of external service processes before receiving the target control instruction issued by the target scheduling platform.
[0081] In an optional embodiment, the receiving module 702 includes: a third processing unit, configured to receive a first instruction issued by the target scheduling platform and configure a set of environment variables based on the first instruction, wherein the set of environment variables includes environment variables of each container in the target container set of the first container system, the environment variables being used to represent the service status of the container, and the target container set including the first group of containers and the second group of containers; a sending unit, configured to send a target notification message to the target scheduling platform when it is determined that the set of environment variables has been configured; and a receiving unit, configured to receive a second instruction issued by the target scheduling platform, wherein the second instruction is used to instruct the first container system to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables, the target control instruction including the first instruction and the second instruction; the restart module 704 includes: a fourth processing unit, configured to restart the first group of containers and the first group of external service processes based on the second instruction, and to activate the set of environment variables.
[0082] In an optional embodiment, the first group of containers includes application containers, and the second group of containers includes public containers, wherein the application containers are used to provide application services, and the public containers are used to provide public services.
[0083] It should be noted that each of the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: all the above modules are located in the same processor; or, each of the above modules is located in different processors in any combination.
[0084] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.
[0085] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0086] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0087] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0088] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.
[0089] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0090] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A control method for a container system, characterized in that, Applications in switching scheduling platforms include: Upon receiving a target switching instruction, a target control instruction is issued to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes. The target switching instruction is used to instruct the system to switch to the first container system in the event of a failure in the second container system. The first group of external service processes includes external service processes corresponding to each container in the first group of containers. Before receiving the target switching instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes external service processes corresponding to each container in the second group of containers. The step of issuing target control instructions to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes includes: A first instruction is issued to the first container system to instruct the first container system to configure a set of environment variables, wherein the set of environment variables includes the environment variables of each container in the target container set in the first container system, the environment variables being used to represent the service status of the container, and the target container set including the first group of containers and the second group of containers; Upon receiving a target notification message from the first container system, a second instruction is sent to the first container system to instruct it to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables. The target notification message indicates that the first container system has completed the configuration of the set of environment variables, and the target control instruction includes the first instruction and the second instruction.
2. The method according to claim 1, characterized in that, The method further includes: Before receiving the target switching instruction, the first container system is controlled to pre-start the second group of containers and the second group of external service processes.
3. The method according to claim 1, characterized in that, The method further includes: Upon receiving the target switching instruction, a third instruction is sent to the first database to instruct the first database to switch to the target state, wherein the first database is the database corresponding to the first container system, and the target state is used to indicate the state in which the first database is allowed to be read and written.
4. The method according to any one of claims 1 to 3, characterized in that, The first group of containers includes application containers, and the second group of containers includes public containers. The application containers are used to provide application services, and the public containers are used to provide public services.
5. A control method for a container system, characterized in that, Applied to the first container system, including: Receive target control instructions issued by the target scheduling platform, wherein the target control instructions are issued by the target scheduling platform to the first container system upon receiving a target switching instruction, and the target switching instruction is used to indicate switching to the first container system in the event of a failure in the second container system; Based on the target control instruction, the first group of containers and the first group of external service processes are restarted. The first group of external service processes includes the external service process corresponding to each container in the first group of containers. Before the target scheduling platform receives the target switching instruction, the first container system is set to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes the external service process corresponding to each container in the second group of containers. The step of receiving the target control instruction issued by the target scheduling platform includes: receiving a first instruction issued by the target scheduling platform and configuring a set of environment variables based on the first instruction, wherein the set of environment variables includes environment variables of each container in the target container set of the first container system, the environment variables being used to represent the service status of the container, the target container set including the first group of containers and the second group of containers; sending a target notification message to the target scheduling platform when it is determined that the set of environment variables has been configured; and receiving a second instruction issued by the target scheduling platform, wherein the second instruction is used to instruct the first container system to restart the first group of containers and the first group of external service processes, and to take effect the set of environment variables, the target control instruction including the first instruction and the second instruction; The step of restarting the first group of containers and the first group of external service processes based on the target control instruction includes: restarting the first group of containers and the first group of external service processes based on the second instruction, and applying the set of environment variables.
6. The method according to claim 5, characterized in that, The method further includes: Before receiving the target control command issued by the target scheduling platform, the second group of containers and the second group of external service processes are started in advance.
7. The method according to any one of claims 5 to 6, characterized in that, The first group of containers includes application containers, and the second group of containers includes public containers. The application containers are used to provide application services, and the public containers are used to provide public services.
8. A control device for a container system, characterized in that, include: A first control module is configured to issue a target control instruction to a first container system upon receiving a target switching instruction, instructing the first container system to restart a first group of containers and a first group of external service processes. The target switching instruction is used to instruct switching to the first container system in the event of a failure in the second container system. The first group of external service processes includes external service processes corresponding to each container in the first group of containers. Before receiving the target switching instruction, the first container system is configured to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes external service processes corresponding to each container in the second group of containers. The first control module is further configured to issue a first instruction to the first container system to instruct the first container system to configure a set of environment variables, wherein the set of environment variables includes environment variables of each container in the target container set of the first container system, the environment variables being used to represent the service status of the container, and the target container set including the first group of containers and the second group of containers; upon receiving a target notification message sent by the first container system, the module sends a second instruction to the first container system to instruct the first container system to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables, wherein the target notification message is used to indicate that the first container system has completed the configuration of the set of environment variables, and the target control instruction includes the first instruction and the second instruction.
9. A control device for a container system, characterized in that, include: The receiving module is used to receive target control instructions issued by the target scheduling platform. The target control instructions are issued by the target scheduling platform to the first container system when it receives a target switching instruction. The target switching instruction is used to indicate switching to the first container system in the event of a failure in the second container system. The restart module is used to restart the first group of containers and the first group of external service processes based on the target control instruction. The first group of external service processes includes external service processes corresponding to each container in the first group of containers. Before the target scheduling platform receives the target switching instruction, the first container system is set to pre-start the second group of containers and the second group of external service processes. The second group of external service processes includes external service processes corresponding to each container in the second group of containers. The receiving module is further configured to receive a first instruction issued by the target scheduling platform, and configure a set of environment variables based on the first instruction. The set of environment variables includes environment variables for each container in the target container set of the first container system, and the environment variables represent the service status of the containers. The target container set includes the first group of containers and the second group of containers. Upon determining that the set of environment variables has been configured, the module sends a target notification message to the target scheduling platform. It also receives a second instruction issued by the target scheduling platform, wherein the second instruction instructs the first container system to restart the first group of containers and the first group of external service processes, and to activate the set of environment variables. The target control instruction includes the first instruction and the second instruction. Restarting the first group of containers and the first group of external service processes based on the target control instruction includes: restarting the first group of containers and the first group of external service processes based on the second instruction, and activating the set of environment variables.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 4 or 5 to 7.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 4 or 5 to 7.
Citation Information
Patent Citations
Container service disaster recovery method and device, production site and disaster recovery backup site
CN106598789A
Container arrangement method and system applied to Kubernetes
CN114816662A