How to install OpenVZ Kernel in Linux Server

In order to install OpenVZ, we need to add the OpenVZ repository to yum:
 
cd /etc/yum.repos.d
 
wget http://download.openvz.org/openvz.repo
 
rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ
 
 
Now open openvz.repo.
vi openvz.repo
and disable the [openvz-kernel-rhel6] repository (enabled=0) and enable the [openvz-kernel-rhel5] repository instead (enabled=1):
 
yum search ovzkernel
yum list ovzkernel*
yum install ovzkernel*
Open grub.conf and check Openvz kernel is set to default or not. You can check the default value as per Openvz kernel. But by default it will automatically take Openvz at the top of the grub.conf means at the 0th position.
vi /etc/grub.conf
default=0
save the file and quit.
 
Now go to grub prompt by using the below command:
[root@server~]# grub
Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub>
Now fire the below command on grub prompt to reboot the server using the openvz kernel once.
savedefault – -default=0 – -once
Now, reboot the server.
shutdown -rf now 
 
I want to use CentOS 5 in my virtual machines, so I download a CentOS 5 template:
 
cd /vz/template/cache
wget http://download.openvz.org/template/precreated/centos-5-x86.tar.gz
 
restart vz service on the server using the below command:
/etc/init.d/vz restart
 
IP forwarding is not enabled                               [WARNING]
 
If you are getting above warning message then follow the below steps:
vi /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 0     —-> make it 1
save and quit the file
 
Please use the below commands to install vzctl and vzquota commands on the server
yum install vzctl vzquota