User Tools

Site Tools


virtualization:openvz

This is an old revision of the document!


OpenVZ Virtualization

OpenVZ is a form of OS virtualization based on 'containers'.

Other common forms of operating system virtualization:

  • Fully virtualized
    • Often called HVM (hardware virtual machine)
    • VMware, KVM, etc.
  • Para-Virtualized
    • Xen

OpenVZ containers offer a very high performance virtualization platform. This is primarily due to its low overhead. Containers share the common host kernel and is primarily for Linux VMs.

Host Servers

PBX

Templates

OpenVZ containers are created from templates. Since containers are not fully virtualized environments, there is no booting to CD/DVD drives or ISO images.

Creating Templates

Create a FreePBX (Centos 5) Template on Proxmox

Install your Centos server and application to a physical machine.

Create a Centos 5 container using an existing Centos template and shut it down.

Log into the Proxmox host.

CTID=100

rm -rf /var/lib/vz/private/$CTID

mkdir /var/lib/vz/private/$CTID

rsync -arvpz --exclude=/dev --exclude=/mnt --exclude=/proc --exclude=/sys --exclude=/tmp -e ssh root@xx.xx.xx.xx:/ /var/lib/vz/private/$CTID/

sed -i -e 's/^[0-9].*getty.*tty/#&/g' /var/lib/vz/private/$CTID/etc/inittab

grep devpts /var/lib/vz/private/$CTID/etc/fstab > /var/lib/vz/private/$CTID/etc/fstab.new

mv -f /var/lib/vz/private/$CTID/etc/fstab.new /var/lib/vz/private/$CTID/etc/fstab

mkdir /var/lib/vz/private/$CTID/dev
mkdir /var/lib/vz/private/$CTID/mnt
mkdir /var/lib/vz/private/$CTID/proc
mkdir /var/lib/vz/private/$CTID/sys
mkdir /var/lib/vz/private/$CTID/tmp

mkdir /var/lib/vz/private/$CTID/dev/pts

mkdir /var/lib/vz/private/$CTID/etc/udev/devices

cd /var/lib/vz/private/$CTID

chroot .

MAKEDEV -d /dev -x {p,t}ty{a,p}{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f} console core full kmem kmsg mem null port ptmx random urandom zero ram0

MAKEDEV -d /etc/udev/devices -x {p,t}ty{a,p}{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f} console core full kmem kmsg mem null port ptmx random urandom zero ram0

chmod 1777 /tmp
chmod 1777 /var/tmp

# Disable any physical NICs by modifying the etc/sysconfig/network-scripts/ifcfg-ethX files
# (where X is the interface number starting from 0) and setting ONBOOT to no.

vi /etc/sysconfig/network-scripts/ifcfg-eth0

ONBOOT=no

vi /etc/sysconfig/network

NETWORKING_IPV6="no"

vim /etc/rc.d/rc.sysinit

#/sbin/start_udev

# For RHEL 6 and clone distributions, you must comment out "console" in /vz/private/$CTID/etc/init/rc.conf
# and /vz/private/$CTID/etc/init/rcS.conf.
#
# You must also delete or rename tty.conf and start-ttys.conf.
#
# If you do not the container will not boot up.

# Change 'el5' to 'el6' for EL6 repos

cat << EOF >> /etc/yum.repos.d/vz.repo
[vz-base]
name=vz-base
mirrorlist=http://vzdownload.swsoft.com/download/mirrors/redhat-el5
gpgcheck=0 

[vz-updates]
name=vz-updates
mirrorlist=http://vzdownload.swsoft.com/download/mirrors/updates-released-rhel5
gpgcheck=0
EOF

cat >> ~/.bash_profile << EOF

alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias ls="BLOCK_SIZE=\'1 ls --color=auto"
alias free="free -m"
export GREP_OPTIONS='--color=auto'
PS1='\[\033[00;36m\]\u\[\033[00m\]@\h:\[\033[05;33m\]\w\[\033[00m\] \$ '
export HISTCONTROL=ignoredups
EOF

mkdir /var/lock/rpm

echo "
# IPv6
blacklist ipv6
blacklist net-pf-10" >> /etc/modprobe.d/blacklist.conf


exit # from chroot

virtualization/openvz.1345929462.txt.gz · Last modified: 2012/08/25 15:17 by gcooper