This howto shows how to install OpenVZ on CentOS 6.
Assumptions
- SELinux is disabled
- Firewall is disabled
- Containers are on the same subnet as the physical host
Installation Steps
Install the OpenVZ yum repo and ensure it points to the right repo (RHLE6)
wget -O /etc/yum.repos.d/openvz.repo http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
vi openvz.repo
Install the OpenVZ kernel. Ensure it is the 1st option in GRUB
yum install vzkernel
vi /boot/grub/menu.lst
Install the OpenVZ utilities
yum install vzctl vzquota
Tune /etc/sysctl.conf
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
Create vmbr0 bridge (optional)
If you are planning on using VETH in containers you will need a bridge interface.
Create vmbr0
# cat /etc/sysconfig/network-scripts/ifcfg-vmbr0 DEVICE="vmbr0" BOOTPROTO="static" IPV6INIT="no" ONBOOT="yes" TYPE="Bridge" DELAY=0 IPADDR=192.168.1.99 NETMASK=255.255.255.0 GATEWAY=192.168.1.1
Add eth0 to vmbr0
# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" ONBOOT="yes" IPV6INIT="no" TYPE="Ethernet" BRIDGE="vmbr0"
Create /etc/vz/vznet.conf with this content
#!/bin/bash EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"
This will automatically attach/detach the container's veth interface to/from vmbr0 on container's startup/shutdown.
Done. Reboot