Install an OpenVZ Server on CentOS

Install an OpenVZ Server on CentOS

Category : How-to

Get Social!

openvz-logo-150px_new_3OpenVZ servers are hypervisors which allow you to create numerous guest instances within a single hardware node. Unlike other products which offer full hardware virtualisation, OpenVZ creates containers – isolated program execution environments – that share the hardware nodes kernel.

OpenVZ works very differently to the more mainstream hypervisors like VMWare’s ESXI, KVM or Xen and therefore comes with some benefits as well as a few problems. In the benefit category, the big one is performance.  OpenVZ containers loose very little power from what is available on a bare metal machine. The big drawback is that an OpenVZ container can only run Linux guests because each guest is actually using the hardware nodes kernel.

OpenVZ recommends running an OpenVZ server on Red Hat Linux, or one of it’s derivitives such as CentOS. Before starting this tutorial, make sure that you have a freshly installed CentOS server with terminal access. For this example, I’m going to use a fresh install of CentOS 6.5.

There are three stages to the installation of the OpenVZ software; install the OpenVZ kernel, configure system parameters and install the OpenVZ tools.

Install the OpenVZ kernel

All of the packages required to install an OpenVZ server are available in a repository which needs to be added to yum. Once this is complete, you can use yum to install all of the OpenVZ packages, including the kernel. Using this method, we can also keep our packages up to date as future releases are made available by the OpenVZ team.

Download the OpenVZ repository details and add the GPG key which is used to sign each package.

wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ

We can now install the OpenVZ kernel by running the below command. Type y when prompted to begin the download and installation.

yum install vzkernel

Configure system parameters

We need to configure various system parameters for OpenVZ to work, especially on the networking side.

Open up the sysctl.conf file.

vi /etc/sysctl.conf

Either add or amend the following settings.

# 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

OpenVZ needs SELinux to be disabled. Open up the selinux config file and make the SELINUX attribute disabled.

vi /etc/sysconfig/selinux

For example:

 This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Install OpenVZ tools

Once the kernel is set up we need to install the OpenVZ tools for creating and managing an OpenVZ server.

yum install vzctl vzquota

You can now reboot your machine. When your machine starts up, make sure that the OpenVZ kernel is loaded with the uname -r command. The result should be similar to below, although the version numbers will change with time.

# uname -r
2.6.32-042stab084.26

And that’s it! You now have an OpenVZ server up and running.

 

See Basic container management for details on creating your first CT.

 


NFS Mount Error on OEL

Category : How-to

Get Social!

oelI have been using an Oracle Enterprise Linux (OEL) OpenVZ container in Proxmox for installing some Oracle software. The easiest and least interfering way I have found is to mount an NFS share which contains the binaries directly to the container. See my NFS blog post for more information on setting up an OpenVZ container for NFS.

After the service and container was set up for NFS I tried to mount the NFS share. I received the below error after running the mount command.

[root@localhost ~]# mount -a
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

This was because the rpcbind daemon was not running. Run the below command to start the rpcbind daemon.

service rpcbind start

The service will display that the daemon is now running.

Starting rpcbind: [ OK ]

You can set rpcbind to start automatically by adding it to the startup group.

chkconfig rpcbind on

Retry the mount command and your NFS share should be mounted.

mount -a

You may need to check that you have the NFS client packages installed.

yum install nfs-utils

Visit our advertisers

Quick Poll

Which type of virtualisation do you use?
  • Add your answer

Visit our advertisers