CentOS 7 – Setting up OpenVZ virtualization on CentOS 7

File Management Commands in Linux

OpenVZ is a new form of virtualization technology that we call a container based one. It basically creates multiple secure and isolated Linux containers running on a single Linux server. This container technology allows better server utilization, since we are not installing a full virtual machine, just a container to hold some of it, and it eliminates application conflict. The virtual machine running on OpenVZ platform are on a standalone mode, where it is the capacity to run without falling in any type of conflict with any other virtual machine running on the same platform. Those machines are independent from each other.

The virtual machines running on OpenVZ have their own operating system, IP address, processes, memory or storage space, application and configuration files, and so on.

Source: http://www.quantact.com

While using OpenVZ, the virtualization is run through the system-level virtualization technology, where the guest system uses the same kernel as the physical machine system unlike KVM and VirtualBox and this helps with the usage effectiveness of the physical machine processing power and the storage power.

For a better usage for OpenVZ, we might need to use QEMU and Virtuozzo as management utilities. We really recommend the usage of the OpenVZ container and virtual machines on a Virtuozzo installation of images.

For CentOS 7, there is no working OpenVZ distribution as of now. So, we are going to install its forked project, Virtuozzo 7, which is capable of all OpenVZ options and more. Yet, we are going to use the OpenVZ tools only.

To install Virtuozzo 7, we need to install the RPM-based distribution package. First, we need to bring the meta information of the virtuozzo-release package into the YUM repository:


$ sudo yum localinstall http://download.openvz.org/virtuozzo/releases/7.0/x86_64/os/Packages/v/virtuozzo-release-7.0.0-10.vz7.x86_64.rpm

Then, we install the mandatory Virtuozzo RPM packages:


$ sudo yum install -y prlctl prl-disp-service vzkernel

Now, we have OpenVZ kernel installed. We move on to the kernel parameter configuration:


$ sudo nano /etc/sysctl.conf

Then, we add the following code:


# 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

After that, we make SELinux act permissive to ensure that OpenVZ works fine:


$ sudo nano /etc/sysconfig/selinux

Next, we need to have the configuration line to make it look like the following:


SELINUX=permissive

This part is optional. We can install the OpenVZ usage statistics tools if needed:


$ sudo yum install vzctl vzquota ploop

Now, since we have successfully installed OpenVZ, we can reboot the system and log in through the OpenVZ kernel. We need to edit the OpenVZ configuration file to set the same subnet for physical and virtual machines:


$ sudo nano /etc/vz/vz.conf

Then, we find and uncomment the following line and change its option to this:


NEIGHBOUR_DEVS=all

Now, we can set up a web-based interface for OpenVZ to help administrate it. We need to download the installation script and run it:


$ sudo wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

Then, add the port from where this web interface is going to serve using Firewalld:


$ sudo firewall-cmd --zone=public --permanent --add-port=3000/tcp

Then, reload Firewalld:


$ sudo firewall-cmd --reload

The web-based interface will be serving its web interface at the machine hostname or IP address followed by port number 3000:


http://<the-hostname>:3000

Now, we are going to start using OpenVZ to download a container and start using it. First, we need to specify a folder to put our containers into:


$ mkdir OpenVZCont
$ cd OpenVZCont

Then, we download an example container:


$ wget http://download.openvz.org/template/precreated/centos-7-x86_64-minimal.tar.gz

Next, we unpack the tar file:


$ tar –xzvf centos-7-x86_64-minimal.tar.gz

Then, we type this command to create our first virtual machine:


$ sudo vzctl create 101 --ostemplate centos-7-x86_64-minimal

Our container ID is 101, since they typically start from 100. Now, we set an IP address for our container:


$ sudo vzctl set 101 --ipadd 10.0.0.14 --save

Then comes a DNS server:


$ sudo vzctl set 101 --nameserver 8.8.8.8 --save

After having the network configuration ready, we can start our newly created container:


$ sudo vzctl start 101

We can verify that it is running by pinging its IP address:


$ ping 10.0.0.14

Now, we can log in to our container to explore it:


$ sudo vzctl enter 101

We are in the newly created container. We can do whatever we want with it. To exit the virtual machine, we can simply type exit in the terminal. Also, using the OpenVZ web interface, we can visualize its status and do some administrative management through it.

Source: https://bderzhavets.wordpress.com/

Comments are closed.