OpenVZ on CentOS 5.5 i686 on Older Server hardware

Home » Computer Articles » Linux » OpenVZ on CentOS 5.5 i686 on Older Server hardware
September 27, 2010 Linux No Comments

I had some old server hardware I didn't want to throw into the garbage. So I looked into some virtual machine software that is called Container Virtualization instead of full Virtualization software like VMWare, Virtualbox, Microsoft Hyper-V and other.

Server hardware Dell Poweredge with Dual PIII 1.4 processors, 2G ram and raid controller.

CentOS 5 basic installation for i386

When installing OS I created a LVM Partition and now I am finishing the setup.
# pvcreate /dev/sda5 (or whatever partition # you setup for the LVM Partition) 
# vgcreate vg0 /dev/sda5
# lvcreate -L124G -n lvol0 vg0
# mkfs.ext3 -j /dev/vg0/lvol0

# mount /dev/vg0/lvol0 /mnt (It seems to be working)
# vi /etc/fstab and add /dev/vg0/lvol0 /vz ext3 defaults 1 2

Some commands to check out LVM Setup.
# pvdisplay
# vgdisplay
# lvdisplay

Updated the CentOS 5 to current CentOS 5.5
# yum update

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

Install OpenVZ i686 kernel
# yum install ovzkernel
# yum install vzctl vzquota vzpkg vzyum vzrpm43-python vzrpm44-python vzctl-lib vzrpm43

Make some changes to sysctl.conf
# vi /etc/sysctl.conf
Added information between 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


Make sure that SELINUX is disabled.
# vi /etc/sysconfig/selinux
SELINUX=disabled

Some other tools that I thought needed to be installed.
# yum install db4 db4-utils

Look for this ip address and change for your ip address range.
# vi /etc/vz/dists/scripts/functions
Edit the FAKEGATEWAY and FAKEGATEWAYNET entries to your ip environment.

Need to install a template file for creating Centos 5 i386 containers.
# wget http://www.neonhost.com/openvz/vztmpl-centos-5-2.0-2.i386.rpm
# rpm -ivh vztmpl-centos-5-2.0-2.i386.rpm

Download a precreated image.
# wget http://download.openvz.org/template/precreated/centos-5-x86.tar.gz

Run this command to list image.
# vzpkgls

Run this command if you want to create your own image instead of using the precreated image.
vzpkgcache -f centos-5-i386-default creating centos-5-i386-default Image from scratch.

VZPKGCACHE Error:  See below to fix.
vi /vz/template/centos/5/i386/config/install-post
Goto this website to fix:
http://www.linuxweblog.com/blogs/sandip/20080708/openvz-centos-template-cache-creation-with-vzpkgcache
You will notice that you are adding a exit 0 to two locations, so what happens when it runs it will error on syslog but still create the image file.

http://wiki.openvz.org/Container_creation
# vzctl create 101 --ostemplate centos-5 --config basic
# vzctl set 101 --ipadd 192.168.1.200 --save
# vzctl set 101 --nameserver 192.168.1.1 --nameserver 192.168.1.2 --searchdomain domainname --save
# vzctl set 101 --hostname openvz-client1.domainname --save
# vzctl set 101 --diskspace 8G:8G --save
or what ever size you want.
# vzctl start 101
# vzctl set 101 --userpasswd root:12345678

Start or Stop client
# vzctl start 101
# vzctl stop 101
# vzctl restart 101

 

Set timezone on client
# chroot /image/dir
# rm /etc/localtime
# ln -s /usr/share/zoneinfo/YourTime/Zone /etc/localtime

List clients
# vzlist -a

Change into the client session
# vzctl enter 101 type exit to exit the session.

Check status of container
# vzctl status 101

Destroy the container
# vzctl destroy 101 or vzctl delete 101

Ran commands inside a running container.
# vzctl exec 101 ps aux

If you have more than one server you can use vzmigrate.
vzmigrate [-r yes|no] [--ssh=<options>] [--keep-dst] [--online] [-v]
# vzmigrate 192.168.1.240 101

You can do a online migration where it will hang and then continue like normal.
# vzmigrate --online 192.168.1.240 101

Updating Clients, There is no yum in the containers.
# vzyum 101 update

Installing applications
# vzyum 101 install httpd php

VZYUM error:
vi /usr/bin/vzyum add this to second to last line.
$VZCTL exec $VEID rpm --quiet -qa

 

BACKUPS:
# rpm -ivh "ftp://ftp.pbone.net/mirror/ftp.freshrpms.net/pub/freshrpms/pub/dag/redhat/el5/en/i386/RPMS.dag/cstream-2.7.4-3.el5.rf.i386.rpm"
# wget http://dag.wieers.com/rpm/packages/perl-LockFile-Simple/perl-LockFile-Simple-0.206-1.el5.rf.noarch.rpm
# rpm -ivh perl-LockFile-Simple-0.206-1.el5.rf.noarch.rpm
# wget http://chrisschuld.com/centos54/vzdump-1.2-6.noarch.rpm
# rpm -ivh vzdump-1.2-6.noarch.rpm
or
# rpm -ivh "http://chrisschuld.com/centos54/vzdump-1.2-6.noarch.rpm"

 

Perl Error:
run this: ln -s /usr/share/perl5/PVE/ /usr/lib/perl5/5.8.8/PVE
# vzdump
# vzrestore

I like to use the command prompt tools because you get more options than the OpenVZ Web Panel but the OpenVZ Web Panel gui makes some of the jobs very easy. Like installing new client templates.

OpenVZ Web Panel but I found so far you either have to use the Web Panel or the command prompt tools.
# wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh
http://<your-ip-address-host>:3000

Proxmox Virtual Environment even easier to setup and use but it needs 64bit Processor and it supports Container Virtualization (OpenVZ) and Full Virtualization (KVM).

Can use bridge configuration for certain configuration.
http://wiki.openvz.org/Using_private_IPs_for_Hardware_Nodes

Website I used for setting up OpenVZ
http://wiki.centos.org/HowTos/Virtualization/OpenVZ
http://download.openvz.org/template/precreated/

Share This:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.