How to Install and Configure OpenVZ on Ubuntu 8.04 (Hardy)
OpenVZ allows multiple Linux distributions to run on a single computer or server, each with their own dedicated resources and configurations, also known as “Virtual Private Servers” (VPS). It is the free and open source alternative to VMWare and Virtuozzo (actually based on OpenVZ and has many similarities).
Preparing and Installing OpenVZ
1. It is recommended, but not necessary, to create a separate partition for the VE. Use gparted if needed to resize partitions. After the partition is made, create the /vz directory (even if skipping the partition):
sudo mkdir /vz
2. If making a separate partition, add the following to /etc/fstab:
/dev/sda1 /vz ext3 noatime,relatime,errors=remount-ro 0 1
3. Create a symbolic link from /vz to a /var/lib/vz
sudo ln -s /vz /var/lib/vz
4. Make sure backports is enabled.After backports is enabled, install the openvz packages
sudo apt-get install linux-openvz
and then reboot into the openvz kernel.
5. After rebooting into the openvz kernel, install some tools
sudo apt-get install vzctl vzquota
6. Edit the /etc/sysctl.conf with some necessary info:
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
7. Restart the vz service:
sudo /etc/init.d/vz restart
Creating the VE
1. Get an OS template to create the VE. I am using the ubuntu 8.04 template, there are more available at http://wiki.openvz.org/Download/template/precreated
wget download.openvz.org/template/precreated/ubuntu-8.04-i386-minimal.tar.gz
sudo mv ubuntu-8.04-i386-minimal.tar.gz /var/lib/vz/template/cache/
2. Create the VE (don’t use less than 101, since those are for internal use):
sudo vzctl create 101 –ostemplate ubuntu-8.04-i386-minimal
Configuring the VE
1. Add the appropriate network settings to the VE. For a static IP
sudo vzctl set 101 –ipadd 192.168.1.101 –hostname testvps –nameserver 192.168.1.100 –nameserv
2. Edit /etc/vz/conf/101.conf to give the VE some usable resources
# UBC parameters (in form of barrier:limit)
KMEMSIZE=”16384000:18022400″
LOCKEDPAGES=”4096:4096″
PRIVVMPAGES=”262144:292912″
SHMPAGES=”131072:131072″
NUMPROC=”400:400″
PHYSPAGES=”0:2147483647″
VMGUARPAGES=”102400:2147483647″
OOMGUARPAGES=”102400:2147483647″
NUMTCPSOCK=”500:500″
NUMFLOCK=”200:220″
NUMPTY=”64:64″
NUMSIGINFO=”512:512″
TCPSNDBUF=”5365760:10485760″
TCPRCVBUF=”5365760:10485760″
OTHERSOCKBUF=”1503232:4063232″
DGRAMRCVBUF=”262144:262144″
NUMOTHERSOCK=”500:500″
DCACHESIZE=”4194304:4317184″
NUMFILE=”9312:9312″
AVNUMPROC=”200:200″
NUMIPTENT=”128:128″
# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE=”5048576:5153024″
DISKINODES=”1000000:1020000″
QUOTATIME=”0″
3. Start the VE:
sudo vzctl start 101
4. Enter & test the VE’s networking:
sudo vzctl enter 101
ping
ping google.com
5. If it’s working you can start using your VE just like another copy of Ubuntu or whatever distro you used for the OS template. Note: the Ubuntu template is a minimal install (only uses 46MB default). I updated the VE’s /etc/sources.list to match my HN’s repos, then installed whatever software I needed, using ‘apt-cache search
Useful Commands
List all VEs and their state: vzlist -a
Delete VEs: vzctl destroy (no going back)
More commands: man vzctl
See VE stats: vzctl exec cat /proc/user_beancounters
Troubleshooting
Weird errors? Make sure you are booted into the openvz kernel:
uname -a
Linux vpsu4.4domains.com 2.6.24-19-openvz #1 SMP Thu Aug 21 04:18:17 UTC 2008 i686 GNU/Linux
And all the openvz modules are loaded on the HN:
sudo modprobe vzethdev vznetdev vzrst vzctp vzmon vzdquota vzdev
Read More...
[Source: Linux Blogs2k - Posted by FreeAutoBlogger]


0 Comments:
Post a Comment