Managing an OpenVZ server (II)

Hello again everyone. First of all, I want to thank you all for the good reception I have had in DesdeLinux and, especially, to the staff for making all this possible. I hope I can continue to collaborate in the future and that this community is growing. But enough sentimentality for now, let's get down to business.

On this occasion I will dedicate the entire post to dealing with everything related to the installation of OpenVZ in our system. So we will have everything ready in the next posts to start working.

If you remember the Previous Article, we said that currently OpenVZ has support to be installed both in Red Hat/6 CentOS as in Debian 7. We will review your installation step by step on both systems.

Installation on Red Hat / CentOS 6

When installing the base system there is no special configuration to do. It is only recommended to use the following partitioning scheme:

  • / Partition: for the base system and openvz software. In full installations (with graphical interface) it must have at least 3 GB, much less if the version is used minimal o netinstall.
  • Swap Partition: For the swap area. Use the recommended size according to our ram.
  • / Vz partition: It is where the containers and all their information will be stored. It is recommended to allocate all the remaining space to this partition.

Once we have installed the base system, we proceed to install the software OpenVZ. The first thing is to add the repository OpenVZ to our team to be able to download all the software. To install and manage OpenVZ it is necessary to have permissions Super user, so we open a terminal like root and we execute the following:

#wget -O /etc/yum.repos.d/openvz.repo http://download.openvz.org/openvz.repo
#rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

OpenVZ uses a modified version of the linux kernel. With the following command we will install it:

#yum install vzkernel

The following two steps are not required for newer installations (as of version 4.4 of vzctl) but I will comment on them to ensure compatibility with older versions.

The first thing is to enable some options for the kernel. We edit the file sysctl.conf with our preferred editor:

#vim /etc/sysctl.conf

And we add the following at the end:

net.ipv4.ip_forward = 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
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1

You also need to disable Selinux, so that in CentOS It is enabled by default and can cause problems:

#echo "SELINUX=disabled" > /etc/sysconfig/selinux

From now on we continue with the steps for everyone. We are going to install the necessary tools for the administration of OpenVZ:

#yum install vzctl ploop

To make the backup copies we will install the tool vzdump. Since the version of the repositories is outdated, we are going to download the package rpm:

#wget http://download.openvz.org/contrib/utils/vzdump/vzdump-1.2-4.noarch.rpm

And we install it:

#rpm -ivh rpm -ivh vzdump-1.2-4.noarch.rpm

Now that we have everything prepared, it only remains to restart the machine so that it loads the new one kernel with the options we have configured.

Installation on Debian 7

To install OpenVZ en Debian 7The first thing to consider is partitioning. As in CentOS, it is recommended to create a partition for the directory OpenVZ in which the containers will be and that occupies all the excess space of the rest of the partitions (normally one in / and another as an exchange area). But different from CentOS, this directory is:

/ var / lib / vz

Once we have finished configuring the system to our liking, we proceed to install OpenVZ. The first thing is to add the repositories. To do this we execute this command:

cat < /etc/apt/sources.list.d/openvz-rhel6.list
deb http://download.openvz.org/debian wheezy main
# deb http://download.openvz.org/debian wheezy-test main
EOF

With this little command we have added the repository of OpenVZ to our system. Then you have to download the key GPG to sign the repository:

#wget http://ftp.openvz.org/debian/archive.key
#apt-key add archive.key

And we do an update so that the repositories are updated:

#apt-get update

Now we can start installing everything we need. The first and fundamental thing is to install the Kernel modified. We do so:

#apt-get install linux-image-openvz-amd64

After doing this, it is very important to do the next step before restarting the system. What we must do is edit the file sysctl.conf to add some parameters to the kernel:

#vim /etc/sysctl.conf

And we add the following text at the end:

# 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

Now we can restart the system. In fact, it is recommended to do it so that it boots with the OpenVZ kernel. After this, we install the necessary tools for the administration of OpenVZ:

#apt-get install vzctl vzquota ploop

And with this we finish everything related to the installation of OpenVZ. If everything has gone well we will have our host ready to start creating the containers.

Before saying goodbye I comment that, for the next parts of this tutorial, all the code will have been tested on a computer with 6.4 CentOS. Those that you are going to use Debian you should take it into account. The differences will probably be minimal. The main one will be the location of the OpenVZ (where the containers are located among other things). Meanwhile in CentOS It is located / vz, riding a Debian you will find it in / var / lib / vz. If you have any problem or doubt related to this or anything else, do not hesitate to leave a comment and I will try to help as much as I can.

This is it for now. The next part will cover one of the most important topics: container creation and its basic administration. We'll see each other then. Long life and prosperity.


2 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   trinity said

    Good! Thank you very much for the submissions on OpenVZ. I have a little doubt about the partitioning. When installing the OS, do you recommend creating a partition for the / var directory?

    1.    Jose Alejandro Vazquez said

      Well, as the article says: "in CentOS it is located / vz, in Debian you will find it in / var / lib / vz." Clarify, in the partitioning in the debian installation, it allows you to create a manual partition, you take that option and put: / var / lib / vz and it will create and mount the partition in that directory without major inconvenience, of course your / var It will only be a directory in your root directory, so all your logs will also be loaded in the / partition and not in / var / lib / vz, I have it like this and no problem, I hope I have clarified it.