Install Openvz on CentOS or Scientific Linux 6.x (RHEL 6.x)

Install Openvz on Scientific Linux or CentOS 6.x (RHEL 6.x)
November 12th 2011

This how-to covers the installation of OpenVZ with the RHEL6 kernel on a headless “Basic Server” version of Scientific Linux (SL) or CentOS 6.x. This doc assumes that you have already have a properly working installation of SL. The Scientific Linux site has a very good step-by-step install guide here:
As root, download the yum repo for OpenVZ

# cd /etc/yum.repos.d
# wget

Import the GPG key
# rpm –import

Modify the default openvz.repo file to enable the RHEL6 kernel. The default openvz.repo enables the RHEL5 kernel.

# nano /etc/yum.repos.d/openvz.repo

On line 20 under the [openvz-kernel-rhel5] branch, disable the RHEL5 repo:
Change “enabled=1” to “enabled=0”

On line 50 under the [openvz-kernel-rhel6] development branches, enable the RHEL6 repo:
Change “enabled=0” to “enabled=1”

Save and Exit

# yum update
# yum install vzkernel

Note: This will also install vzquota and vzctl as dependencies.
Reboot to apply the new kernel

Modify the grub menu.lst to reflect the OpenVZ kernel

# nano /boot/grub/menu.lst

For example, change the title “Scientific Linux (2.6.32-042stab021.1)” to “OpenVZ: Scientific Linux (2.6.32-042stab021.1)”

Modify the sysctl.conf file. Append 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 do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

Save the file and apply.
# sysctl -p

Disable SELinux
# nano /etc/sysconfig/selinux

Change “SELINUX=enforcing” to “SELINUX=disabled”
Install vzdump

Vzdump has two dependencies, cstream and perl-LockFile-Simple.
You can either install these each by hand or install them via RPMforge repo.

To install the vzdump dependencies by hand (as root):

# cd
# wget
# wget

# rpm -ivh cstream-2.7.4-3.el6.rf.i686.rpm
# rpm -ivh perl-LockFile-Simple-0.207-1.el6.rf.noarch.rpm

To install the vzdump dependencies via RPMForge repo:

Download the RHEL6 RPMForge release:
# wget

Import the gpg key:
# rpm –import

# yum update

Install the dependencies:
# yum install perl-LockFile-Simple cstream

Now, download and install vzdump:
# wget
# rpm -ivh vzdump-1.2-4.noarch.rpm