Previously we talked about OpenVZ and compared with Xen, KVM virtualization. OpenVZ is Free Software intended for production usage. CentOS or Red Hat Enterprise Linux are practical GNU/Linux distro for certain works. Furthermore, CentOS has lot of users who are using OpenVZ. We can use OpenVZ on dedicated server to create multiple virtual servers. Here is how to install OpenVZ on CentOS to create virtual servers. Minimum system requirement of OpenVZ is just less and even cheapest dedicated servers will meet the hardware requirements.
Officially CentOS 5.x or CentOS 6.x or Red Hat Enterprise Linux or Scientific Linux or Ubuntu 14.04 are compatible host OS with partition scheme of /
of 20 GB or more, twice amount of SWAP than RAM, /vz
partition for the rest of hard disk, at least 2NICs and 2 IP addresses needed on physical machine. It is recommended to use a separate partition for containers (by default /vz)
and format it to ext4.
You can manually browse the repo :
---
1 2 | https://download.openvz.org/openvz.repo http://ftp.openvz.org/openvz.repo |
How To Install OpenVZ On CentOS To Create Virtual Servers
For REHL 6 based kernel, there is uncomplicated matter :
1 | https://wiki.openvz.org/Different_kernel_flavors_(UP,_SMP,_ENTERPRISE,_ENTNOSPLIT) |
You can manually install :
1 2 3 | wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ yum install vzkernel |
We need some changes on sysctl.conf
:
1 | nano sysctl.conf |
Like this :
1 2 3 4 5 6 7 8 9 10 11 12 | ... net.ipv4.ip_forward = 1 net.ipv6.conf.default.forwarding = 1 net.ipv6.conf.all.forwarding = 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 |
selinux file needs to be disabled :
1 | nano /etc/sysconfig/selinux |
Set it as disabled :
1 | SELINUX=disabled |
The following tools needed to be installed for OpenVZ usage statistics :
1 | yum install vzctl vzquota ploop |
Open :
1 | nano /etc/vz/vz.conf |
Make it :
1 | NEIGHBOUR_DEVS=all |
Reboot the server.
Above are minimum steps for installing OpenVZ on CentOS dedicated server. There is a ready to use bash script to automate the initial steps which was for the paid version. The importance is that, you can wget and cat it to check extra packages :
1 2 3 | wget -N http://files.virtualizor.com/install.sh chmod 0755 install.sh cat install.sh |
If you run it, you’ll get output like :
1 2 3 | ----------------------------------------------- Welcome to Softaculous Virtualizor Installer ----------------------------------------------- |
OpenVZ has many control panels :
1 | https://openvz.org/Control_panels |
Default Locations for some OpenVZ directories –
/vz : Main directory.
/vz/private – Each VPS container’s directories
/etc/vz/conf – Softlinked directory for each VPS config
/etc/vz/vz.conf – Main OpenVZ config file
/vz/template/cache – Directory to download and store each Linux distribution template
/etc/vz/ – OpenVZ config directory