How to Install OpenVZ on CentOS

CentOS is one of the most popular free and open source server operating systems. OpenVZ is a popular open source system for creating virtual private servers. Combine the two together, and you have a low-cost yet powerful VPS system. The following is a brief installation guide to get OpenVZ running on CentOS.

Step 1. Add the OpenVZ repository to Yum:

cd /etc/yum.repos.d


rpm –import

Edit openvz.repo and disable the [openvz-kernel-rhel5] repository (enabled=0) and enable the [openvz-kernel-rhel6] repository.

Step 2. Install the OpenVZ kernel:

Search using:

yum search vzkernel

Choose the kernel you want and install:

yum install vzkernel

(This should automatically update Grub to your new kernel. If not, you may need to manually edit your grub configuration).

Step 3. Install OpenVZ user tools:

yum install vzctl vzquota

Step 4. Edit /etc/sysctl.conf and ensure you have these settings:

net.ipv4.ip_forward = 1

net.ipv4.conf.default.proxy_arp = 0

net.ipv4.conf.all.rp_filter = 1

kernel.sysrq = 1

net.ipv4.conf.default.send_redirects = 1

net.ipv4.conf.all.send_redirects = 0



Step 5. If your IP addresses for your virtual machines will be on a different subnet than your host machine, you need to make sure you have this in /etc/vz/vz.conf:


Step 6. Disable SELinux bye editing /etc/sysconfig/selinux:

# enforcing – SELinux security policy is enforced.

# permissive – SELinux prints warnings instead of enforcing.

# disabled – No SELinux policy is loaded.


Step 7: Reboot

You should now have a working OpenVZ installation. You should then test it to verify that the kernel is running and that you are able to create containers.