Easyhost Easyhost Easyhost Easyhost Easyhost

Setting up an centos5.2 openvz host and containers.

Quick, quick quick…

I’m doing this install on an old dell 1850, and did on a R300 and worked as well.
My architecture is for both platforms x86_64.

1. netinstall the host system : I use a barebones system (with nothing selected on the setup i.e. no gnome or any kind of x)

2. After your hosts’s setup, set your yum repository to see yum:

cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

3. Install openvz kernel and supporting tools:

yum install ovzkernel.x86_64 vzctl.x86_64

4. Edit the sysctl

vim /etc/sysctl.conf
append:
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

5. Disable selinux

vim /etc/sysconfig/selinux
set:
selinux=disabled

6. Reboot
7. download a domU template ( a precreated template for your container)
Go to : http://wiki.openvz.org/Download/template/precreated and download your favorite.
i used:

cd /vz/template/cache/
wget http://download.openvz.org/template/precreated/contrib/centos-5-x86_64-default.tar.gz

8. Create your first container:

vzctl create 101 --ostemplate centos-5-x86_64-default --hostname --ipadd

Don’t worry you can change the network settings later.

9. Don’t forget to allow dns resolving for client machines, as well as tcp downloading

vim /etc/sysconfig/iptables
Add somewhere in the RH-Firewall-1-INPUT (before the REJECT rule
-A RH-Firewall-1-INPUT -p udp -m udp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart

Troubleshooting

t1. Unable to open pty: No such file or directory
If you have:

[root@host01 cache]# vzctl enter 101
enter into VE 101 failed
Unable to open pty: No such file or directory


[root@host01 cache]# vzctl exec 101 /sbin/MAKEDEV tty
[root@host01 cache]# vzctl exec 101 /sbin/MAKEDEV ptty

t2. if you have memory issues, check the barriers
cat /proc/user_beancounters
if something is failed increase that barrier like this:

vzctl set --save --kmemsize 14372700 --privmpages 655360

t3. If you still can’t resolve names use:

vzctl set 101 ----nameserver 10.80.130.1 --save

Enjoy
Disclaimer: This documentation is provided under the freebsd licence: http://www.freebsd.org/copyright/freebsd-doc-license.html

Alexandru Bordei
Advanced Technologies Specialist @ Hostway Corporation