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:

http://www.scientificlinux.org/distributions/6x/installing/install-guide-full.html
As root, download the yum repo for OpenVZ

# cd /etc/yum.repos.d
# wget http://download.openvz.org/openvz.repo

Import the GPG key
# rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ

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 http://pkgs.repoforge.org/cstream/cstream-2.7.4-3.el6.rf.i686.rpm
# wget http://pkgs.repoforge.org/perl-LockFile-Simple/perl-LockFile-Simple-0.207-1.el6.rf.noarch.rpm

# 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 http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

Import the gpg key:
# rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Update
# yum update

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

Now, download and install vzdump:
# wget http://download.openvz.org/contrib/utils/vzdump/vzdump-1.2-4.noarch.rpm
# rpm -ivh vzdump-1.2-4.noarch.rpm

Done.