Tag Archives: OpenVZ in Centos 6.5

How to install OpenVZ in Centos 6.5

Install first a fresh OS Centos 6.5 with the partitions below. In this example we will use 1 TB of hardisk.

/ – 20000mb

/swap – 5000mb

/vz – All the available space.


Below is the steps on how to install OpenVZ in Centos 6.5

1. Edit the config file below and change SELINUX=enforcing to SELINUX=disabled.

vi /etc/selinux/config

2. Turn off firewall

chkconfig iptables –level 2345 off
chkconfig iptables –list

3. Install wget package if it’s not installed.

yum install wget

4. Download the repository of OpenVZ.

cd /etc/yum.repos.d

wget http://download.openvz.org/openvz.repo

rpm –import¬† http://download.openvz.org/RPM-GPG-Key-OpenVZ

5. Edit the repository and make sure in “[openvz-kernel-rhel6]” is enable.

vi /etc/yum.repos.d/openvz.repo

name=OpenVZ RHEL6-based kernel

6. Update/install OpenVZ and it’s packages required.

yum install openvz-kernel-rhel6 vzctl vzquota bridge-utils -y

7. Make OPENVZ to be the first priority in the boot loader.

vi /boot/grub/grub.conf

title OpenVZ (2.6.32-042stab072.10)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-042stab072.10 ro root=UUID=a4bcc31b-4164-4a6b-aa91-a4d3577d9963 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-042stab072.10.img
title CentOS (2.6.32-279.19.1.el6.x86_64)
root (hd0,0)

8. Reboot the machine.

init 6

9. Edit the config to the below parameters.

vi /etc/sysctl.conf

net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
kernel.core_uses_pid = 1

10. Download a template for guest OS.

cd /vz/template/cache

wget http://download.openvz.org/template/precreated/centos-6-x86_64.tar.gz

11.Install ploop.

yum install ploop -y

12. It’s time to create guest os config.

vzctl create 1001 –ostemplate centos-6-x86_64
vzctl set 1001 –hostname webserverpage.com –save
vzctl set 1001 –ipadd –save
vzctl set 1001 –nameserver –save
vzctl set 1001 –userpasswd root:’mypassword’ –save
vzctl set 1001 –onboot yes –save
vzctl set 1001 –applyconfig unlimited –save

13. To view/start/stop/restart the created VPS you may use the command below.

vzlist -a # view

vzctl start 1001 # start

vzctl stop 1001 # stop

vzctl restart 1001 # restart

vzctl enter 1001 # enter to the VPS