<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: OpenVZ]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?openvz</link>
<description></description>
<pubDate>Sun, 22 Feb 2009 16:44:34 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[OpenVZ]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?openvz</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div>Tags: OpenVZ, virtualization</div><hr/><div class="wiki">
<p>
<a target="_blank" title="(external link)" href="http://www.openvz.org/">OpenVZ<!-- wiki-renamed-hyperlink "OpenVZ"<http://www.openvz.org/> --></a> is nice name-space virtualization, creating chroot jails on steroids, similar in spirit to Solaris zones. It ideal if you want to run single kernel and allocate resources using bean counters as opposed to hard-limits (20% of CPU as opposed to one core). Each slice is called <tt>VE</tt>.</p>
<div class="nlw_phrase"><table class="wafl_container">
  <tr>
    <td>
      <div class="wafl_box">
        
          <div class="wafl_titlebox">
            <div class="wafl_title">
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            </div>
          </div>
          <div class="wafl_items">
            
              <div class="wiki">
<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#disk_speed">Dobrica Pavlinušić's random unstructured stuff (Disk speed)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Disk speed} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#add_disk_space_to_ve">Dobrica Pavlinušić's random unstructured stuff (Add disk space to VE)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Add disk space to VE} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#ve_management">Dobrica Pavlinušić's random unstructured stuff (VE management)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] VE management} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#update_debian">Dobrica Pavlinušić's random unstructured stuff (Update Debian)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Update Debian} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#quick_reporting">Dobrica Pavlinušić's random unstructured stuff (Quick reporting)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Quick reporting} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#find_getty_processes">Dobrica Pavlinušić's random unstructured stuff (find getty processes)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] find getty processes} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#devices_inside_ve">Dobrica Pavlinušić's random unstructured stuff (devices inside VE)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] devices inside VE} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#links">Dobrica Pavlinušić's random unstructured stuff (Links)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Links} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_tools">Dobrica Pavlinušić's random unstructured stuff (vz-tools)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=tools} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#related_posts_on_my_blog">Dobrica Pavlinušić's random unstructured stuff (Related posts on my blog)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Related posts on my blog} --></span></li>
</ul>
</div>

            
            
          </div>
        
      </div>
    </td>
  </tr>
</table>
<!-- wiki: {toc: }
--></div><br /><br /><h1 id="disk_speed">Disk speed</h1>
<pre>
dpavlin@zut:~$ sudo hdparm -tT /dev/cciss/c1d0 /dev/sda

/dev/cciss/c1d0:
 Timing cached reads:   2184 MB in  2.00 seconds = 1092.39 MB/sec
 Timing buffered disk reads:  324 MB in  3.02 seconds = 107.40 MB/sec

/dev/sda:
 Timing cached reads:   2144 MB in  2.00 seconds = 1071.89 MB/sec
 Timing buffered disk reads:  136 MB in  3.02 seconds =  45.02 MB/sec
</pre>
<br /><p>
Insert joke about <a target="_blank" title="(external link)" href="http://images.google.com/images?hl=en&amp;q=enterprise+storage">enterprise storage<!-- wiki-renamed-hyperlink "enterprise storage"<http://images.google.com/images?hl=en&q=enterprise+storage> --></a></p>
<h1 id="add_disk_space_to_ve">Add disk space to VE</h1>
<p>
We are using normal Linux LVM with single logical volume for all VEs.</p>
<p>
First, resize logical volume:</p>
<pre>
root@koha-hw:~# vgextend -L +80G /dev/vg/vz
vgextend: invalid option -- L
  Error during parsing of command line.

root@koha-hw:~# lvextend -L +80G /dev/vg/vz
  Extending logical volume vz to 100.00 GB
  Logical volume vz successfully resized

root@koha-hw:~# resize2fs /dev/vg/vz 
resize2fs 1.40-WIP (14-Nov-2006)
Filesystem at /dev/vg/vz is mounted on /vz; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 7
Performing an on-line resize of /dev/vg/vz to 26214400 (4k) blocks.
The filesystem on /dev/vg/vz is now 26214400 blocks long.

root@koha-hw:~# df -h /vz/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg-vz      99G   20G   79G  21% /vz
</pre>
<br /><p>
Then, take a look how much space does VEs take:</p>
<pre>
root@koha-hw:~# vzlist -o veid,diskspace,diskspace.s,diskspace.h,diskinodes,diskinodes.s,diskspace.h
      VEID   DQBLOCKS DQBLOCKS.S DQBLOCKS.H   DQINODES DQINODES.S DQBLOCKS.H
    212052   11717220   15728640   20971520      61001     286527   20971520
    212226    6407804   10485760   12582912      69011     435472   12582912
</pre>
<br /><p>
alternativly, you can also execute df inside VEs:</p>
<pre>
root@koha-hw:~# vzlist -o veid -H | xargs -i sh -c &quot;echo --{}-- ; vzctl exec {} df -h&quot;
--212052--
Filesystem            Size  Used Avail Use% Mounted on
simfs                  15G   12G  3.9G  75% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
tmpfs                 2.0G     0  2.0G   0% /dev/shm
--212226--
Filesystem            Size  Used Avail Use% Mounted on
simfs                  10G  6.2G  3.9G  62% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
tmpfs                 2.0G     0  2.0G   0% /dev/shm
</pre>
<br /><p>
next, we will set diskpace on both VEs (becase we want them to share all available resources) to new logical volume size:</p>
<pre>
root@koha-hw:~# vzlist -o veid -H | xargs -i vzctl set {} --diskspace 100G:100G --save
Saved parameters for VE 212052
Saved parameters for VE 212226
</pre>
<br /><p>
This VEs are not in production, and one is development version of another. When we move to production, we want to enforce more strict limit on disk usage, to protect production machine from running out of disk space in case the development one goes wild.</p>
<h1 id="ve_management">VE management</h1>
<p>
We usually want to do some operations on bunch of VEs at once. This can be done using <tt>vzctl exec</tt> in one sweep like this:</p>
<h2 id="update_debian">Update Debian</h2>
<pre>
vzlist -H -o veid | xargs -i vzctl exec {} 'apt-get update &amp;&amp; apt-get -y upgrade' 2&gt;&amp;1 | tee ~/log
</pre>
<br /><h2 id="quick_reporting">Quick reporting</h2>
<p>
You can read more about <a target="_blank" title="(external link)" href="http://blog.rot13.org/2008/05/group_by_data_in_shell_pipes.html">groupby.pl and sum.pl on my blog<!-- wiki-renamed-hyperlink "groupby.pl and sum.pl on my blog"<http://blog.rot13.org/2008/05/group_by_data_in_shell_pipes.html> --></a>.</p>
<pre>
# install dependencies which are not part of standard lenny (sorry!)
cpanp i IPC::System::Simple

dpavlin@mjesec:~$ vzps -E axv --no-headers \
  | groupby.pl 'sum:($7+$8+$9*1024),1,count:1' --join 'sudo vzlist -H -o veid,hostname' --on 2 \
  | sort -rn | align | sum.pl -h
webgui.rot13.org  23      1026M OOOOOOOOOOOO                              1026M
0                385       855M OOOOOOOOOO------------                    1882M
saturn.ffzg.hr    32       544M OOOOOO-----------------------             2427M
eprints.ffzg.hr   18       351M OOOO-----------------------------         2778M
arh.rot13.org     20       224M OO----------------------------------      3003M
</pre>
<br /><h2 id="find_getty_processes">find getty processes</h2>
<pre>
root@mljac:~# ps ax | grep getty | cut -c-5 | xargs vzpid
Pid     VEID    Name
5668    0       getty
5670    0       getty
5672    0       getty
5673    0       getty
5674    0       getty
5675    0       getty
9503    207016  getty
9504    207013  getty
9505    207013  getty
9534    207016  getty
9535    207015  getty
9536    207013  getty
9537    207013  getty
9538    207015  getty
9539    207015  getty
9540    207015  getty
9541    207016  getty
9542    207015  getty
9543    207016  getty
9545    207013  getty
9546    207013  getty
9547    207015  getty
9548    207016  getty
</pre>
<br /><h1 id="devices_inside_ve">devices inside VE</h1>
<p>
For example, <a target="_blank" title="(external link)" href="http://wiki.openvz.org/FUSE">fuse<!-- wiki-renamed-hyperlink "fuse"<http://wiki.openvz.org/FUSE> --></a></p>
<pre>
dpavlin@brr:/dev$ vzctl set 100 --devices c:10:229:rw --save
</pre>
<br /><h1 id="links">Links</h1>
<ul>
<li><a target="_blank" title="(external link)" href="http://community.livejournal.com/openvz/27178.html">Recent Advances in the Linux Kernel resource management<!-- wiki-renamed-hyperlink "Recent Advances in the Linux Kernel resource management"<http://community.livejournal.com/openvz/27178.html> --></a></li>
</ul>
<h1 id="vz_tools">vz-tools</h1>
<span class="nlw_phrase"><div class="wiki-include-page">
<div class="wiki-include-title"><a href='https://saturn.ffzg.hr/rot13/index.cgi?vz_tools' >vz-tools</a> </div>
<div class="wiki-include-content">
<p>
Suite of perl scripts in spirit of <a target="_blank" title="(external link)" href="http://www.xen-tools.org/">xen-tools<!-- wiki-renamed-hyperlink "xen=-tools"<http://www.xen=-tools.org/> --></a> but for <a target="_blank" title="(external link)" href="http://openvz.org/">OpenVZ<!-- wiki-renamed-hyperlink "OpenVZ"<http://openvz.org/> --></a></p>
<div class="nlw_phrase"><table class="wafl_container">
  <tr>
    <td>
      <div class="wafl_box">
        
          <div class="wafl_titlebox">
            <div class="wafl_title">
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            </div>
          </div>
          <div class="wafl_items">
            
              <div class="wiki">
<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#installation">Dobrica Pavlinušić's random unstructured stuff (Installation)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Installation} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#install_perl_dependencies_from_debian_packages">Dobrica Pavlinušić's random unstructured stuff (Install perl dependencies from Debian packages)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Install perl dependencies from Debian packages} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#install_utilities_from_debian_packages">Dobrica Pavlinušić's random unstructured stuff (Install utilities from Debian packages)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Install utilities from Debian packages} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#checkout_source">Dobrica Pavlinušić's random unstructured stuff (Checkout source)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Checkout source} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#check_and_install_perl_modules_from_cpan">Dobrica Pavlinušić's random unstructured stuff (Check and install perl modules from CPAN)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Check and install perl modules from CPAN} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#usage">Dobrica Pavlinušić's random unstructured stuff (Usage)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Usage} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_create_pl">Dobrica Pavlinušić's random unstructured stuff (vz-create.pl)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=create.pl} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_optimize_pl">Dobrica Pavlinušić's random unstructured stuff (vz-optimize.pl)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=optimize.pl} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_clone_pl">Dobrica Pavlinušić's random unstructured stuff (vz-clone.pl)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=clone.pl} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#source">Dobrica Pavlinušić's random unstructured stuff (Source)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Source} --></span></li>
</ul>
</div>

            
            
          </div>
        
      </div>
    </td>
  </tr>
</table>
<!-- wiki: {toc: }
--></div><br /><br /><h1 id="installation">Installation</h1>
<h2 id="install_perl_dependencies_from_debian_packages">Install perl dependencies from Debian packages</h2>
<p>
This step is optional. If you don't want to use perl modules from packages provided by your distribution, skip this step, and modules will be automatically installed in next one.</p>
<pre>
sudo apt-get install libio-prompt-perl libregexp-common-perl libdata-dump-perl
</pre>
<br /><h2 id="install_utilities_from_debian_packages">Install utilities from Debian packages</h2>
<pre>
sudo apt-get install host
</pre>
<br /><h2 id="checkout_source">Checkout source</h2>
<pre>
svn co svn://svn.rot13.org/vz-tools/trunk vz-tools
</pre>
<br /><h2 id="check_and_install_perl_modules_from_cpan">Check and install perl modules from CPAN</h2>
<pre>
cd vz-tools
perl Makefile.PL
make
</pre>
<br /><p>
Please note that there is no need to run <tt>make install</tt></p>
<p>
Tools are runnable from current directory. This will probably change in later versions.</p>
<h1 id="usage">Usage</h1>
<p>
This is quick hand-on overview of commands to get you started.</p>
<p>
All commands must be started with <tt>root</tt> priviledges</p>
<h2 id="vz_create_pl">vz-create.pl</h2>
<p>
This will perform following steps:</p>
<ul>
<li>Create new virtual machine bootstraped using <tt>debootstrap</tt></li>
<li>Change root password</li>
<li>Create single user</li>
<li>Make small custimization like installing <tt>vim</tt> and <a target="_blank" title="(external link)" href="http://www.rot13.org/~dpavlin/apt-iselect.html">apt-iselect<!-- wiki-renamed-hyperlink "apt=-iselect"<http://www.rot13.org/~dpavlin/apt=-iselect.html> --></a></li>
</ul>
<p>
All commands will be echoed on screen, <strong>even passwords</strong>. However, if you want to learn steps in creating OpenVZ VE, this is very helpful.</p>
<p>
To run interactive session which asks questions use:</p>
<pre>
./vz-create.pl
</pre>
<br /><p>
Other alternative is to just enter hostname (defined in <tt>/etc/hosts</tt> for example)</p>
<pre>
./vz-create.pl my-new-ve.exmple.com
</pre>
<br /><p>
or by specifing IP adress</p>
<pre>
./vz-create.pl 192.168.42.42
</pre>
<br /><h2 id="vz_optimize_pl">vz-optimize.pl</h2>
<h2 id="vz_clone_pl">vz-clone.pl</h2>
<pre>
root@black:~/vz-tools# time ./vz-clone.pl create 1001
Clone VE 1001 -&gt; 101001
found LV /dev/vg/vz for /vz
vzquota : (warning) Quota is running, so data reported from quota file may not reflect current values
quota for 1001 | 10485760 &lt; 20971520 | usage: 7826792
using existing /dev/vg/vz-clone-101001
Mounting /dev/vg/vz-clone-101001 to /tmp/vz-clone-101001
rsync /vz/private/1001 -&gt; /tmp/vz-clone-101001/private
101001 new IP number: 10.42.42.42
101001 new hostname: clone-42.example.com

Please review config file: /etc/vz/conf/101001.conf
Add NAT for new VE with: iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Start clone of 1001 with: vzctl start 101001

real    1m57.347s
user    0m2.252s
sys     0m8.591s
</pre>
<br /><h1 id="source">Source</h1>
<div class="nlw_phrase"><div class="fetchrss_box">
  <div class="fetchrss_titlebox">
    
 <div class="fetchrss_title">
     fetchrss: http://svn.rot13.org/index.cgi/vz-tools/rss/trunk
 </div>

  </div>
  
<ul class="fetchrss_item">
  <li class="fetchrss_item">
    There was an error: 500 SSL negotiation failed: 

  </li>
</ul>

</div>
















<!-- wiki: {fetchrss: http://svn.rot13.org/index.cgi/vz-=tools/rss/trunk full}
--></div><br /></div></div><!-- wiki: {include: [vz-=tools]} --></span><br /><br /><h1 id="related_posts_on_my_blog">Related posts on my blog</h1>
<div class="nlw_phrase"><div class="fetchrss_box">
  <div class="fetchrss_titlebox">
    
 <div class="fetchrss_title">
     fetchrss: http://blog.rot13.org/mt/mt-search.cgi?search=openvz&Template=feed&IncludeBlogs=1
 </div>

  </div>
  
<ul class="fetchrss_item">
  <li class="fetchrss_item">
    There was an error: 500 SSL negotiation failed: 

  </li>
</ul>

</div>
















<!-- wiki: {fetchrss: http://blog.rot13.org/mt/mt-=search.cgi?search==openvz&Template==feed&IncludeBlogs==1 full}
--></div><br /></div>
]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category>OpenVZ, virtualization</category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?openvz</guid>
<pubDate>Sun, 22 Feb 2009 16:44:34 -0000</pubDate>
</item>
</channel>
</rss>