I have a tiny embedded server (acrosser model) Intel Celeron with only 400MHz and 512MB Mem total. Before I upgraded debian to squeeze I used Xen, now its time to use OpenVZ.
Reasons:
– My tiny hardware:)
– Container virtualization – I can use more virtual machines
– Less memory usage – Container cannot boot
OpenVZ kernel and the vzctl and vzquota packages are available in the Debian repositories, so we can install them as follows:
1 | aptitude update ; aptitude install linux-image-openvz-686 vzctl vzquota |
Create a symlink from /var/lib/vz to /vz to provide backward compatibility and better usage:
1 | ln -s /var/lib/vz /vz |
Open vim /etc/sysctl.conf and make sure that you have the following settings in it:
1 2 3 4 5 6 7 8 9 10 11 | [...] net.ipv4.conf.all.rp_filter = 1 net.ipv4.icmp_echo_ignore_broadcasts = 1 net.ipv4.conf.default.forwarding = 1 net.ipv4.conf.default.proxy_arp = 0 net.ipv4.ip_forward = 1 kernel.sysrq = 1 net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.eth0.proxy_arp = 1 [...] |
View now your current config:
1 | sysctl -p |
Now its time to reboot and start your new kernel:
1 | reboot |
After reboot you should see your fresh installed kernel:
1 2 | nibbler ~ # uname -a Linux nibbler 2.6.32-5-openvz-686 #1 SMP Tue Mar 8 23:30:33 UTC 2011 i686 GNU/Linux |
Now we create our fist container, to do this we need a working template. A lot of templates can be founded here.
Of course you can create your own template. I describe it later:)
Choose one and download it to your template directory:
1 2 | cd /vz/template/cache wget http://download.openvz.org/template/precreated/contrib/debian-6.0-i386-minimal.tar.gz |
After download don’t extract it!
1 2 3 4 5 6 7 8 | vzctl create 01 --ostemplate debian-6.0-i386-minimal vzctl set 01 --ipadd 192.168.1.77 --save vzctl set 01 --nameserver 192.168.1.1 --save vzctl set 01 --hostname gitcher --save vzctl start 01 ping 192.168.1.77 vzctl exec 01 passwd vzctl enter 01 |
Some basic commands:
1 2 3 4 5 6 7 8 9 10 | vzlist vzlist -a vzctl stop 01 vzctl start 01 vzctl restart 01 vzctl status 01 vzctl umount 01 vzctl destroy 01 allocate disk space vzctl set 01 --diskspace "10000000:11000000" --save |
UPDATE 30.06.2011 – Fix the default gateway
After VE creating the default gateway will be: 192.0.2.1 but whit is not my network.
You can set the default gateway in: /etc/vz/dists/scripts/functions
1 2 | vim /etc/vz/dists/scripts/functions FAKEGATEWAY=192.168.1.1 |
[…] Източник: http://zeldor.biz/20…install-openvz/ […]