OpenVZ How to install? OpenVZ Installation Tutorial

Source: Internet
Author: User
Tags gpg domain name server centos nameserver virtual environment


Who doesn't know the famous OpenVZ? In the host industry has been used (abuse) for many years, is still healthy development. As an operating system-level virtualization technology, there are no hard hardware requirements for running OpenVZ. OpenVZ can create a virtualized environment called a container (containers). These virtual machines are not completely isolated (due to different language habits, or the "container" translation of "virtual machine" more easily understandable). One of the features of OpenVZ is that it's simple and almost without any hard overhead. There are virtual machines (such as memory or hard drives) that use resource constraints, but these restrictions are not rigid. So, you can allocate more resources to the virtual machines that are actually available. It is also one of the weaknesses of OpenVZ, which is easy to sell.
Whether you like it or not, OpenVZ is a great technology that creates a virtual environment that is almost without any hard overhead. But will you use it as a VPS provider?
This tutorial is a guide to installing OpenVZ: You need to install OpenVZ, at least 2 IP addresses (the same subnet) on a stand-alone server with a minimized installation of the CentOS 64-bit (REDHAT) operating system, and some time.

1. Installation OpenVZ
It is recommended that you assign a separate partition to the virtual machine (the default is the/VZ directory) and format it as a Ext4 file system.
Download the Openvz.repo file to the/etc/yum.repos.d/directory www.111cn.net

Wget-p/etc/yum.repos.d/http://ftp.openvz.org/openvz.repo

Import OpenVZ GPG key for signing RPM packages

RPM--import Http://ftp.openvz.org/RPM-GPG-Key-OpenVZ

Start installation
OpenVZ now supports the Linux 3.x kernel, but is still using the 2.6.x kernel.

Yum-y Install Vzkernel

So far, the OpenVZ has been installed. At this point, the machine cannot be restarted.
Verify that the content in the/etc/sysctl.conf configuration file is consistent with the following:

# 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

Also, disable SELinux and run the command:

echo "selinux=disabled" >/etc/sysconfig/selinux

Additional packages need to be installed: Vzctl, for managing virtual machines, Vzquota, for controlling hard disk capacity allocation, Ploop for OpenVZ file system management.
Execute the following command:

Yum-y Install Vzctl Vzquota ploop

After this step is completed, reboot the machine. The system automatically loads the OpenVZ kernel (the default selection), and after startup completes, checks to see if the kernel is properly installed:

Uname-a

Output is similar to the following results:

Linux hostname 2.6.32-042stab081.8 #1 SMP Mon Nov 17:50:24 MSK 2013 x86_64

Where the string "042stab081.8" represents the OpenVZ version number, should be the latest version of the OpenVZ official online.

2. Create virtual machine (container)
It's not difficult to create a virtual machine, but before that, you need to download some of the OpenVZ on the web of the operating system template placed under/vz/template/cache/, please note that the download back to the tar.gz end of the file, without decompression.
OpenVZ website provides the template download address:
Http://openvz.org/Download/template/cache

These templates include: CentOS, Debian, Fedora, OpenSUSE, Ubuntu, are common Linux distributions.

To create and start a virtual machine, simply run the following command:

VZCTL Create Ctid--ostemplate osname
Vzctl set Ctid--ipadd a.b.c.d--save
Vzctl set Ctid--nameserver a.b.c.d--save
Vzctl Start Ctid

The Ctid here is a positive integer id,osname is the name of the system template, A.B.C.D is the assigned IP address, nameserver is the domain name server (usually with Google's public DNS server 8.8.8.8).

Examples are as follows:

VZCTL Create 101–ostemplate Centos-6-x86
Vzctl Set 101–ipadd 192.0.2.1–save
Vzctl Set 101–nameserver 8.8.8.8–save
Vzctl Start 101

Here, a virtual machine (container) is created.

To refresh a virtual machine that has already been created, execute:

VZCTL EXEC ctid PS ax

Enter the virtual machine and execute:

Vzctl Enter Ctid

Exit the virtual machine and enter exit.

Stop the virtual machine and execute:

Vzctl Stop Ctid

To delete a virtual machine, perform:

Vzctl Destroy Ctid

To limit the use of a virtual machine, edit the/etc/vz/conf/ctid.conf. Each created virtual machine will have its own configuration file. The general default configuration is 256MB memory, 512MB VSWAP,2GB hard disk space.

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.