I recently worked on the cloud platform and worked with another partner to develop php and java. The website is almost finished. Now we are building a java environment. At first we thought about many solutions. As sandbox isolation, cpu, memory restrictions, and some resource sharing are required, we finally decided to adopt lxc, the so-called lxc is system-level isolation. It can achieve the effect of virtual machines without any hardware configuration. Of course, it is not as isolated as vmware, however, this can also meet the various needs of my cloud platform ..
Step 1: Install lxc
Sudo apt-get install lxc
Note: When lxc is installed through apt-get In Ubuntu, other lxc dependent software, such as debootstrap, lvm2, and cgroup-lite, will be automatically installed.
Step 2: configure the lxc host
First, we will introduce several folders (the following files/folders will be automatically generated by default through apt-get installation)
/Etc/lxc/default. conf
If no configuration file is specified during container creation, the default. conf file is used by default as the configuration file of the container.
/Usr/share/lxc/templates/
The linux templates of various Release versions supported by LXC are stored in this directory, which usually include:
/Var/lib/lxc/
This directory is used to store container instances. By default, only the administrator can access and read files in this folder.
/Var/cache/lxc/
The first time you create a container, You need to download a mini version of the container system. It takes a long time to create a cache in this directory, when I create a new application directly using the cache, I do not need to download it online. For my needs, I prefer lxc-clone. Almost all application containers have the same configuration, therefore, cloning not only saves time but also saves a lot of configuration complexity.
Step 3: Check whether lxc has been installed
Lxc-verison
If lxc version: x. x. x is displayed, the installation is successful. Here, x indicates the version number. I installed lxc version: 0.9.0.
Lxc-checkconfig
It is reasonable to say that all options should be enable, but User namespace: missing. Don't worry, this has little impact. Some people say that Kernel configuration is a problem, while others say it only appears in ubuntu32-bit systems. The following section is written by a foreign blogger:
Linux container technology-LXC-related technical knowledge
Linux container technology-Analysis of the execution process of creating a virtual machine in LXC
Use shell scripts to monitor applications in the LXC application container
Cgroup and LXC (Linux container) Installation Details (CentOS 6.2) System
Linux container Virtual Technology LXC Concise Manual