Thursday, August 13, 2009

Common tasks with OpenVZ

You just want to skip all the reading about OpenVZ and start using it ?!
This is just for you.
It will install the openvz kernel and utilities and have a container ready.
Feel free to execute all or just a few commands.

### 
# info http://wiki.openvz.org/Quick_installation
# install script

cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import  http://download.openvz.org/RPM-GPG-Key-OpenVZ
yum -y install ovzkernel

# edit grub.conf if you want to change labels etc

reboot

yum install vzctl vzquota
/sbin/service vz start


### 
# info http://wiki.openvz.org/OS_template_cache_preparation
# os templates

# to make templates
# utilities
yum install vzpkg vzyum vzrpm43-python vzrpm44-python vzctl-lib

# metadata
yum search vztmpl

# create cache
vzpkgcache centos-4-i386-minimal



# Precreated template cache 
# YOU NEED TO DO THIS - there are many templates
# download from http://wiki.openvz.org/Download/template/precreated


#  Create and start a container 
# To create and start a container, run the following commands:
# 
# [host-node]# vzctl create CTID --ostemplate osname
# [host-node]# vzctl set CTID --ipadd a.b.c.d --save
# [host-node]# vzctl set CTID --nameserver a.b.c.d --save
# [host-node]# vzctl start CTID
# 

###########
vzctl create 1 --ostemplate centos-5-x86
vzctl set 1 --ipadd 10.0.51.254 --save
vzctl set  1 --nameserver 192.168.1.20 --save
vzctl start 1


# Here CTID is the numeric ID for the container; osname is the name of the OS template for the container, and a.b.c.d is the IP address to be assigned to the container.
# Your freshly-created container should be up and running now; you can see its processes:
# 
[host-node]# vzctl exec CTID ps ax
# 
# Enter to and exit from the container
# 
# To enter container give the following command:
# 
[host-node]# vzctl enter CTID
# entered into container CTID
# [container]#
# 
# To exit from container, just type exit and press Enter:
# 
[container]# exit
# exited from container VEID
# [host-node]#
# 
# Stop and destroy the container
# 
# To stop container:
# 
[host-node]# vzctl stop CTID
# Stopping container ...
# Container was stopped
# Container is unmounted
# 
# And to destroy container:
# 
[host-node]# vzctl destroy CTID
# Destroying container private area: /vz/private/CTID
# Container private area was destroyed
# 


0 comments: