A method and apparatus for migrating host applications based on Linux containers
By deploying a Linux container cluster and migration console on the target machine, the challenge of migrating traditional existing applications to modern cloud architecture is solved, achieving efficient application-level migration and management and improving resource utilization.
Patent Information
- Application Number
- CN202310250069.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-13
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2043-03-13
AI Technical Summary
Existing technologies make it difficult to migrate traditional, existing applications that are difficult to containerize to modern container-based cloud infrastructure, especially due to a lack of understanding of the specific dependencies of the applications and the difficulty in modification.
By deploying a Linux container cluster on the target machine, using the migration console and agent service, information about the source machine is collected, the target container is created, and the root file system and application data of the source machine are migrated to the target Linux container, using a combination of LXD and LXC technologies for the migration.
It enables the smooth migration of traditional existing applications to Linux containers, supports orchestration and management on modern cloud infrastructure, and improves resource utilization and migration efficiency.
Smart Images

Figure CN116302529B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of container platform technology, specifically relating to a method and apparatus for migrating host applications based on Linux containers. Background Technology
[0002] Application migration refers to moving software applications from one IT system to another, and is generally divided into four categories: 1) Remanufacturing: directly moving an application from one platform to another without making major changes; 2) Refactoring: making major changes to the application to run in the new environment, such as splitting a monolithic application into microservices; 3) Platform Change: when migrating to a new environment, some modifications to the application are required; 4) Replacement: abandoning a certain application and using other solutions.
[0003] Application migration via remanufacturing typically involves moving applications from the source machine to a virtual machine, bare metal container, or container platform in the hosting environment. Containers, as a hosting technology, are more lightweight than virtual machines, enabling finer-grained resource isolation and further improving resource utilization. Compared to virtual machines, containers are more suitable for application orchestration due to their lightweight nature, fast startup, and lower resource consumption. Containers abstract an application execution environment on top of IaaS layer computing resources, facilitating migration between private, hybrid, and public clouds. For some legacy applications with traditional architectures, containerization is a challenge, often involving application transformation, application splitting, or even architectural adjustments. Some legacy applications are in a state of discontinuation, and users may not even be familiar with their specific dependencies (system calls, dynamic libraries, inter-process calls, etc.). These traditional legacy applications are difficult to migrate to application-level container platforms like Docker through image building, DevOps, etc. The difficulty in containerizing some traditional legacy applications hinders their migration to modern container-based cloud infrastructures. Summary of the Invention
[0004] The purpose of this invention is to provide a method and apparatus for migrating host applications based on Linux containers, so as to migrate existing applications that are difficult to containerize to Linux containers and build a modern cloud infrastructure.
[0005] To solve the above-mentioned technical problems, the present invention is implemented as follows:
[0006] In a first aspect, embodiments of the present invention provide a method for migrating host applications based on Linux containers, applicable to a system for migrating host applications based on Linux containers, the system comprising a source machine, a control machine, and a target machine, characterized in that it includes:
[0007] Deploy a Linux container cluster using LXD on the target machine;
[0008] The migration console is deployed on the control machine, and the login information of the source host is entered and a migration task is created on the migration console; a migration agent service is deployed on the source host through the migration console;
[0009] Create the target Linux container through the LXD interface of the Linux container cluster;
[0010] The target root file system, application data to be migrated, and the application itself are migrated from the source machine to the target Linux container.
[0011] Optionally, the creation of the migration task includes the following:
[0012] Determine the directory of the data to be migrated and the directory of the data to be excluded;
[0013] Configure the parameters of the target Linux container;
[0014] Configure migration parameters.
[0015] Optionally, after deploying the migration agent service on the source host via the migration console, and before migrating the target data from the source machine to the target Linux container, the method further includes:
[0016] The migration environment is assessed using the source host.
[0017] The evaluation of the migration environment through the source host includes the following:
[0018] Collect basic resource usage information of the source machine, check the migration parameters, and collect kernel information of the source machine.
[0019] Optionally, migrating the data to be migrated from the source machine to the target Linux container includes:
[0020] Create the mount namespace and a temporary directory, mount the data directory of the source host to the temporary directory, and mask the directory of the data to be excluded in the data directory to obtain the directory of the data to be migrated.
[0021] The data to be migrated is migrated to the target Linux container by using the target call parameters.
[0022] Optionally, after creating the mount namespace and temporary directory, the method further includes:
[0023] Mount the source host rootfs to the temporary directory;
[0024] The step of migrating the data to be migrated to the target Linux container via the target invocation parameters includes:
[0025] The data to be migrated is migrated to the directory where the rootfs of the target Linux container is located by using the target call parameters.
[0026] Optionally, after migrating the data to be migrated to the directory where the rootfs of the target Linux container is located via the target call parameters, the method further includes:
[0027] Report migration status information;
[0028] Once the migration of the data to be migrated to the directory where the rootfs of the target Linux container is located has been completed using the target call parameters, a termination command is issued through the migration console.
[0029] Optionally, after issuing the termination command via the migration console, the method further includes:
[0030] The migration console is used to clear the target files in the rootfs of the target Linux container;
[0031] Configure the network and adjust the configuration of the target application according to the operating system type within the target Linux container.
[0032] Optionally, after migrating the data to be migrated from the source machine to the target Linux container, the method further includes:
[0033] Perform the target operation on the target Linux container;
[0034] The target operations include the following: adjusting the CPU and memory of the target Linux container, passing the target device to the target Linux container, and backing up the data in the target Linux container.
[0035] Optionally, after migrating the target root file system, the application's data to be migrated, and the application from the source machine to the target Linux container, the method further includes:
[0036] Start the target Linux container.
[0037] Secondly, a migration device for host applications based on Linux containers, applied to a system for migrating host applications based on Linux containers, the system comprising a source machine, a control machine, and a target machine, including:
[0038] The first deployment module is used to deploy a Linux container cluster via LXD in the target machine;
[0039] The second deployment module is used to deploy a migration console through the control machine, enter the login information of the source host and create a migration task in the migration console, and deploy a migration agent service on the source host through the migration console.
[0040] A module is created to create a target Linux container through the LXD interface of the Linux container cluster;
[0041] The migration module is used to migrate the target root file system, application data to be migrated, and the application from the source machine to the target Linux container.
[0042] Optionally, the creation of the migration task includes the following:
[0043] Determine the directory of the data to be migrated and the directory of the data to be excluded;
[0044] Configure the parameters of the target Linux container;
[0045] Configure migration parameters.
[0046] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0047] The evaluation module is used to evaluate the migration environment through the source host;
[0048] The evaluation of the migration environment through the source host includes the following:
[0049] Collect basic resource usage information of the source machine, check the migration parameters, and collect kernel information of the source machine.
[0050] Optionally, the migration module is specifically used for:
[0051] Create the mount namespace and a temporary directory, mount the data directory of the source host to the temporary directory, and mask the directory of the data to be excluded in the data directory to obtain the directory of the data to be migrated.
[0052] The data to be migrated is migrated to the target Linux container by using the target call parameters.
[0053] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0054] The mount module is used to mount the source host rootfs to the temporary directory;
[0055] The migration module is specifically used for:
[0056] The data to be migrated is migrated to the directory where the rootfs of the target Linux container is located by using the target call parameters.
[0057] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0058] The reporting module is used to report migration status information;
[0059] Once the migration of the data to be migrated to the directory where the rootfs of the target Linux container is located has been completed using the target call parameters, a termination command is issued through the migration console.
[0060] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0061] The cleanup module is used to clear target files in the rootfs of the target Linux container via the migration console;
[0062] The configuration module is used to configure the network and adjust the configuration of the target application according to the operating system type within the target Linux container.
[0063] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0064] The execution module is used to perform target operations on the target Linux container;
[0065] The target operations include the following: adjusting the CPU and memory of the target Linux container, passing the target device to the target Linux container, and backing up the data in the target Linux container.
[0066] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0067] The startup module is used to start the target Linux container.
[0068] The advantages of this invention lie in its provision of a method and apparatus for migrating host applications based on Linux containers. This method and apparatus are applied to a system for migrating host applications using Linux containers. The system includes a source machine, a control machine, and a target machine. The method comprises: deploying a Linux container cluster via LXD on the target machine; deploying a migration console on the control machine and entering the login information of the source host and creating a migration task on the migration console; deploying a migration agent service on the source host via the migration console; creating a target Linux container via the LXD interface of the Linux container cluster; and migrating the target root file system, application data to be migrated, and the application itself from the source machine to the target Linux container. By migrating existing applications to Linux containers through the migration console and migration agent, this method facilitates the migration of existing applications that are difficult to containerize at the application level. Using Linux containers as a hosting technology facilitates the orchestration and management of upper-layer services, thus building a modern cloud infrastructure. Attached Figure Description
[0069] Figure 1 This is a flowchart illustrating a method for migrating a host application based on a Linux container, as provided in an embodiment of the present invention.
[0070] Figure 2 The figure shown is a schematic diagram of a system for migrating host applications based on Linux containers, provided in an embodiment of the present invention.
[0071] Figure 3 This is a schematic diagram of application migration provided in an embodiment of the present invention;
[0072] Figure 4 This is an overall flowchart of application migration provided by an embodiment of the present invention;
[0073] Figure 5 This is a schematic diagram of the service-bearing technology - Linux container - used in the embodiments of the present invention;
[0074] Figure 6 This is a schematic diagram of the structure of a host application migration device based on Linux containers provided in an embodiment of the present invention.
[0075] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0076] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0077] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and are not used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, the first object can be one or more.
[0078] To clearly describe this invention, the relevant definitions mentioned in this invention are explained and interpreted below:
[0079] Linux Containers (LXC) is a user-space interface for the Linux kernel's container functionality. It is an operating system-level virtualization technology that uses cgroups for resource isolation and PID namespaces, network namespaces, Mount namespaces, and user namespaces for process, network, file system, and user isolation. It provides a relatively independent runtime environment for application software and can be combined with technologies such as SELinux, AppArmor, and seccomp for container security.
[0080] Docker and similar containers, as application-level containers, contain the necessary dependencies for software operation. One container corresponds to one application, and the application's lifecycle is consistent with the container's. These application-level containers are generally used as a software deployment mechanism; when services are upgraded, the image is replaced to create a new container without performing the service upgrade within the existing container. Linux containers, as system-level containers, contain a complete operating system such as CentOS 7 or Ubuntu 20.04. Traditional configuration management and deployment tools can be directly used with Linux containers. Users can deploy multiple services within Linux containers and use systemd for background process management. The failure of a single process will not cause the container to exit, and it supports virtual machine-like power on / off and restart operations, providing an overall user experience very close to that of a virtual machine.
[0081] The user-space interface provided by Linux containers covers almost all container functions supported by the upstream kernel. These interfaces are very low-level and have a high learning curve. The Linux container hypervisor (LXD) manages Linux containers through libraries such as liblxc, providing user-friendly command-line tools and a REST API. It also offers basic network management, storage pool management, image management, and container snapshot functions. Users can create, update, back up, and migrate Linux containers through LXD, simplifying the use of Linux containers. LXD deployment supports both single-node and cluster modes. In cluster mode, LXD nodes use the dqlite distributed database for data storage, and nodes join the LXD cluster as members, forming a Linux container cluster.
[0082] The migration method for host applications based on Linux containers provided in this invention will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0083] Example 1
[0084] Reference Figure 1 The diagram illustrates a flowchart of a method for migrating a host application based on a Linux container, as provided in an embodiment of the present invention.
[0085] This invention provides a method for migrating host applications based on Linux containers, applicable to systems that migrate host applications using Linux containers. The system includes a source machine, a control machine, and a target machine, such as... Figure 2 The diagram shown is a schematic of a system for migrating host applications based on Linux containers, provided by an embodiment of the present invention. It consists of three parts: a source machine, a control machine, and a target machine. The method includes:
[0086] S101: Deploy a Linux container cluster using LXD on the target machine;
[0087] Specifically, for deploying an LXD environment on the target machine, a Linux container management interface is provided for the migration console to call. Here, a complete operating system runs inside the Linux container. Services within the container can use operating system functions such as process management, storage management, device management, and file system management. However, since Linux containers are essentially based on namespace isolation rather than virtualization like virtual machine management systems, additional configuration is required through LXD when managing devices such as disks and GPUs within the Linux container.
[0088] For example, Figure 3This is a schematic diagram of application migration provided by an embodiment of the present invention. The web service consists of Nginx, Tomcat, and MySQL, all located on the same source host. A three-node Linux container cluster is deployed using LXD. The LXD storage pool is mounted on LVM for future expansion, or a storage pool is built based on ZFS for disk size limitations. The Linux container network can be built based on technologies such as Bridge or MACVLAN. The container network and the host network are on the same plane, and Linux container management interfaces are exposed through LXD. This application is migrated to a three-node Linux container cluster, where Nginx and Tomcat are migrated to two Linux containers on node 1, and MySQL is migrated to a Linux container on node 2.
[0089] S102: Deploy a migration console through the control machine and enter the login information of the source host and create a migration task in the migration console; deploy a migration agent service on the source host through the migration console;
[0090] Specifically, after the Linux container cluster is deployed, a migration console is deployed on the control machine. The SSH login information for the host machine where the web service resides is entered; the login user must support root access without a password. The Linux container cluster LXD access address is configured in the migration console for managing the Linux container environment.
[0091] It should be noted that the source machine runs the existing application to be migrated and a migration agent service. The latter receives commands from the migration console and performs full migration and incremental synchronization based on technologies such as mount namespace, rsync, and inotify, reporting migration progress, logs, and monitoring metrics to the migration console. The migration console collects and analyzes the environment of the application to be migrated, describes the entire migration process through task flows, and provides task flow management functions.
[0092] After deployment is complete in the migration console, the environment preparation is considered complete, and the application migration step begins. First, migration tasks are created. For example, in the migration console, users create migration tasks at the application level. This example requires creating three migration tasks: Nginx, Tomcat, and MySQL. The user enters basic information for each migration task.
[0093] Optionally, the creation of the migration task includes the following: determining the directory of the data to be migrated and the directory of the data to be excluded, configuring the parameters of the target Linux container, and configuring the migration parameters.
[0094] Specifically, the directories to be migrated can be a list of directories to be migrated, such as migrating the root file system (rootfs) by default. If the business has data in the data directory (not the system disk), it needs to be specified. The directories to be excluded can be specific directories to exclude, such as excluding the MySQL installation directory and data directory on the same host machine when migrating Nginx. Parameters for configuring the target Linux container can include configuring the CPU, memory, and storage size required by the target Linux container, and selecting the eth0 network interface IP of the target Linux container. Migration parameters can include migration bandwidth limits, kernel requirements, etc.
[0095] Optionally, when there are multiple source hosts, the basic information for each migration task may also include specifying the source host to migrate.
[0096] The next step in the application migration process also requires deploying a migration agent service and conducting a migration environment assessment of the source host.
[0097] S103: Create the target Linux container through the LXD interface of the Linux container cluster;
[0098] Optionally, the LXD interface of the Linux cluster can be called to create a Linux container of type migration and mod type push; the rootfs of this type of container is empty and it is used specifically for migration.
[0099] S104: Migrate the target root file system, application data to be migrated, and the application from the source machine to the target Linux container.
[0100] Optionally, after migrating the target root file system, the application's data to be migrated, and the application from the source machine to the target Linux container, the method further includes: starting the target Linux container.
[0101] This invention utilizes a migration console and migration agent to migrate existing applications that are difficult to containerize to Linux containers. Using Linux containers as a hosting technology facilitates the orchestration and management of upper-layer services, enabling the construction of modern cloud infrastructure.
[0102] In one possible implementation, after step S103 and before step S104, the method further includes step S105:
[0103] S105: Evaluate the migration environment using the source host;
[0104] The evaluation of the migration environment through the source host includes the following:
[0105] Collect basic resource usage information of the source machine, check the migration parameters, and collect kernel information of the source machine.
[0106] Specifically, it collects basic resource usage information of the source machine, such as CPU, memory, bandwidth, and storage size, and reports it to the migration console for front-end display of resource monitoring information; it checks whether the migration parameters, such as the data directory, are correct; and it collects the kernel information of the source machine. For example, if a Linux container shares the host machine kernel, the source machine kernel information will be collected here and fed back to the console so that users can evaluate whether the target machine kernel meets the requirements.
[0107] In one possible implementation, step S104 can be performed by sub-steps S1041 to S1042:
[0108] S1041: Create the mount namespace and temporary directory, mount the data directory of the source host to the temporary directory, and mask the directory of the data to be excluded in the data directory to obtain the directory of the data to be migrated.
[0109] S1042: Migrate the data to be migrated to the target Linux container using the target call parameters.
[0110] In one possible implementation, step S1043 may be included after step S1041:
[0111] S1043: Mount the source host rootfs to the temporary directory;
[0112] The step of migrating the data to be migrated to the target Linux container via the target invocation parameters includes:
[0113] The data to be migrated is migrated to the directory where the rootfs of the target Linux container is located by using the target call parameters.
[0114] For example, create a mount namespace and a temporary directory, mount the source host's rootfs and data directory in read-only mode in the temporary directory, mask the directories that need to be excluded in the temporary directory, prepare the rsync call parameters, and use rsync to copy all files in the temporary directory to the target Linux container's rootfs directory; for example, if the target Linux container's rootfs is in the host machine directory / app / lxd / storage-pool / containers / nginx / rootfs and its contents are empty, rsync will copy all files in the source host's temporary directory to that directory on the target machine during the migration, and use it as the container's rootfs.
[0115] In one possible implementation, after migrating the data to be migrated to the directory where the rootfs of the target Linux container is located via the target call parameters, the method further includes:
[0116] Report migration status information;
[0117] Once the migration of the data to be migrated to the directory where the rootfs of the target Linux container is located has been completed using the target call parameters, a termination command is issued through the migration console.
[0118] Specifically, during the migration process, migration status information can be reported. After the main migration is completed, real-time synchronization is performed based on rsync+inotify, waiting for the migration console to issue a completion command.
[0119] In one possible implementation, after issuing the termination command via the migration console, the method further includes:
[0120] The migration console is used to clear the target files in the rootfs of the target Linux container;
[0121] Configure the network and adjust the configuration of the target application according to the operating system type within the target Linux container.
[0122] For example, before starting a Linux container, the migration console will perform some modifications to the container's rootfs, including clearing ` / etc / fstab`. Since the Linux container only has one rootfs at this point, the ` / etc / fstab` file copied from the source machine needs to be cleared to prevent container startup failure. It may also include identifying the Linux distribution type within the container, clearing the original network device configuration, and preparing the network configuration according to the container's network solution. For example, if using a bridge + static IP scheme, it might prepare the `ifcfg-eth0` network configuration file for CentOS.
[0123] In one possible implementation, before step S104, the method further includes step S106:
[0124] S106: Perform the target operation on the target Linux container;
[0125] The target operations include the following: adjusting the CPU and memory of the target Linux container, passing the target device to the target Linux container, and backing up the data in the target Linux container.
[0126] like Figure 4This is a flowchart illustrating the overall application migration process provided in this embodiment of the invention. After the migration is complete, business authentication is required to ensure the successful operation of the migrated application data. Specifically, the network identifiers and storage profiles of the Linux container and the source host change. The Linux container uses a new IP address and has only one rootfs with no other data disks mounted. If the application has dependencies, some application-side configuration adjustments are needed, such as the Tomcat address for accessing MySQL, or Linux container-side adjustments, such as mounting the host machine's data disk into the container via LXD. After the application is running normally, a cutover point is coordinated to complete the migration, thus completing the migration of the host application to the Linux container.
[0127] For applications, apart from IP address and other configurations, their operating environment (operating system and software dependencies, etc.) is almost identical to the original machine. Users can perform target operations on the target Linux container just like maintaining the host application, and maintain the application within the Linux container. For example, to upgrade the application, you can directly log in to the container to perform the upgrade.
[0128] Common operations and maintenance procedures that can be performed on the target Linux container include:
[0129] 1) CPU and memory adjustment: If vertical scaling is required, the CPU and memory limits of the Linux container can be adjusted without shutting down the container, and the changes take effect dynamically;
[0130] 2) Device pass-through: If users have requirements for devices such as data disks and GPUs, the corresponding devices on the host machine can be directly pass-through to the Linux container for application use;
[0131] 3) Backup and Recovery: In addition to application-level backups, users can also perform Linux container-level backups. A backup of the entire Linux container's rootfs can be created and restored to any Linux container environment based on this backup file.
[0132] 4) Linux container migration: If users need to migrate applications across hosts or even across clouds, migrating at the Linux container level is very convenient and fast. Linux containers support cold migration and hot migration based on criu.
[0133] like Figure 5 As shown, Linux containers, as an application runtime technology, offer a user experience closer to virtual machines compared to runtime technologies like Docker containers. Existing traditional applications require no modification and can be smoothly migrated to Linux container clusters running on various clouds based on this solution. This migration approach is highly seamless. Using Linux container technology facilitates subsequent deployment architecture evolution.
[0134] The following specific embodiment illustrates the overall process of a Linux container-based host application migration method provided by this invention:
[0135] Environment preparation: Prepare 3 virtual machines with 16GB of memory and 8 or more CPU cores to deploy a Linux container cluster using LXD; prepare 1 virtual machine with 4GB of memory and 2 CPU cores to deploy a demo service, such as Nginx+Tomcat+MySQL; prepare 1 virtual machine with 8GB of memory and 4 CPU cores to deploy the application migration platform.
[0136] Application Migration: Log in to the application migration platform, enter the migration parameters, and create migration tasks for Nginx, Tomcat, and MySQL; execute the migration tasks. After the migration tasks are completed, you will see that three new Linux containers have been added to the Linux container cluster, running Nginx, Tomcat, and MySQL respectively; log in to the Linux containers and modify the Nginx and Tomcat configurations, such as the Nginx backend service address and the address for Tomcat applications to access MySQL.
[0137] Business verification: Verify the basic functions of the application and end the migration task.
[0138] This invention migrates existing applications to Linux containers via a migration console and migration agent. This method is designed for traditional existing applications that are inconvenient to containerize at the application level, allowing them to be smoothly migrated to system-level containers. Compared to virtual machines, containers offer advantages such as faster start-up and shutdown, finer-grained resource isolation (easier to improve resource utilization), and finer-grained runtime support (easier to migrate and orchestrate). Furthermore, Linux containers are independent of cloud platforms, allowing for the abstraction of an application runtime layer on various cloud platforms. Applications based on this solution can be migrated in scenarios such as private clouds, hybrid clouds, and public clouds, facilitating a smooth transition in business deployment scenarios.
[0139] Example 2
[0140] Reference Figure 6 The diagram shows a schematic of the structure of a Linux container-based host application migration device 60 provided in an embodiment of the present invention.
[0141] A migration device 60 for host applications based on Linux containers, applied to a system for migrating host applications based on Linux containers, the system including a source machine, a control machine, and a target machine, comprising:
[0142] The first deployment module 601 is used to deploy a Linux container cluster via LXD in the target machine;
[0143] The second deployment module 602 is used to deploy a migration console through the control machine, enter the login information of the source host and create a migration task in the migration console, and deploy a migration agent service on the source host through the migration console.
[0144] Module 603 is created to create a target Linux container through the LXD interface of the Linux container cluster.
[0145] Migration module 604 is used to migrate the target root file system, application data to be migrated, and the application from the source machine to the target Linux container.
[0146] Optionally, the creation of the migration task includes the following:
[0147] Determine the directory of the data to be migrated and the directory of the data to be excluded;
[0148] Configure the parameters of the target Linux container;
[0149] Configure migration parameters.
[0150] Optionally, the migration apparatus 60 for migrating host applications based on Linux containers further includes:
[0151] Evaluation module 605 is used to evaluate the migration environment through the source host;
[0152] The evaluation of the migration environment through the source host includes the following:
[0153] Collect basic resource usage information of the source machine, check the migration parameters, and collect kernel information of the source machine.
[0154] Optionally, the migration module 604 is specifically used for:
[0155] Create the mount namespace and a temporary directory, mount the data directory of the source host to the temporary directory, and mask the directory of the data to be excluded in the data directory to obtain the directory of the data to be migrated.
[0156] The data to be migrated is migrated to the target Linux container by using the target call parameters.
[0157] Optionally, the migration apparatus 60 for migrating host applications based on Linux containers further includes:
[0158] Mount module 606 is used to mount the source host rootfs to the temporary directory;
[0159] The migration module 604 is specifically used for:
[0160] The data to be migrated is migrated to the directory where the rootfs of the target Linux container is located by using the target call parameters.
[0161] Optionally, the apparatus for migrating host applications based on Linux containers further includes:
[0162] Reporting module 607 is used to report migration status information;
[0163] Once the migration of the data to be migrated to the directory where the rootfs of the target Linux container is located has been completed using the target call parameters, a termination command is issued through the migration console.
[0164] Optionally, the migration apparatus 60 for migrating host applications based on Linux containers further includes:
[0165] The cleanup module 608 is used to clear the target files in the rootfs of the target Linux container through the migration console;
[0166] Configuration module 609 is used to configure the network and adjust the configuration of the target application according to the operating system type in the target Linux container.
[0167] Optionally, the migration apparatus 60 for migrating host applications based on Linux containers further includes:
[0168] Optionally, the migration apparatus 60 for migrating host applications based on Linux containers further includes:
[0169] Execution module 610 is used to perform target operations on the target Linux container;
[0170] The target operations include the following: adjusting the CPU and memory of the target Linux container, passing the target device to the target Linux container, and backing up the data in the target Linux container.
[0171] Optionally, the migration apparatus 60 for migrating host applications based on Linux containers further includes:
[0172] The startup module 611 is used to start the target Linux container.
[0173] The host application migration device 60 based on Linux containers provided in this embodiment of the invention can implement the various processes implemented in the above method embodiments. To avoid repetition, it will not be described again here.
[0174] In this embodiment of the invention, the first deployment module deploys a Linux container cluster via LXD on the target machine, the second deployment module deploys a migration console on the control machine, enters the login information of the source host and creates a migration task on the migration console, and deploys a migration agent service on the source host via the migration console. The creation module creates a target Linux container through the LXD interface of the Linux container cluster, and the migration module migrates the target root file system, the application's data to be migrated, and the application from the source machine to the target Linux container. By migrating existing applications to Linux containers through the migration console and migration agent, existing applications that are difficult to containerize at the application level are migrated to Linux containers. Using Linux containers as a hosting technology facilitates the orchestration and management of upper-layer services, thus building a modern cloud infrastructure.
[0175] The virtual system in this embodiment of the invention may be a device, or a component, integrated circuit, or chip in a terminal.
[0176] Furthermore, it should be noted that the device embodiments described above are merely illustrative and do not limit the scope of protection of this invention. In practical applications, those skilled in the art can select some or all of the modules to achieve the purpose of this embodiment according to actual needs, and no limitations are imposed here.
[0177] In addition, for technical details not described in detail in this embodiment, please refer to the migration method and apparatus for host applications based on Linux containers provided in any embodiment of the present invention, which will not be repeated here.
[0178] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for migrating host applications based on Linux containers, applied to a system for migrating host applications based on Linux containers, the system comprising a source machine, a control machine, and a target machine, characterized in that, The method includes: Deploy a Linux container cluster using LXD on the target machine; The migration console is deployed through the control machine, and the login information of the source machine is entered and a migration task is created through the migration console. The migration agent service is deployed on the source machine through the migration console. Create the target Linux container through the LXD interface of the Linux container cluster; Migrating the target root file system, the application's data to be migrated, and the application itself from the source machine to the target Linux container specifically includes: Create the mount namespace and a temporary directory, mount the data directory of the source host to the temporary directory, and mask the directories of the data to be excluded in the data directory to obtain the directories of the data to be migrated. The data to be migrated is migrated to the target Linux container using the target call parameters; After creating the mount namespace and temporary directory, the method further includes: Mount the source host rootfs to the temporary directory; The step of migrating the data to be migrated to the target Linux container via the target invocation parameters includes: The data to be migrated is migrated to the directory where the rootfs of the target Linux container is located by using the target call parameters; Report migration status information; After the migration of the data to be migrated to the directory where the rootfs of the target Linux container is located has been completed by using the target call parameters, a termination command is issued through the migration console. The migration console is used to clear the target files in the rootfs of the target Linux container; Configure the network and adjust the configuration of the target application according to the operating system type within the target Linux container.
2. The method according to claim 1, characterized in that, The creation of the migration task includes the following: Determine the directory of the data to be migrated and the directory of the data to be excluded; Configure the parameters of the target Linux container; Configure migration parameters.
3. The method according to claim 1, characterized in that, After deploying the migration agent service on the source machine via the migration console, and before migrating the target data from the source machine to the target Linux container, the method further includes: The migration environment is evaluated using the source machine; The evaluation of the migration environment through the source machine includes the following: Collect basic resource usage information of the source machine, check migration parameters, and collect kernel information of the source machine.
4. The method according to claim 1, characterized in that, After migrating the data to be migrated from the source machine to the target Linux container, the method further includes: Perform the target operation on the target Linux container; The target operations include the following: adjusting the CPU and memory of the target Linux container, passing the target device to the target Linux container, and backing up the data in the target Linux container.
5. The method according to claim 1, characterized in that, After migrating the target root file system, the application's data to be migrated, and the application from the source machine to the target Linux container, the method further includes: Start the target Linux container.
6. A migration apparatus for host applications based on Linux containers, applied to a system for migrating host applications based on Linux containers, the system comprising a source machine, a control machine, and a target machine, including: The first deployment module is used to deploy a Linux container cluster via LXD in the target machine; The second deployment module is used to deploy a migration console through the control machine, enter the login information of the source machine and create a migration task in the migration console, and deploy a migration agent service on the source machine through the migration console. A module is created to create a target Linux container through the LXD interface of the Linux container cluster; The migration module is used to migrate the target root file system, application data to be migrated, and the application from the source machine to the target Linux container, specifically including: Create the mount namespace and a temporary directory, mount the data directory of the source host to the temporary directory, and mask the directories of the data to be excluded in the data directory to obtain the directories of the data to be migrated. The data to be migrated is migrated to the target Linux container using the target call parameters; After creating the mount namespace and temporary directory, the following is also included: Mount the source host rootfs to the temporary directory; The step of migrating the data to be migrated to the target Linux container via the target invocation parameters includes: The data to be migrated is migrated to the directory where the rootfs of the target Linux container is located by using the target call parameters; Report migration status information; After the migration of the data to be migrated to the directory where the rootfs of the target Linux container is located has been completed by using the target call parameters, a termination command is issued through the migration console. The migration console is used to clear the target files in the rootfs of the target Linux container; Configure the network and adjust the configuration of the target application according to the operating system type within the target Linux container.
Citation Information
Patent Citations
Podman automatic migration system and method based on CRIU
CN112286640A
Moving application containers across compute nodes
US11281492B1