<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Hosting Blog &#187; Centos+openVZ</title>
	<atom:link href="http://www.hostingbkk.com/tag/centosopenvz/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hostingbkk.com</link>
	<description>Web Hosting Articles By Linux Systems Administrator Shahram Azin</description>
	<lastBuildDate>Mon, 14 Jun 2010 20:40:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>OpenVZ Installation on Centos</title>
		<link>http://www.hostingbkk.com/2010/06/14/openvz-installation-on-centos/</link>
		<comments>http://www.hostingbkk.com/2010/06/14/openvz-installation-on-centos/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 00:29:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VPS]]></category>
		<category><![CDATA[Centos+openVZ]]></category>
		<category><![CDATA[openVZ+Installation]]></category>

		<guid isPermaLink="false">http://www.hostingbkk.com/?p=374</guid>
		<description><![CDATA[There are number of virtualization products exist for Linux. OpenVZ is one the most popular among others which has been widely used by many Web Hosting Provider. OpenVZ is a glorified Linux chroot or BSD jail system that allows you to completely isolate processes from each other, increase security by keeping bits separate, and tightly [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "OpenVZ Installation on Centos", url: "http://www.hostingbkk.com/2010/06/14/openvz-installation-on-centos/" });</script>]]></description>
			<content:encoded><![CDATA[<p>There are number of virtualization products exist for Linux. OpenVZ is one the most<br />
popular among others which has been widely used by many Web Hosting Provider.</p>
<p>OpenVZ is a glorified Linux chroot or BSD jail system that allows you to completely isolate processes from each other, increase security by keeping bits separate, and tightly control resource utilization. OpenVZ refers to these &#8220;virtual machines&#8221; as containers, virtual private servers (VPS), or virtual environments (VE).</p>
<p><img src="http://hostingbkk.com/images/logo_openvz.jpg" alt="logo_openvz" /></p>
<p>The Installation of  OpenVZ is quite simple. It requires a special kernel to provide the virtualization support it needs, and this can be obtained easily via the OpenVZ project itself. The OpenVZ kernel patch is licensed under GPL license, and the user-level tools are under the QPL license.</p>
<p>The article below explain how to install OpenVZ container in CentOS 5.4. With OpenVZ you can create multiple Virtual Private Servers (VPS) on same hardware machine and running them simultaneously and efficiently.</p>
<p>1, Install OpenVZ</p>
<p>In order to install OpenVZ, we need to add the OpenVZ repository to yum, this would also help us keep the kernel up-to-date:</p>
<p>cd /etc/yum.repos.d<br />
wget http://download.openvz.org/openvz.repo<br />
rpm &#8211;import http://download.openvz.org/RPM-GPG-Key-OpenVZ</p>
<p>The repository contains a few different OpenVZ kernels (you can find more details here: http://wiki.openvz.org/Kernel_flavors), or with this command “yum search ovzkernel“.</p>
<p>Pick one of them and install it as follows:</p>
<p>yum install ovzkernel</p>
<p>This should automatically update the GRUB bootloader as well. An example is listed below”</p>
<p>cat /boot/grub/menu.lst<br />
# grub.conf generated by anaconda<br />
#<br />
# Note that you do not have to rerun grub after making changes to this file<br />
# NOTICE:  You have a /boot partition.  This means that<br />
#all kernel and initrd paths are relative to /boot/, eg.<br />
#root (hd0,0)<br />
#kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00<br />
#initrd /initrd-version.img<br />
#boot=/dev/sda<br />
default=0<br />
timeout=5<br />
splashimage=(hd0,0)/grub/splash.xpm.gz<br />
hiddenmenu<br />
title CentOS (2.6.18-128.2.1.el5.028stab064.7)<br />
root (hd0,0)<br />
kernel /vmlinuz-2.6.18-128.2.1.el5.028stab064.7 ro root=LABEL=/<br />
initrd /initrd-2.6.18-128.2.1.el5.028stab064.7.img</p>
<p>2, Pre-adjustings before the installation</p>
<p>Now we install some OpenVZ user tools:</p>
<p>yum install vzctl vzquota</p>
<p>Open /etc/sysctl.conf and make sure that you have the following settings in it:</p>
<p>cat /etc/sysctl.conf</p>
<p>net.ipv4.ip_forward = 1<br />
net.ipv4.conf.default.proxy_arp = 0<br />
net.ipv4.conf.all.rp_filter = 1<br />
kernel.sysrq = 1<br />
net.ipv4.conf.default.send_redirects = 1<br />
net.ipv4.conf.all.send_redirects = 0<br />
net.ipv4.icmp_echo_ignore_broadcasts=1<br />
net.ipv4.conf.default.forwarding=1</p>
<p>The following step is important if the IP addresses of your virtual machines are from a different subnet than the host system’s IP address. If you don’t do this, networking will not work in the virtual machines!</p>
<p>Open /etc/vz/vz.conf and set NEIGHBOUR_DEVS to all, the modified entry is like this “NEIGHBOUR_DEVS=all“. SELinux needs to be disabled, you can do it by making changes on its config file /etc/sysconfig/selinux. Finally, reboot the system, and then your new OpenVZ kernel should show up:</p>
<p>[root@server1 ~]# uname -r<br />
2.6.18-128.2.1.el5.028stab064.7</p>
<p>3, Create a Virutal Server</p>
<p>Before we can create virtual machines with OpenVZ, we need to have a template for the distribution that we want to use in the virtual machines in the /vz/template/cache by default. New virtual machines will be created from these templates. A list of precreated templates is available here.</p>
<p>I want to use CentOS 5 in my virtual machines, so I download a CentOS 5 template:</p>
<p>cd /vz/template/cache<br />
wget http://download.openvz.org/template/precreated/contrib/centos-5-i386-default.tar.gz</p>
<p>To set up a VPS from the default CentOS 5 template, run:</p>
<p>vzctl create 211 &#8211;ostemplate centos-5-i386-default &#8211;config vps.basic</p>
<p>The 211 must be uniqe and each virtual machine must have its own ID. You can use the last part of the VPS’s IP address for it. For example, if the virtual machine’s IP address is 192.168.0.211, you use 211 as the ID.</p>
<p>4, Common controls on OpenVZ</p>
<p>If you want to have the vm started at boot, run:</p>
<p>vzctl set 211 &#8211;onboot yes &#8211;save</p>
<p>To set a hostname and IP address for the vm, run:</p>
<p>vzctl set 211 &#8211;hostname test.example.com &#8211;save<br />
vzctl set 211 &#8211;ipadd 192.168.0.211 &#8211;save</p>
<p>Next we set the number of sockets to 120 and assign a few nameservers to the vm:</p>
<p>vzctl set 211 &#8211;numothersock 120 &#8211;save<br />
vzctl set 211 &#8211;nameserver 85.17.150.123 &#8211;nameserver 83.149.80.123 &#8211;nameserver 145.253.2.75 &#8211;save</p>
<p>Instead of using the vzctl set commands, you can directly edit vm’s configuration file which is stored in the directory /etc/vz/conf. If the ID of the vm is 211, then the configuration file is /etc/vz/conf/211.conf.</p>
<p>In order to start the vm, run “vzctl start 211″, to set a root password for the vm, run “vzctl exec 211 passwd”. Now You can either connect to the vm via SSH (e.g. with PuTTY), or login through console directly as follows:</p>
<p>vzctl enter 211</p>
<p>To leave the vm’s console, type “exit”, to stop a vm, run “vzctl stop 211“, to restart a vm, run “vzctl restart 211“.</p>
<p>To delete a vm from the hard drive (it must be stopped before you can do this), run “vzctl destroy 211“.</p>
<p>5, Check VM Status</p>
<p>To get a list of your vms and their statuses, run “vzlist -a” like this:</p>
<p>[root@server1 cache]# vzlist -a<br />
VEID      NPROC STATUS  IP_ADDR         HOSTNAME<br />
211         18 running 192.168.0.211   test.example.com</p>
<p>To find out about the resources allocated to a vm, run like follows:</p>
<p>[root@server1 cache]# vzctl exec 211 cat /proc/user_beancounters</p>
<p>The failcnt column is very important, it should be only zeros; if not, means that the vm needs more resources than currently allocated. Open the vm’s configuration file in /etc/vz/conf and raise the appropriate resource, then restart it.</p>
<p>To find out more about the vzctl command, run “man vzctl”.</p>
<p>Article Written By Shahram Azin   <a href="http://www.hostingbangkok.com">http://www.hostingbangkok.com/</a></p>
<div class="awmp_tags"><a href="http://www.hostingbkk.com/search/openVZ Installation/" rel="tag">openVZ Installation</a> <a href="http://www.hostingbkk.com/search/Centos openVZ/" rel="tag">Centos openVZ</a></div><p><a href="http://sharethis.com/item?&wp=3.0.1&amp;publisher=eaf0515d-6ba4-4ac9-9359-d170d1179dd2&amp;title=OpenVZ+Installation+on+Centos&amp;url=http%3A%2F%2Fwww.hostingbkk.com%2F2010%2F06%2F14%2Fopenvz-installation-on-centos%2F">ShareThis</a></p><img src="http://www.hostingbkk.com/?ak_action=api_record_view&id=374&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.hostingbkk.com/2010/06/14/openvz-installation-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

