OpenVZ is container-based virtualization for Linux. OpenVZ creates multiple secure, isolated containers (otherwise known as VE or VPS) on a single physical server enabling better server utilization and ensuring that applications do not conflict. Each container performs and executes exactly like a stand-alone server; a container can be rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files.
Step 1. Installation:
An OpenVZ kernel and the vzctl and vzquota packages are available in the Debian Squeeze repositories, so we can install them as follows:
An OpenVZ kernel and the vzctl and vzquota packages are available in the Debian Squeeze repositories, so we can install them as follows:
apt-get install linux-image-openvz-686 vzctl vzquota
Step 2. Create a symlink from /var/lib/vz to /vz to provide backward compatibility:
ln -s /var/lib/vz /vz
Step 3. Open with your favorite editor (eg: nano, vim) /etc/sysctl.conf and edit as following :
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
After you’ve edited /etc/sysctl.conf file run:
sysctl -p
Step 4. Open /etc/vz/vz.conf and set as following:
NOTE: This is important! If you don’t do this, networking will not work in the virtual machines!
NEIGHBOUR_DEVS=all
Step 5. Reboot the system using:
reboot or shutdown -r now
Step 6. After reboot run:
uname -r
Your output should be like this:
2.6.32-5-openvz-686
Step 6. Using OpenVZ
Before we can create virtual machines we need to have a template for the distribution that we want to use in the/var/lib/vz/template/cache directory.
You can find a list of precreated templates on http://wiki.openvz.org/Download/template/precreated. For example, we can download a minimal Debian Squeeze template.
Step 7. Basic commands for using OpenVZ:
a) To set up a VPS from the debian-6.0-i386-minimal template run:
vzctl create 101 –ostemplate debian-6.0-1386-minimal –config basic
NOTE: 101 is the ID of your virtual machine. Each virtual machine must have unique ID
b) Set the virtual machine to be started at boot:
b) Set the virtual machine to be started at boot:
vzctl set 101 –onboot yes –save
c) Set a hostname and IP address for the virtual machine:
vzctl set 101 –hostname debian-tutorials.com –save
vzctl set 101 –ipadd 10.10.0.2 –save
d) Start the virtual machine:
vzctl start 101
e) Set a root password for the virtual machine:
vzctl exec 101 passwd.
f) IPTables NAT that OpenVZ Container can connect to internet
iptables -t nat -A POSROUTING -o eth0 -j MASQUERADE
For more commands you can use the man vzctl command.
http://openvz.org/Installation_on_Debian
This tutorial is adapted for debian squeeze from http://howtoforge.com
Tidak ada komentar:
Posting Komentar