|
Disclaimer: I resume here what I have learned about the virtualization with the OpenVZ tool. I DO NOT assume any responsibility about rights and wrongs of what you find here. These are my understandings of the tool, they can be right or wrong, so if you are using this information, evaluate it by yourself first.
Open Vz is a virtualization tool that is a co project with the Virtuoso one, the lest one commercial. A HUGE amount of information about open vz can be found in the Open VZ project's page, and in the forum.
What we will discuss here are related to debian based
distributions, what does include ubuntu. I will present:
host #> cat
>> /etc/apt/sources.list
deb http://download.openvz.org/debian etch main
deb http://debian.systs.org/ stable openvz
deb-src http://debian.systs.org/ stable openvz
host
#> apt-get update
host #> apt-get install
ovzkernel-2.6.18-enterprise
host #> apt-get
install vzctl vzquota vzdump vzctl-ostmpl-debian
host #>
update-grub
# If the grub is not
installed it will be necessary to install it. FOR THE
TESTED CASE!!!!!! in
this way:
host #> grub-install
/dev/hda4
host #> /sbin/update-grub
(# hiddenmenu) remove the #
host #> reboot
host #>
modprobe vzethdev
host #> vzctl
create 104 --ostemplate debian-4.0-i386-minimal
host #> vzlist
-a
VEID NPROC
STATUS
IP_ADDR
HOSTNAME
104
- stopped
-
-
host #> vzctl
set 104 --ipadd 192.168.12.104 --save
Saved parameters for VE 104
host #> rvzctl set 104
--nameserver 192.168.12.100 --save
Saved parameters for VE 104
host #> vzctl
set 104 --netif_add
eth0,00:12:34:56:74:01,veth104.0,00:12:34:56:71:04 --save
Saved parameters for VE 104
host #> vzctl
start 104
Starting VE ...
VE is mounted
Adding IP address(es): 192.168.12.104
Setting CPU units: 1000
File resolv.conf was modified
Configure veth devices: veth104.0
VE start in progress...
host #>
ifconfig veth104.0 0
host #>
echo 1 > /proc/sys/net/ipv4/conf/veth104.0/forwarding
host #>
echo 1 > /proc/sys/net/ipv4/conf/veth104.0/proxy_arp
host #>
echo 1 > /proc/sys/net/ipv4/conf/eth0/forwarding
host #>
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
host #>
ip route add 192.168.12.104 dev veth104.0
host #> enable () { for
file in $@; do echo $file; echo 1
> $file; done }
host #> enable
/proc/sys/net/ipv4/conf/*/send_redirects
host #> cat 0 >
/proc/sys/net/ipv4/icmp_echo_ignore_all
host #> cat 0 >
/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
host #> vzctl enter 104
virtual
104 #> ifconfig
lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
venet0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.1 P-t-P:127.0.0.1
Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500
Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
virtual
104 #> /sbin/ifconfig eth0 0
virtual
104 #> ifconfig eth0 192.168.12.104
virtual
104 #> ifconfig
eth0 Link
encap:Ethernet HWaddr 00:12:34:56:74:01
inet addr:192.168.12.104 Bcast:0.0.0.0
Mask:255.255.255.255
inet6 addr: fe80::212:34ff:fe56:7401/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:384 (384.0 b)
lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
venet0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.1 P-t-P:127.0.0.1
Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500
Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
virtual 104 #>
route -n
Kernel IP routing table
Destination
Gateway
Genmask
Flags Metric Ref Use Iface
192.0.2.1
*
255.255.255.255 UH
0
0
0 venet0
0.0.0.0
192.0.2.1
0.0.0.0
UG
0
0
0 venet0
virtual 104 #>
route add default gw 192.168.12.100
virtual 104 #>
route del default gw 192.0.2.1
virtual 104 #> route del
-host 192.0.2.1
virtual 104 #>
route -n
Kernel IP routing table
Destination
Gateway
Genmask
Flags Metric Ref Use Iface
192.168.12.0
*
255.255.255.0
U
0
0
0 eth0
0.0.0.0
192.168.12.100
0.0.0.0
UG
0
0
0 eth0
virtual 104 #>
ping
192.168.12.100
PING 192.168.12.100 (192.168.12.100) 56(84) bytes of data.
64 bytes from 192.168.12.100: icmp_seq=1 ttl=63 time=979 ms
64 bytes from 192.168.12.100: icmp_seq=2 ttl=63 time=0.348 ms
64 bytes from 192.168.12.100: icmp_seq=3 ttl=63 time=0.349 ms
--- 192.168.12.100 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.348/326.606/979.122/461.398 ms
virtual 104 #>
cat > /etc/resolv.conf
nameserver 192.168.12.100
host #> brctl
addbr vzbr0
# Add veth devices to bridge
host #> brctl
addif vzbr0 veth104.0
host #>
brctl addif vzbr0 veth105.0
...
host #>
brctl addif vzbr0 vethXXX.N
host #> ifconfig
vzbr0 0
host #>
echo 1 > /proc/sys/net/ipv4/conf/vzbr0/forwarding
host #>
echo 1 > /proc/sys/net/ipv4/conf/vzbr0/proxy_arp
host #> ip
route add 192.168.12.104 dev vzbr0
host #>
ip route add 192.168.12.105 dev vzbr0
host #>
ip route add 192.168.12.106 dev vzbr0
....
host #>
ip route add 192.168.xxx.xxx dev vzbr0
host #> enable
() { for
file in $@; do echo $file; echo 1
> $file; done }
host #> enable
/proc/sys/net/ipv4/conf/*/send_redirects
host #> cat 0 >
/proc/sys/net/ipv4/icmp_echo_ignore_all
host #> cat 0 >
/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts