Virtualisation with OpenVZ

Published: Wednesday, Dec 26, 2007 Last modified: Monday, Apr 8, 2024

I do not recommend OpenVZ user vserver instead! http://linux-vserver.org/Welcome_to_Linux-VServer.org You need the openvz patched kernel:

deb http://download.openvz.org/debian etch main

See what resources the Virtual Environment (VE) is using:

sudo vzcalc -v 100

What VEs are currently running?

sudo vzlist

Start the machine:

sudo vzctl start 100

Stop the machine:

sudo vzctl stop 100

Get inside:

sudo vzctl enter 100

Create a machine called simon:

sudo debootstrap --arch i386 etch /var/lib/vz/private/100 http://ftp.us.debian.org/debian

sudo vzctl set 100 --applyconfig vps.basic --save

sudo vzctl set 100 --ipadd 192.168.2.66 --nameserver 72.29.96.250 --hostname simon --save

More on networking: The guide was: http://wiki.openvz.org/Using_NAT_for_VE_with_private_IPs So we create openvz VEs (virtual machines) with private addresses like 192.168.2.66 in this test case. Then I’ll use the IP of eth0:0, 72.249.20.194. I want to setup a VE with lighttpd. This is a good guide to setting up a Debian VE /usr/share/doc/vzctl/README.Debian, though in future I’ll like to make a template. So I am going to setup a VE 192.168.2.66:80 with 72.249.20.194:80

this sets up networking for the VE

sudo iptables -t nat -A POSTROUTING -s 192.168.2.66 -o eth0 -j SNAT –to 72.249.20.194

This gets outside Internet access working

sudo iptables -t nat -A PREROUTING -p tcp -d 72.249.20.194 –dport 80 -i eth0 -j DNAT –to-destination 192.168.2.66:80 It works well! Increasing disk space and memory allocation:

sudo vzctl set 100 --diskspace 10G --save

sudo vzctl set 100 --vmguarpages $((256 * 256)) --save

sudo vzctl set 100 --privvmpages $((256 * 1024)) --save