Open Source Linux Container OpenVZ Quick Start Guide __linux

Source: Internet
Author: User
Tags nameserver

Introduction to Linux containers and OpenVZ OpenVZ installation kernel mirroring configuration sysctl and installation related tools reboot to OpenVZ kernel download a prepared template can also be called mirror creation and configure container information to start running and use

Introduction to Linux containers and OpenVZ

The Linux container (Linux CONTAINER,LXC) is a lightweight virtual running environment, with traditional virtual machine side
Different type. 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 kernel mechanism with the system, and the container provides only the files needed to run the environment
System, virtual network and so on.

The specific architecture is shown in the figure:

As shown in the figure, the OpenVZ described in this article is a way to implement a container. There are other containers, such as LXC tool (this tool can be used to create LXC operating environment, Docker can be said to be based on LXC tool), the blog will be in the follow-up in-depth analysis.

OpenVZ for Container technology practice earlier, the kernel in the implementation of LXC many mechanisms are also from their hands, the current OpenVZ of many features are based on RHEL6 The kernel (kernel version is 2.6.32) is modified and some of the new features are not in the mainstream kernel, so it is recommended that you use the OpenVZ kernel for better container features such as isolation, snapshots, and so on. OpenVZ Installation

The Debian7 (wheezy) version does not support OpenVZ by default (it is not known because of kernel version problems or some other problems)
, but the OPENVZ team added support for Debian7, and we can install the Linux core mirrors they provide
Like complete installation, refer to [1][3] 1. Install kernel image

As previously owned, the kernel image provided on the DEBIAN7 requires a dedicated installation of OpenVZ to fully support OpenVZ, as follows:

1.1 Add source and update (root permissions are required for the following actions)

' # 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 kernel Mirroring

' # apt-get install linux-image-openvz-amd64
 # apt-get Install linux-image-openvz-686    (if you still use 32-bit system) '
2. Configure sysctl and install related tools

OpenVZ kernel mirroring is installed and requires the following configuration before rebooting

2.1 Some kernel parameters need to be configured to ensure the normal operation of the 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 don't 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 installation completed, need to restart the kernel to openvz the kernel simple

For such a can provide a complete system operating environment of the Linux container, of course, have to play with the play, quickly sit well experience it. More references [2][4] 1. Download a prepared template (also known 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. Create and configure 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--ostemplate ubuntu-14.04-x86
# Vzctl Set--hostname ubuntu--save
# Vzctl Set--ipadd 192.168.2.233--save
# Vzctl Set--nameserver 192.168.2.1--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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.