Ubuntu 8.0.4 (kernel vmlinuz-2.6.24-16-generic)
First step:
到
http://download.openvz.org/ 下载对应的内核
apt-get install linux-openvz
apt-get install vzctl vzquota
2nd Step:
vi /etc/sysctl.conf
修改以下参数:
############ For openvz ######################
# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.eth0.proxy_arp = 100
# Enables source route verification
net.ipv4.conf.all.rp_filter = 1
# Enables the magic-sysrq key
kernel.sysrq = 1
# TCP Explict Congestion Notification
#net.ipv4.tcp_ecn = 0
# we do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
sysctl -p
vi /etc/vz/vz.conf
NEIGHBOUR_DEVS=all
reboot
$uname -r
2.6.24-openvz-24-004.1d1-686
3rd Step:
http://wiki.openvz.org/Download/template/precreated
下载templates
cp centos-5-i386-minimal.tar.gz到 /var/lib/vz/template/cache
4th Step:
vzctl create 101 --ostemplate centos-5-i386-minimal --config vps.basic
If you want to have the vm started at boot, run
vzctl set 101 --onboot yes --save
To set a hostname and IP address for the vm, run:
vzctl set 101 --hostname test.example.com --save
vzctl set 101 --ipadd 192.168.0.101 --save
Next we set the number of sockets to 120 and assign a few nameservers to the vm:
vzctl set 101 --numothersock 120 --save
vzctl set 101 --nameserver 213.133.98.98 --nameserver 213.133.99.99 --nameserver 213.133.100.100 --nameserver 145.253.2.75 --save
(Instead of using the vzctl set commands, you can as well directly edit the vm's configuration file which is stored in the /etc/vz/conf directory. If the ID of the vm is 101, then the configuration file is /etc/vz/conf/101.conf.)
To start the vm, run
vzctl start 101
To set a root password for the vm, execute
vzctl exec 101 passwd
You can now either connect to the vm via SSH (e.g. with PuTTY), or you enter it as follows:
vzctl enter 101
To leave the vm's console, type
exit
To stop a vm, run
vzctl stop 101
To restart a vm, run
vzctl restart 101
To delete a vm from the hard drive (it must be stopped before you can do this), run
vzctl destroy 101
To get a list of your vms and their statuses, run
edy@edy-desktop:~$ sudo vzlist -a
VEID NPROC STATUS IP_ADDR HOSTNAME
14 19 running 192.168.90.14 f8
101 4 running 192.168.0.101 deb-4.0
102 5 running 192.168.0.102 atlinux
103 30 running 192.168.90.13 cent5
vzctl 可以控制很多 --diskspace