1] Setup a minimal CentOS 6.2 64-bit.
2] Setup networking. I used the "192.168.1.0/24" network. Here's my guide for setting up networking: http://blog.malaya-digital.org/setup-a-minimal-centos-6-0-64-bit-setup-with-networking/
3] Login as root.
4] Turn off selinux by issuing in a shell as root:
# setenforce 0
... and then editing /etc/sysconfig/selinux to set:
SELINUX=disabled
5] yum -y update
6] yum -y install wget
7] cd /root
8] wget http://mirror.nus.edu.sg/fedora/epel/6/x86_64/epel-release-6-5.noarch.rpm
9] rpm -Uvh epel-release-6-5.noarch.rpm
10] rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
11] cd /etc/yum.repos.d
12] wget http://download.openvz.org/openvz.repo
13] To see kernels to choose: yum search vzkernel
14] I chose: yum install vzkernel.x86_64 vzkernel-headers.x86_64 vzkernel-devel.x86_64 vzkernel-firmware.noarch
15] vi /etc/yum.conf
... and make sure you have a "exclude=kernel*" line under the [main] section.
16] vi /boot/grub/menu.lst # check if you'll be booting the OpenVZ kernel. You can "rpm -ql vzkernel.x86_64 | grep \/boot\/vmlinuz" for more information on the OpenVZ kernel package.
17] yum install vzctl vzquota # packages may have been installed already, but do this just to make sure.
18] vi /etc/sysctl.conf
Make sure you have the following 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
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.forwarding = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
19] shutdown -r now
20] "vi /etc/vz/vz.conf" and set:
NEIGHBOUR_DEVS=all
21] service iptables stop
22] chkconfig iptables off
23] shutdown -r now
24] To create a container:
cd /vz/template/cache
wget http://download.openvz.org/template/precreated/centos-6-x86.tar.gz
vzctl create 101 --ostemplate centos-6-x86
vzctl set 101 --ipadd 192.168.1.215 --save
vzctl set 101 --nameserver 208.67.222.222 --nameserver 208.67.220.220 --save
vzctl set 101 --hostname "my.new.container.com" --save
vzctl set 101 --onboot yes --save
vzctl start 101
25] To set time zone to Singapore for both host and container:
rm -rf /etc/localtime 2>/dev/null; unlink /etc/localtime 2>/dev/null
ln -s /usr/share/zoneinfo/Asia/Singapore /etc/localtime
vzctl exec 101 rm -rf /etc/localtime 2>/dev/null
vzctl exec 101 unlink /etc/localtime 2>/dev/null
vzctl exec 101 ln -s /usr/share/zoneinfo/Asia/Singapore /etc/localtime
26] To enter container:
vzctl enter 101
Some usefull stuff(stop your container before doing these):
Adjust disk space:
vzctl set 101 --diskspace 4096000 --save
Adjust memory(Guaranteed 512MB and 1024MB Burstable):
vzctl set 101 --vmguarpages 512M --save
vzctl set 101 --oomguarpages 512M --save
vzctl set 101 --privvmpages 512M:1024M --save

1 Comment to 'Setup OpenVZ in a minimal CentOS 6.2 64-bit installation'
November 14, 2012
[...] – thanks to this site I found out that there is a better way to disable default kernel from updates then uninstalling it. [...]
Leave a comment