A brief installation guide how to install OpenVZ. I recommend to use a separate partition for the containers and to use the filesystemtype EXT3 for it. I asume you have CentOS allready running and yum is available.
First we need to setup the OpenVZ repository. As root type:
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
Next install the OpenVZ kernel and the OpenVZ tools:
yum install ovzkernel.x86_64 vzctl.x86_64 vzquota.x86_64Before rebooting into the OpenVZ kernel we have to change some kernel parameters and disable
SElinux. The kernel parameters should be changed or added in /etc/sysctl.conf. Open /etc/sysctl.conf and change or add the lines:
# Enables the kernel magic-sysrq keyTo disable SELinux change the file
kernel.sysrq = 1
# Not all the network interfaces should send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
# Enables source route verification
net.ipv4.conf.all.rp_filter = 1
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
/etc/sysconfig/selinux and add the line
SELINUX=disabled
Now you can reboot your machine to boot up with the OpenVZ kernel.
Once rebooted we can install a new virtual machine. Easy way to do so is to use a precreated OS template from the OpenVZ website. Let's take a CentOS 5 x86_64 template and store it into the template directory /vz/template/cache
cd /vz/template/cache/Create a new container (VPS) based on this template using container-id 1001, we need to run:
wget http://download.openvz.org/template/precreated/centos-5-x86_64.tar.gz
vzctl create 1001 --ostemplate centos-5-x86_64On your terminal you see the status:
Creating container private area (centos-5-x86_64)Using the
Performing postcreate actions
Container private area was created
vzctl command you can change the settings of the container. Don't forget to set the root password immediatly. To set the root password and change the ipaddress and hostname of this container, type:
vzctl set 1001 -hostname myhost.my.domain --ipadd 192.168.1.2 --userpasswd root:[newpasswd]
--save
(Read the man-page of vzctl for more options and instructions.)
To start your newly created VPS you should run:
vzctl start 1001You can now enter your container directly from the hardwarenode itself using:
vzctl enter 1001or using a remote ssh connection. To stop the VPS you should run
vzctl stop 1001
Tags:
