About OpenVZ
OpenVZ is a container-based virtualization solution for Linux. We can create ‘n’ number of Virtual machines depending upon the configuration of our physical system. Each virtual machine will act like a separate standalone physical system, and doesn’t conflict with one another. The virtual machines created using OpenVZ can be rebooted independently, and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files. Since it uses operating system level virtualization technology, unlike other virtualization methods such as VirtualBox, KVM, and Vmware, the guest systems uses the same kernel of the host system. Each virtual machine will efficiently share the CPU, Memory, Disk space, and network of your Physical server.
Installing OpenVZ on CentOS 6.5
System Requirements:
- A decent Intel or AMD PC;
- Atleast 128MB of RAM;
- Hard drives with atleast 4GB free disk space;
- Atleast 2NICs;
- Internet connection.
It is recommended to use a separate partition for containers (by default /vz) and format it to ext4. You need to have set two IP addresses to your physical machine. One is for the original host and another IP is for Virtual machine.
1. Add OpenVZ Repository
Download OpenVZ Repository and put it in /etc/yum.repos.d/ directory.
yum install wget
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
Import OpenVZ GPG key:
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
2. Install OpenVZ kernel
yum install vzkernel
3. Setting up Kernel parameters
Make sure you have added the following kernel parameters before logging into vz kernel.
vi sysctl.conf
Add the following lines:
# On Hardware Node we generally need # 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 # Enables source route verification net.ipv4.conf.all.rp_filter = 1 # Enables the magic-sysrq key kernel.sysrq = 1 # We do not want all our interfaces to send redirects net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0
4. Disable SELinux
Edit /etc/sysconfig/selinux file:
vi /etc/sysconfig/selinux
Set as disabled:
SELINUX=disabled
5. Install OpenVz usage statistics tools
The following tools to be installed to gather the OpenVZ usage statistics. Here is the reason why you should install these tools.
yum install vzctl vzquota ploop
That’s it. We have successfully installed OpenVZ.
Now, it’s time to reboot and log in to OpenVZ kernel(it should be the default choice in the boot loader).
We’ll see how to create virtual machines using OpenVZ in our upcoming tutorials.
While creating VMs, make sure you have the same subnet on both physical and virtual machine. If you want to use different subnet, you have to edit /etc/vz/vz.conf file,
vi /etc/vz/vz.conf
Find and uncomment the line:
NEIGHBOUR_DEVS=detect
And, change it to:
NEIGHBOUR_DEVS=all
That’s it.
Want to instal OpenVZ in Ubuntu and derivatives, check the following link.
Ok, I have installed OpenVZ in CentOS, now what?
- Create and manage Linux containers – The command line way
- Create and manage Linux containers Using OpenVz Web Panel
OpenVZ Home page: