Skip to main content

How to install OpenVZ on CentOS 6.10 ?

Virtuozzo leverages OpenVZ as its core of a virtualization solution offered by Virtuozzo company. OpenVZ is a container-based virtualization solution for Linux. Since it uses operating system level virtualization technology, unlike other virtualization methods such as VirtualBox, KVM, and Vmware, the guest systems uses the same kernel of the host system. Each virtual machine will efficiently share the CPU, Memory, Disk space, and network of your Physical server. 
It allows a physical server to run multiple isolated operating system instances, called containers, virtual private servers (VPSs), or virtual environments (VEs). OpenVZ is similar to Solaris Containers and LXC.

While virtualization technologies such as VMware, Xen and KVM provide full virtualization and can run multiple operating systems and different kernel versions where OpenVZ uses a single Linux kernel and therefore can run only Linux. 
All OpenVZ containers share the same architecture and kernel version. This can be a disadvantage in situations where guests require different kernel versions than that of the host. However, as it does not have the overhead of a true hypervisor, it is very fast and efficient.
Memory allocation with OpenVZ is soft in that memory not used in one virtual environment can be used by others or for disk caching. While old versions of OpenVZ used a common file system (where each virtual environment is just a directory of files that is isolated using chroot), current versions of OpenVZ allow each container to have its own file system.

OpenVZ WiKi:


OpenVZ Comparison:

OpenVZ Official:

Virtuozzo Doc details:

Installing OpenVZ on CentOS 6.10

My System Details: 
Intel(R) Xeon(R) CPU X3440 @2.53GHz 
4 Core(s), 8 Logical Processor(s)
24 RAM; 2 TB Storage
NIC 1: Public IP ( Internet )  
NIC 2: Private IP  ( NAT ) & One Router 
Host OS : CentOS 6.10 ( Fresh Installation )
N.B: It is recommended to use a separate partition for containers (by default /vz) and format it to ext4. 

1. Disable SELinux & Reboot
# vi /etc/sysconfig/selinux

2. Add OpenVZ Repository & Import OpenVZ GPG key:
# yum install wget
# wget -P /etc/yum.repos.d/
# rpm --import 
# yum update -y
Another Repo:
# cd /etc/yum.repos.d
# wget
# rpm --import 
For another, Do the the following  ( open vi /etc/yum.repos.d/openvz.repo )
[openvz-kernel-rhel5] repository (enabled=0) is and  [openvz-kernel-rhel6] repository (enabled=1)

3. Install OpenVZ kernel
# yum search vzkernel
# yum install vzkernel
This should automatically update the GRUB bootloader as well. Anyway, we should open /boot/grub/menu.lst; the first kernel stanza should now contain the new OpenVZ kernel. The title of that kernel just reads "CentOS Linux ". I think it's a good idea to change that title and add something with "OpenVZ" to it so that you know that it's the OpenVZ kernel. Also make sure that the value of default is 0 so that the first kernel (the OpenVZ kernel) is booted automatically instead of the default CentOS kernel.
# vi /boot/grub/menu.lst 

4. Setting up Kernel parameters : Open /etc/sysctl.conf and make sure that you have the following settings in it (take back up first : # cp -a /etc/sysctl.conf   /etc/sysctl.conf-bak)
# 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

# Controls source route verification
net.ipv4.conf.default.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
If you need to modify /etc/sysctl.conf, run
# sysctl -p  
5. Now Install some OpenVZ user tools: The following tools to be installed to gather the OpenVZ usage statistics. Here is the reason why you should install these tools.
# yum install vzctl vzquota ploop 
6. Network Setup: While creating VMs, make sure you have the same subnet on both physical and virtual machine. If you want to use different subnet OR if the IP addresses of your virtual machines are from a different subnet than the host system's IP address. If you don't do this, networking will not work in the virtual machines! You have to edit /etc/vz/vz.conf file, Open /etc/vz/vz.conf and set NEIGHBOUR_DEVS to all:
# vi /etc/vz/vz.conf

NEIGHBOUR_DEVS=all [ Find and uncomment the line ]

7. Finally Reboot the Server