- Introduction to Linux containers and OpenVZ
- OpenVZ Installation
- Installing kernel Mirroring
- Configuring Sysctl and installing related tools
- Reboot to OpenVZ kernel
- Easy to get Started
- Downloading a pre-prepared template can also be called mirroring
- Creating and Configuring container information
- Start running and use
Introduction to Linux containers and OpenVZ
The Linux container (Linux CONTAINER,LXC) is a lightweight, virtual runtime environment that works with traditional virtual machines
Different types. Traditional virtual machines need to abstract the hardware and provide a complete operating system, while LXC different
The place is that multiple containers share a set of kernel mechanisms with the system, and the containers provide only the files required by the running environment
Systems, virtual networks, and so on.
The specific architecture:
, the OpenVZ described in this article is the implementation of a container. There are other containers, such as the LXC tool (which can be used to create a LXC operating environment, Docker can be said to be based on the LXC tool), this blog will be in-depth analysis in succession.
OpenVZ for container technology practices earlier, many of the mechanisms used in the kernel to implement LXC are also out of their hands, and many of OpenVZ's features are now based on RHEL6 Kernel (kernel version 2.6.32) is modified, and some of the new features are not included in the mainstream kernel, so it is recommended to use the OPENVZ kernel to achieve better container characteristics such as isolation, snapshots, etc.
OpenVZ Installation
Debian7 (wheezy) version does not support OpenVZ by default (not known because of kernel version issues, or some other issues)
, but the OPENVZ team added support for Debian7, which we can install by installing the Linux kernel mirrors they provide
Like complete installation, refer to [1][3]
1. Install kernel image
As previously, you need to specifically install OPENVZ provided kernel images on DEBIAN7 to fully support OpenVZ, as follows:
1.1 Add source and update (root permission is required for operation below)
`# cat << EOF > /etc/apt/sources.list.d/openvz.list deb http://download.openvz.org/debian wheezy main deb http://download.openvz.org/debian wheezy-test main EOF # apt-get update`
1.2 Installing the kernel image
`# apt-get install linux-image-openvz-amd64 # apt-get install linux-image-openvz-686 (如果您仍然使用32位系统)`
2. Configuring sysctl and installing related tools
OpenVZ The kernel image is installed, the following configuration is required before rebooting
2.1 Some kernel parameters need to be configured to ensure the normal operation of OpenVZ, the configuration file is "/etc/sysctl.conf"
# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
# Enables source route verification
net.ipv4.conf.all.rp_filter = 1
# Enables the magic-sysrq key
kernel.sysrq = 1
# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
2.2 Tools to install some user space
# apt-get install vzctl vzquota ploop vzstats
3. Reboot to OpenVZ kernel
Configuration and related software are installed and need to reboot kernel to OpenVZ kernel
Easy to get Started
For such a Linux container that can provide a complete system run environment, of course you have to play with the play, quickly sit down and experience it. More references [2][4]
1. Download the pre-prepared template (also referred to as mirroring)
1.1 Download the template you need from the official website [5][6]
1.2 Move the downloaded template to the desired path
# mv ubuntu-14.04-x86.tar.gz /var/lib/vz/template/cache/
2. Creating and Configuring container information
# vzctl create CTID --ostemplate osname
# vzctl set CTID --hostname test --save
# vzctl set CTID --ipadd a.b.c.d --save
# vzctl set CTID --nameserver a.b.c.d --save
Such as:
# vzctl create 111 --ostemplate ubuntu-14.04-x86
# vzctl set 111 --hostname ubuntu --save
# vzctl set 111 --ipadd 192.168.2.233 --save
# vzctl set 111 --nameserver 202.201.0.131 --save
3. Start running and use
# vzctl start CTID
# vzctl exec CTID ps ax # Now the container is running!
# vzctl enter CTID
entered into container CTID
[container]# ...
[container]# exit
exited from container VEID
# vzctl stop CTID
# vzctl destroy CTID
Such as:
# vzctl start 111
# vzctl enter 111
[container]# do something (default is root)
[container]# exit
# vzctl stop 111
[1] Https://wiki.openvz.org/Installation_on_Debian
Http://openvz.livejournal.com/45345.html
[2] Https://wiki.openvz.org/Basic_operations_in_OpenVZ_environment
[3] Http://download.openvz.org/doc/openvz-intro.pdf
[4] Http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf
[5] http://download.openvz.org/template/precreated/
[6] Http://openvz.org/Download/template/precreated
Open source Linux Container OpenVZ Quick Start Guide