A Beginners Guide to OpenVZ

Posted on November 11th, 2016

OpenVZ is an OS level virtualization technology for Linux. It allows a physical server to run multiple operating systems on it. We can call these platforms containers or VPS. OpenVZ is a container which holds an operating system. We can install multiple operating systems on their containers. OpenVZ containers have no kernel, so it uses VZkernel as common and OpenVZ containers cannot be operated using Linux kernel.

 

Basic terms of an OPENVZ

Templates

OS templates are modified Linux distributions, OpenVZ uses these templates to create containers on it. We can download number of operating system templates from the OpenVZ website. The template architecture must be similar to the host architecture version. Which means the host architecture is 64 bit, so you have to use 64 bit templates to create OpenVZ containers. We can choose any OS templates to install on OpenVZ containers. That is if you are running OpenVZ on a Centos6.6 machine, then you can also create a container with Debian template on that machine.

 

Guest OS

The guest OS is the operating system. Which runs inside the container. We use operating system templates as the guest OS. We can run different containers, but the host OS architecture and the guest OS architecture must be same.

 

Host OS

Host OS is the main OS which holds both OpenVZ kernel and all the other containers.

 

CTID

CTID or container ID is a number we can assign to every container to manage it. CTID must uniquely for every container.

 

OpenVZ configuration

Download openVZ.repo file to your /etc/yum.repos.d/ repository.

#  wget -P /etc/yum.repos.d/ https://download.openvz.org/openvz.repo

Import OpenVZ GPG key used for signing RPM packages

# rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ

# yum install vzkernel

SELinux should be disabled. So, put Disable Selinux in /etc/sysconfig/selinux.

OpenVZ needs user-level tools installed:

# yum install vzctl vzquota ploop

Now reboot the system and select “OpenVZ” on the boot loader menu.

service name = vz

 

Container creation

Download precreated templates from openvz.org to /vz/template/cache location. Downloaded file will be a tar extension file, which doesn’t need to be extracted in the directory.  Before the container creation, check whether the service vz is running active.

# service vz restart

# vzctl create 101 –ostemplate “os name that we downloaded (without .tar extension)”

Assign the container IP:

# vzctl set 101 –ipadd “IP” –save

Set preferred public DNS IP

# vzctl set 101 –nameserver “.           .           .           .” –save

Set the hostname for the container

# vzctl set 101 –hostname “hostname” –save

Assign diskspace for the container

# vzctl set 101 –diskspace “size(eg: 2G)” –save

Set password for root

# vzctl set 101 –userpasswd root:hostname

Set the ram space for the container

# vzctl set 101 –ram “ram size (eg: 256M)” –save

check container details

# vzlist -a

Then start the container

# vzctl restart 101

Finally, the containers can be accessed in two ways

1) vzctl enter “container id”

2) ssh “IP”

 

If you need any further assistance please contact our support department.

 

 

Leave a Reply