<?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>MDLog:/sysadmin &#187; Ubuntu</title> <atom:link href="http://www.ducea.com/category/linux/ubuntu/feed/" rel="self" type="application/rss+xml" /><link>http://www.ducea.com</link> <description>The Journal Of A Linux Sysadmin</description> <lastBuildDate>Sun, 04 Dec 2011 06:53:45 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Build your own packages easily with FPM</title><link>http://www.ducea.com/2011/08/31/build-your-own-packages-easily-with-fpm/</link> <comments>http://www.ducea.com/2011/08/31/build-your-own-packages-easily-with-fpm/#comments</comments> <pubDate>Wed, 31 Aug 2011 22:13:02 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[deb]]></category> <category><![CDATA[debian_packages]]></category> <category><![CDATA[FPM]]></category> <category><![CDATA[rpm]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1369</guid> <description><![CDATA[Building packages is a task that every system administrator will end up doing. Most of the time this is not a very interesting task but someone has to do it, right? Normally you will end up modifying and tweaking based on your own needs an existing package that was built by the maintainers of the [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong>Building packages</strong> is a task that every system administrator will end up doing. Most of the time this is not a very interesting task but someone has to do it, right? Normally you will end up modifying and tweaking based on your own needs an existing package that was built by the maintainers of the Linux distribution that you are using. In time you might even become familiar with the packaging system you are using (rpm, deb, etc.) and you will be able to write a spec file and start from scratch and build a new package if you need to. Still, this <em>process is complicated and requires a lot of work</em>.</p><p>Luckily, <strong><a
href="http://www.semicomplete.com/blog" target="_blank">Jordan Sissel</a></strong> has built a tool called <strong><a
href="https://github.com/jordansissel/fpm" target="_blank">FPM</a></strong> (Effing Package Management), exactly for this: to ease the pain of building new packages; packages that you will use for your own infrastructure and you want them customized based on your own needs; and you don&#8217;t care about upstream rules and standards and other limitations when building such packages. This can be very useful for people deploying their own applications as rpms (or debs) and can simplify a lot of the process of building those packages.</p><p>FPM can be easily installed on your build system using rubygems:<br
/> <code>gem install fpm</code></p><p>Once installed you can use fpm to build <strong>packages</strong> (targets):</p><ul><li>deb</li><li>rpm</li><li>solaris</li></ul><p>from any of the following <strong>sources</strong>:</p><ul><li>directory (of compiled source of some application)</li><li>gem</li><li>python eggs</li><li>rpm</li><li>node npm packages</li></ul><p><span
id="more-1369"></span>Use the command line help (fpm &#8211;help) or the <a
href="https://github.com/jordansissel/fpm/wiki" target="_blank">wiki</a> to see full details on how to use it. I&#8217;ll show some simple examples on how to build some packages from various input sources that I&#8217;ve found useful myself.</p><h3>1. Package a directory &#8211; output of a &#8216;make install&#8217; command</h3><p>This is how you would usually package an application that you would install with:<br
/> <em>./configure; make; make install</em><br
/> For example, here is how you can create an rpm of the latest version of memcached:<br
/> <code>wget http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz<br
/> tar -zxvf memcached-1.4.7.tar.gz<br
/> cd memcached-1.4.7<br
/> ./configure --prefix=/usr<br
/> make</code><br
/> so far everything looks like a normal manual installation (that would be followed by make install). Still we will now install it in a separate folder so we can capture the output:<br
/> <code>mkdir /tmp/installdir<br
/> make install DESTDIR=/tmp/installdir</code><br
/> and finally using fpm to create the rpm package:<br
/> <code>fpm -s dir -t rpm -n memcached -v 1.4.7 -C /tmp/installdir</code><br
/> where <strong>-s</strong> is the input source type (directory), <strong>-t</strong> is the type of package (rpm), <strong>-n</strong> in the name of the package and <strong>-v</strong> is the version; <strong>-C</strong> is the directory where fpm will look for the files.<br
/> Note: you might need to install various libraries to build your package; for ex. in this case I had to install libevent-dev.</p><p>If you are packaging your own application you can do this just by pointing to your build folder and set the version of the app. Here is an example for an deb package:<br
/> <code>fpm -s dir -t deb -n myapp -v 0.0.1 -C /build/myapp/0.0.1/</code></p><p>There are various other parameters that you can use but basically this is how simple it is to build a package from a directory.<br
/> Here is an example on how to define some dependencies on the package you are building (using <strong>-d</strong>; repeat it as many times as needed):<br
/> <code>fpm -s dir -t deb -n memcached -v 1.4.7 -C /tmp/installdir \<br
/> -d "libstdc++6 (&gt;= 4.4.5)" \<br
/> -d "libevent-1.4-2 (&gt;= 1.4.13)"</code></p><h3>2. Ruby gems or python egg &#8211; converted to packages</h3><p>You can create a deb or rpm from a gem very simple with fpm:<br
/> <code>fpm -s gem -t deb &lt;gem_name&gt;</code><br
/> this will download the gem and create a package named rubygem-&lt;gem_name&gt;<br
/> For example:<br
/> <code>fpm -s gem -t deb fpm</code><br
/> will create a debian package for fpm: rubygem-fpm_0.3.7_all.deb</p><p>You can inspect it with<em> dpkg &#8211;info</em> and you can notice that in this case it will fill nicely all the fields with the maintainer, and dependencies on various other gems. Very cool.</p><p>If you use python and want to package various python eggs this will work exactly the same and you will use -s python (it will download the python packages with easy_install first).</p><p>Overall <strong>FPM</strong> is a great tool and can help you<span
style="text-decoration: underline;"><em> simplify the way you are building your own packages</em></span>. Check it out and let me know what you think and if you found it useful. And if you found this useful don’t forget to thank <strong><a
href="http://www.twitter.com/jordansissel" target="_blank">Jordan</a></strong> for his great work on this awesome tool.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2011/08/31/build-your-own-packages-easily-with-fpm/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>HowTo Improve IO Performance for KVM Guests</title><link>http://www.ducea.com/2011/07/06/howto-improve-io-performance-for-kvm-guests/</link> <comments>http://www.ducea.com/2011/07/06/howto-improve-io-performance-for-kvm-guests/#comments</comments> <pubDate>Wed, 06 Jul 2011 17:58:18 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[Virtualization]]></category> <category><![CDATA[kvm]]></category> <category><![CDATA[performance]]></category> <category><![CDATA[xen]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1313</guid> <description><![CDATA[Recently I&#8217;ve worked on a project where we deployed a bunch KVM instances. Immediately we noticed horrible IO performance on all the guests instances. In this particular case the hosts and the guests were all Ubuntu 10.04 Lucid and were created with vmbuilder without any special settings using the ubuntu defaults. Here is a sample [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>Recently I&#8217;ve worked on a project where we deployed a bunch <strong>KVM</strong> instances. Immediately we noticed <em>horrible IO performance</em> on all the guests instances. In this particular case the hosts and the guests were all <em>Ubuntu 10.04 Lucid</em> and were created with <strong>vmbuilder</strong> without any special settings using the ubuntu defaults. Here is a sample command similar to what we used to build the kvm images:</p><p><code>vmbuilder kvm ubuntu --suite=lucid --flavour=virtual --arch=amd64 --mirror=http://en.archive.ubuntu.com/ubuntu -o --libvirt=qemu:///system --ip=10.0.0.11 --gw=10.0.0.1 --part=vmbuilder.partition --templates=mytemplates --user=username --pass=password --firstboot=/var/vms/vm1/boot.sh --mem=1024 --hostname=myhost --bridge=br0</code></p><p>Now even if we haven&#8217;t tuned anything I would have expected it to perform at least the same level or even better compared with a <strong>Xen</strong> instance. Still, this was not the case, and the performance was really horrible and any kind of IO bound tasks would effectively lock the instance. Looking into this and trying to understand what was the problem I was able to isolate this issue happening only on instances that had <strong>ext4</strong> as the filesystem (the default for lucid), but strangely enough this didn&#8217;t happen for an older instance that was build with <strong>ext3</strong> (actually a <em>debian lenny</em> instance). All the images build with the above command will use <strong>qcow2</strong> sparse format as the default format for the disk.</p><p><span
id="more-1313"></span>In order to achieve good IO performance we had to use <strong>cache=&#8217;writeback&#8217;</strong> for the instances and this will significantly increase the IO performance and bring it almost to host level performance, but in anycase much better compared with the old xen instances we had. Here is how you can enable writeback for an instance: stop the vm; edit the guestdomain and add cache=writeback in the driver section, save and start back the vm:<br
/> <code>virsh --connect qemu:///system<br
/> stop guestdomain<br
/> edit guestdomain   &lt;-- add cache='writeback' in the driver section<br
/> start guestdomain</code></p><p>Here is the how the disk part of my guest domain looks like after adding the cache writeback:<br
/> <code>&lt;disk type='file' device='disk'&gt;<br
/> &lt;driver name='qemu' type='qcow2' <strong>cache='writeback'</strong>/&gt;<br
/> &lt;source file='/var/vms/vm2/ubuntu-kvm/tmphAUcOB.qcow2'/&gt;<br
/> &lt;target dev='hda' bus='ide'/&gt;<br
/> &lt;/disk&gt;</code></p><p>In the process of debugging and searching for a fix for this issue, I&#8217;ve found out that it can also be useful to use <strong>elevator=noop</strong> as the <em>default kernel io scheduler</em>; this definitely helps, but not to the same extend as the cache writeback setting on the virtio disk. You can add elevator=noop to your kernel command line in your grub config, and I have this by default on all the instances.</p><p>Hopefully this will help you greatly improve IO performance for your KVM guests and will save you the time I&#8217;ve lost while trying to find a solution to this problem. Please feel free to share your experiences using the comment form bellow; also I&#8217;m curious if you have any other tips on how to improve this even more.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2011/07/06/howto-improve-io-performance-for-kvm-guests/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Multiple java versions on debian</title><link>http://www.ducea.com/2010/08/09/multiple-java-versions-on-debian/</link> <comments>http://www.ducea.com/2010/08/09/multiple-java-versions-on-debian/#comments</comments> <pubDate>Mon, 09 Aug 2010 23:56:14 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[java]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=1098</guid> <description><![CDATA[Debian has a nice way to handle multiple java installations on a the same machine. Let&#8217;s say that for some reason you want to have sun-java 1.5 and also 1.6 installed on the server, we can easily configure the default one with the update-java-alternatives command (part of the java-common package). Here is how it can [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>Debian has a nice way to handle <strong>multiple java installations</strong> on a the same machine. Let&#8217;s say that for some reason you want to have <em>sun-java 1.5</em> and also <em>1.6</em> installed on the server, we can easily configure the default one with the <strong>update-java-alternatives</strong> command (part of the <em>java-common</em> package). Here is how it can be used:</p><p>To see what versions of java we have installed on the system (from debian packages):<br
/> <code>update-java-alternatives -l<br
/> java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun<br
/> java-6-sun 63 /usr/lib/jvm/java-6-sun</code></p><p>We can see that the default version is 1.6 in my case (as it was the last installed):<br
/> <code>java -version<br
/> java version "1.6.0_20"<br
/> Java(TM) SE Runtime Environment (build 1.6.0_20-b02)<br
/> Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)</code></p><p>We can change the default version with: update-java-alternatives &#8211;jre -s &lt;ver&gt; , like:<br
/> <code><strong>update-java-alternatives</strong> --jre -s java-1.5.0-sun</code><br
/> and now the default is 1.5:<br
/> <code>java -version<br
/> java version "1.5.0_22"<br
/> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)<br
/> Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode, sharing)</code></p><p>This is quite handy if you need to have multiple java versions installed, and need a quick way to change the default one (you can access any of them directly from their own path of course).</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2010/08/09/multiple-java-versions-on-debian/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Apache2 umask</title><link>http://www.ducea.com/2009/08/03/apache2-umask/</link> <comments>http://www.ducea.com/2009/08/03/apache2-umask/#comments</comments> <pubDate>Mon, 03 Aug 2009 23:21:49 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[apache-tips-and-tricks]]></category> <category><![CDATA[tips]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=951</guid> <description><![CDATA[Many times you might want to fine tune the default permissions of the files created on a linux system. This is very simple and usually if you are using bash all you have to do is to define somewhere in the bash startup files (/etc/profile is a good place for this) a new value for [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>Many times you might want to fine tune the <strong>default permissions</strong> of the files created on a linux system. This is very simple and usually if you are using <strong>bash</strong> all you have to do is to define somewhere in the bash startup files (<em>/etc/profile</em> is a good place for this) a new value for <strong>umask</strong> like this:<br
/> <code>umask 002</code><br
/> (this will allow by default group write permissions on the newly created files)</p><p>Normally on modern linux distributions this is by <em>default set to 022</em> and you can easily find out what it is on your system by running the umask command:<br
/> <code>umask</code></p><p>Contrary to what you might think, this is not enough to have this working for all applications and daemons on the system. This works fine for any files created from a shell session, but the files created by other processes, like the web server for example, will still use the default, unless otherwise configured. In order to have <strong>apache</strong> use a <strong>different umask</strong> we can define this inside <strong>/etc/apache2/envvars</strong> (debian, and ubuntu systems) or /etc/sysconfig/httpd (rhel,centos systems) like this:<br
/> <code>umask 002</code><br
/> and restart apache to enable it.</p><p>Other daemons will have different locations where you can define this to overwrite the default setting for umask (check their documentation if you are unsure).</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/08/03/apache2-umask/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>PHP Sessions in Memcached</title><link>http://www.ducea.com/2009/06/02/php-sessions-in-memcached/</link> <comments>http://www.ducea.com/2009/06/02/php-sessions-in-memcached/#comments</comments> <pubDate>Tue, 02 Jun 2009 10:15:34 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Scaling]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[memcached]]></category> <category><![CDATA[pecl]]></category> <category><![CDATA[php5]]></category> <category><![CDATA[php_extensions]]></category> <category><![CDATA[php_modules]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=903</guid> <description><![CDATA[The moment a PHP application grows to run on more servers, normally people will see problems caused by PHP sessions. If the application is not persistent you are lucky and don&#8217;t care about this, but if not you will quickly see this regardless of how good the load balancer you use is handling stickiness (sending [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>The moment a <em>PHP application grows to run on more servers</em>, normally people will see problems caused by <strong>PHP sessions</strong>. If the application is not persistent you are lucky and don&#8217;t care about this, but if not you will quickly see this regardless of how good the load balancer you use is handling stickiness (sending the users to the same real server), this will slowly become a major issue. There are various solutions that can be used to store PHP sessions in a <strong>shared location</strong>, but I want to present today one solution that is very simple to implement, yet very efficient and on the long term better suited than using a database backend for this: using <a
href="http://danga.com/memcached" target="_blank"><strong>memcache</strong></a> to store the sessions.</p><p>The <a
href="http://pecl.php.net/package/memcache" target="_blank">pecl memcache php extension</a> has supported for a long time the memcache session.save_handler, but with the release <strong>3.0.x</strong> (still in beta at this time) this brings in a set of interesting <a
href="http://pecl.php.net/package/memcache/3.0.0" target="_blank">features</a> for us:<br
/> - UDP support<br
/> - Binary protocol support<br
/> - Non-blocking IO using select()<br
/> - Key and session redundancy (values are written to N mirrors)<br
/> - Improved error reporting and failover handling</p><p><span
id="more-903"></span>Installing the php memcache module is very simple and can be done either by using distribution repositories (the version we want to use 3.0.x will probably not be available) or by using pecl or manual compilation:</p><p>Using pecl:<br
/> <code>pecl install memcache-3.0.4</code></p><p>or manually:<br
/> <code>wget http://pecl.php.net/get/memcache-3.0.4.tgz<br
/> tar xvfz memcache-3.0.4.tgz<br
/> cd memcache-3.0.4<br
/> phpize<br
/> ./configure<br
/> make<br
/> make install</code></p><p>Finally, we need to <em>activate the module in php.ini</em>. I normally prefer to create a new file for this <strong>memcache.ini</strong> inside the include directory of the php build (for ex. in debian this is under <strong>/etc/php5/conf.d/memcache.ini</strong>) like this:<br
/> <code>extension=memcache.so<br
/> memcache.allow_failover = 1<br
/> memcache.redundancy = 1<br
/> memcache.session_redundancy = 2</code></p><p>To use memcached to store the <strong>php sessions</strong> we will have to edit php.ini and replace the default file handler settings with something like:<br
/> <code>; Use memcache as a session handler<br
/> session.save_handler = memcache<br
/> ; Use a comma separated list of server urls to use for storage:<br
/> session.save_path="udp://&lt;memcache_server&gt;:11211?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15"</code></p><p>or if we don&#8217;t want to use this serverwide, we can just define it inside a php block like this:</p><pre><code>$session_save_path = "tcp://&lt;memcache_server1&gt;:11211?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15, tcp://&lt;memcache_server2&gt;:11211";
ini_set('session.save_handler', 'memcache');
ini_set('session.save_path', $session_save_path);</code></pre><p>Note: as you can see I used in the above example tcp and udp also. Please be sure that your memcached server has udp support enabled if you want to use that. Also ensure that the web server can connect to the memcache server/port (use proper firewall rules to allow this) in order for this to work.</p><p>After restarting apache, it will start using memcache to store the php sessions. If redundancy is needed (why not?) we will probably want to use the internal php memcache support to save the sessions to more servers, or if you prefer you can use an external solution to replicate the memcached server data &#8211; <a
href="http://repcached.lab.klab.org/" target="_blank">repcached</a>.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/06/02/php-sessions-in-memcached/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Official Ubuntu Amazon EC2 AMIs</title><link>http://www.ducea.com/2009/04/29/official-ubuntu-amazon-ec2-amis/</link> <comments>http://www.ducea.com/2009/04/29/official-ubuntu-amazon-ec2-amis/#comments</comments> <pubDate>Wed, 29 Apr 2009 11:30:36 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Cloud Computing]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[News from Outside]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[amazon]]></category> <category><![CDATA[ami]]></category> <category><![CDATA[ec2]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=854</guid> <description><![CDATA[Ubuntu released official images for Amazon EC2 for Intrepid (8.10) and Hardy (8.04) releases (not Jaunty image yet). These are server edition images. I&#8217;ve always used the great alestic ec2 images created by Eric Hammond for any Ubuntu or Debian release I needed in the past and was very happy with the quality of the [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong>Ubuntu </strong><a
href="http://www.ubuntu.com/ec2" target="_blank">released official images</a> for <strong>Amazon EC2</strong> for Intrepid (8.10) and Hardy (8.04) releases (not Jaunty image yet). These are <em>server edition images</em>. I&#8217;ve always used the great <a
href="http://alestic.com/" target="_blank">alestic ec2 images</a> created by <a
href="http://www.anvilon.com/" target="_blank">Eric Hammond</a> for any Ubuntu or Debian release I needed in the past and was very happy with the quality of the images Eric maintained. This was also seen by the Ubuntu team and they worked with Eric to create their official images with the same quality and most of the features of what most people were used for Ubuntu images so far in EC2 world.</p><p>In my opinion here are the <strong>advantages </strong>of the newly released official Ubuntu images:</p><ul><li><strong>officially support</strong> by Canonical (Eric has done a great job in patching and updating his images, but I am sure he has better things to do and let the Ubuntu team do this).</li><li><strong>custom kernels</strong>: for Intrepid <strong>2.6.27</strong> and Hardy <strong>2.6.24</strong> by having Amazon support in doing this (while alestic images were using the default Amazon Fedora kernel 2.6.21 image).</li><li><strong>apt mirrors</strong> in the ec2 cloud provided by Ubuntu: <em>us.ec2.archive.ubuntu.com</em> and <em>eu.ec2.archive.ubuntu.com</em></li><li><strong>RightScale </strong>support for advanced integration with the RightScale platform for RightScale users.</li></ul><p><span
id="more-854"></span>Starting a default small instance Intrepid US image (check for the <a
href="https://help.ubuntu.com/community/EC2StartersGuide" target="_blank">current AMI Ids</a>):<br
/> <code>ec2-run-instances ami-5059be39 -k my-keypair<br
/> ec2-describe-instances<br
/> ssh -i .ec2/id_rsa-my-keypair <strong>ubuntu</strong>@ec2-x-x-x-x.compute-1.amazonaws.com<br
/> sudo su -</code><br
/> <em>Note: you have to login as ubuntu user and sudo as root.</em></p><p>Don&#8217;t forget to shutdown your instances when you are done, to avoid unneeded charges <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p><p>For more details: <a
href="http://www.ubuntu.com/ec2" target="_blank">http://www.ubuntu.com/ec2</a></p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/04/29/official-ubuntu-amazon-ec2-amis/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>iptables geoip match on debian lenny</title><link>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/</link> <comments>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/#comments</comments> <pubDate>Wed, 18 Mar 2009 13:56:31 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[geoip]]></category> <category><![CDATA[iptables]]></category> <category><![CDATA[kernel_modules]]></category> <category><![CDATA[lenny]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=818</guid> <description><![CDATA[The geoip iptables extension allows you to filter, nat or mangle packets based on the country&#8217;s source or destination. This does exactly what the geoip apache module does, or the regular geoip binary, but at the iptables level. I would not go into the details why you would want to use that, but there are [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>The <strong>geoip iptables extension</strong> allows you to filter, nat or mangle packets based on the country&#8217;s source or destination. This does exactly what the geoip apache module does, or the regular geoip binary, but at the iptables level. I would not go into the details <strong>why </strong>you would want to use that, but there are many &#8216;positive&#8217; ways it can be useful&#8230; For example myself I use it in a project where we want to<em> serve customized content for different countries</em>. Since this is a high traffic site running on many web servers behind a loadbalanced setup, we prefer to split this at the <em>loadbalancer level</em> and not at apache level, to simplify our setup. We serve customized content to the US based visitors, while for the other countries we serve another international site.</p><p>Now this has been working fine for a long time now, using the <a
href="http://people.netfilter.org/peejix/geoip/" target="_blank">original geoip module</a> and <strong>patch-o-matic-ng</strong> method of installation (similar to what is very well <a
href="http://www.debian-administration.org/articles/518" target="_blank">described here</a>). Still, this is unmaintained, and starting with <strong>kernel 2.6.22</strong> it is no longer working. There is a <a
href="http://bjerkeset.com/patches/geoip-match-2.6.22.patch.gz" target="_blank">patch</a> that will make it work with a newer kernel, but if you run <strong>iptables 1.4.x</strong> this will again fail and even if there are some manual walkarounds this is still not the best solution.</p><p>The solution is called <strong>Xtables-addons</strong>. <a
href="http://xtables-addons.sourceforge.net/" target="_blank">Xtables-addons</a> is the successor to patch-o-matic-ng. Likewise, <em>it contains extensions that were not, or are not yet, accepted in the main kernel/iptables packages. Xtables-addons is different from patch-o-matic in that you do not have to patch or recompile the kernel, sometimes recompiling iptables is also not needed.</em><br
/> The latest version <strong>1.12</strong> <a
href="http://xtables-addons.git.sourceforge.net/git/gitweb.cgi?p=xtables-addons;a=blob;hb=master;f=INSTALL" target="_blank">supports</a>: iptables &gt;= 1.4.1 and kernel-source &gt;= 2.6.17.</p><p><span
id="more-818"></span>The installation is very simple and requires only the following steps exemplified on a <strong>debian lenny</strong> machine (kernel 2.6.26 and iptables 1.4.2):</p><p><strong>1.</strong> Install the needed <strong>dependencies</strong>: kernel headers and iptables dev:<br
/> <code>aptitude install linux-headers-2.6.26-1-amd64 iptables-dev</code><br
/> <em>libtext-csv-xs-perl</em> will be also needed if you plan to update the database (normally you will want this to be able to update the db from time to time):<br
/> <code>aptitude install libtext-csv-xs-perl</code></p><p><strong>2.</strong> <strong>Download </strong>the xtables-addons package and the supplied <a
href="http://jengelh.medozas.de/files/geoip/" target="_blank">database</a> (or the <a
href="http://jengelh.medozas.de/files/geoip/geoip_src.tar.bz2" target="_blank">sources</a> to build your own):<br
/> <code>wget http://switch.dl.sourceforge.net/sourceforge/xtables-addons/xtables-addons-1.12.tar.bz2<br
/> wget http://jengelh.medozas.de/files/geoip/geoip_iv0_database-20090201.tar.bz2<br
/> </code><br
/> <strong>3.</strong> Configure and <strong>compile </strong>the package. There are several iptables modules included; you can leave them all enabled or choose to compile and install only the ones needed. For this edit the <strong>mconfig </strong>file and leave only the ones you want:<br
/> <code>build_CHAOS=m<br
/> build_DELUDE=m<br
/> build_DHCPADDR=m<br
/> build_ECHO=<br
/> build_IPMARK=m<br
/> build_LOGMARK=m<br
/> build_SYSRQ=m<br
/> build_TARPIT=m<br
/> build_TEE=m<br
/> build_condition=m<br
/> build_fuzzy=m<br
/> <strong>build_geoip=m</strong><br
/> build_ipp2p=m<br
/> build_ipset=m<br
/> build_length2=m<br
/> build_lscan=m<br
/> build_quota2=m</code></p><p>Compile and install:<br
/> <code>./configure --with-xtlibdir=/lib/xtables<br
/> make<br
/> make install</code></p><p>this will add the iptables extension <strong>/lib/xtables/libxt_geoip.so</strong> and the kernel module in /lib/modules/&lt;kernel&gt;<strong>/extra/xt_geoip.ko</strong></p><p><strong>4.</strong> Now we have to put the <strong>geoip database files</strong> under the expected location (<strong>/var/geoip</strong>); this is hardcoded in the code, but you can change it if really needed and recompile. I would like to add that even if this uses the same geoip source (the <a
href="http://www.maxmind.com/app/geolitecountry" target="_blank">free GeoLite Country database</a>) as the original geoip iptables module, but the format has changed. You can either get the database from the source, or build your own with the supplied script. Once you have that copy the files to /var/geoip</p><p><code>wget http://www.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip<br
/> unzip GeoIPCountryCSV.zip<br
/> ./runme.sh<br
/> cp -R var/geoip/ /var/</code></p><p>That&#8217;s it! All you have to do is use the module based on your needs. The syntax is the same as the original geoip iptables module:<br
/> <em> [!] &#8211;src-cc, &#8211;source-country country[,country...] = Match packet coming from (one of) the specified country(ies)<br
/> [!] &#8211;dst-cc, &#8211;destination-country country[,country...] = Match packet going to (one of) the specified country(ies)<br
/> NOTE:  The country is inputed by its ISO3166 code.</em></p><p>We use something like this to mark and send each type of traffic to its own destination:<br
/> <code>iptables -t mangle -A PREROUTING -p tcp -m geoip --src-cc US -d &lt;IP&gt; --dport 80 -j MARK --set-mark 1<br
/> iptables -t mangle -A PREROUTING -p tcp -m geoip ! --src-cc US -d &lt;IP&gt; --dport 80 -j MARK --set-mark 2</code></p><p>I hope you found this article useful, and as me, are grateful that <strong>Xtables-addons</strong> project took over the patch-o-matic-ng broken modules and made them available on current distributions. Xtables-addons was also accepted in debian repository (in <a
href="http://packages.debian.org/squeeze/xtables-addons-source" target="_blank">testing</a>) and this will make it even simpler to install and use in the future.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>iotop: simple top-like i/o monitor</title><link>http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/</link> <comments>http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/#comments</comments> <pubDate>Tue, 10 Mar 2009 16:04:05 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[iotop]]></category> <category><![CDATA[vmstat]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=717</guid> <description><![CDATA[iotop does for I/O usage what top does for CPU usage. It watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes on the system. This tool is written by Guillaume Chazarain and requires Python &#62;= 2.5 and a Linux kernel &#62;= [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong><a
href="http://guichaz.free.fr/iotop/" target="_blank">iotop</a> </strong>does for <strong>I/O usage</strong> what <strong>top </strong>does for <strong>CPU usage</strong>. It watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes on the system. This tool is written by <em>Guillaume Chazarain</em> and requires <strong>Python &gt;= 2.5</strong> and a <strong>Linux kernel &gt;= 2.6.20</strong> to run. This post introduces this very useful tool and shows how we can install it and use it.</p><p><a
href="http://www.ducea.com/images/iotop_big.png"><img
class="alignright" title="iotop" src="http://www.ducea.com/images/iotop.png" alt="" width="150" height="99" /></a>iotop can be <a
href="http://guichaz.free.fr/iotop/" target="_blank">downloaded</a> either as source package or a rpm package. Starting with <strong>lenny</strong>, <em>debian includes <a
href="http://packages.debian.org/lenny/iotop" target="_blank">iotop</a></em> in the main repository and it can be installed just as simple as running:<br
/> <code>aptitude install iotop</code>This is very cool indeed and kudos to the debian team to include iotop in lenny <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br
/> <span
id="more-717"></span><br
/> For other distributions, we can install it from source using the following simple steps (be sure to have python2.5 before trying this); I am using git and this will download the latest trunk version 3, if this is not what you want download the tar.gz (ver 0.2.1) and use the stable version instead.<br
/> <code>git clone git://repo.or.cz/iotop.git<br
/> cd iotop<br
/> ./setup.py install</code><br
/> after this <strong>iotop </strong>will be installed under <strong>/usr/bin</strong>.</p><p>Let’s see what are the program parameters:</p><pre><code>iotop -h
Usage: /usr/bin/iotop [OPTIONS]

DISK READ and DISK WRITE are the block I/O bandwidth used during the sampling
period. SWAPIN and IO are the percentages of time the thread spent respectively
while swapping in and waiting on I/O more generally. PRIO is the I/O priority at
which the thread is running (set using the ionice command).
Controls: left and right arrows to change the sorting column, r to invert the
sorting order, o to toggle the --only option, p to toggle the --processes
option, q to quit, any other key to force a refresh.

Options:
--version             show program's version number and exit
-h, --help            show this help message and exit
-o, --only            only show processes or threads actually doing I/O
-b, --batch           non-interactive mode
-n NUM, --iter=NUM    number of iterations before ending [infinite]
-d SEC, --delay=SEC   delay between iterations [1 second]
-p PID, --pid=PID     processes/threads to monitor [all]
-u USER, --user=USER  users to monitor [all]
-P, --processes       only show processes, not all threads</code></pre><p>We can run it interactively, just like top, by simply typing: <strong>iotop</strong>, or add some parameters like<br
/> <code>iotop -o -d 2</code><br
/> We can also run it in batch mode using <strong>-b</strong>:<br
/> <code>iotop -b -o -d 5<br
/> ...<br
/> Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s<br
/> TID PRIO USER      DISK READ  DISK WRITE   SWAPIN    IO    COMMAND<br
/> Total DISK READ: 0.00 B/s | Total DISK WRITE: 2.49 M/s<br
/> TID PRIO USER      DISK READ  DISK WRITE   SWAPIN    IO    COMMAND<br
/> 19215 be/1 mysql       0.00 B/s    1.24 M/s  0.00 %  2.58 % mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock<br
/> 11670 be/1 mysql       0.00 B/s  152.28 K/s  0.00 %  0.64 % mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock<br
/> 11656 be/1 mysql       0.00 B/s    1.11 M/s  0.00 %  0.00 % mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock</code></p><p>Other similar tools are <strong>iopp </strong>(presented in a <a
href="http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/">previous post</a>) and <strong>pidstat </strong>from newer sysstat packages (&gt;= Sysstat 8.0.0). <span
style="text-decoration: line-through;">Stay tuned for a future post on</span> <a
href="http://www.ducea.com/2009/03/11/howto-install-iotop-on-debian-etch/">here is how</a> you can run iotop on debian etch (that uses by default python2.4).</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/10/iotop-simple-top-like-io-monitor/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>iopp: howto get i/o information per process</title><link>http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/</link> <comments>http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/#comments</comments> <pubDate>Mon, 09 Mar 2009 10:30:16 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[iopp]]></category> <category><![CDATA[vmstat]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=712</guid> <description><![CDATA[We all know and love vmstat, but wouldn&#8217;t it be nice to get such information on a per process basis, to be able to better understand what is causing i/o problems? This is exactly what iopp, written by Mark Wong and released as open source does: &#8220;It&#8217;s a custom tool to go through the Linux [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p>We all know and love <strong>vmstat</strong>, but wouldn&#8217;t it be nice to get such information on a <strong>per process</strong> basis, to be able to better understand what is causing <strong>i/o</strong> problems? This is exactly what <strong>iopp</strong>, written by <em>Mark Wong</em> and released as open source does:<br
/> <em>&#8220;It&#8217;s a custom tool to go through the Linux process table to get i/o statistics per process. It is open source and can be downloaded from: <a
href="http://git.postgresql.org/?p=~markwkm/iopp.git;a=summary" target="_blank">http://git.postgresql.org/?p=~markwkm/iopp.git;a=summary</a>&#8220;</em></p><p>Now this sounds interesting, and I am sure anyone that has dealt with i/o issues in the past will probably find this very useful. Let&#8217;s see how we can <strong>install </strong>it and what kind of reporting we get. We will install this from source and here are some quick steps to do this (you will need git and cmake for this):<br
/> <code>git clone git://git.postgresql.org/git/~markwkm/iopp.git<br
/> cd iopp<br
/> cmake CMakeLists.txt<br
/> make</code></p><p><span
id="more-712"></span>And install it:<br
/> <code>make install DESTDIR=/usr<br
/> [100%] Built target iopp<br
/> Install the project...<br
/> -- Install configuration: ""<br
/> -- Installing /usr/bin/iopp<br
/> -- Installing /usr/share/man/man8/iopp.8</code><br
/> after this <strong>iopp </strong>will be installed into <strong>/usr/bin</strong>.</p><p>Let&#8217;s see what are the program parameters:<br
/> <code>iopp -h<br
/> usage: iopp -h|--help<br
/> usage: iopp [-ci] [-k|-m] [delay [count]]<br
/> -c, --command display full command line<br
/> -h, --help display help<br
/> -i, --idle hides idle processes<br
/> -k, --kilobytes display data in kilobytes<br
/> -m, --megabytes display data in megabytes<br
/> -u, --human-readable display data in kilo-, mega-, or giga-bytes</code></p><p>And finally let&#8217;s test it:<br
/> <code>iopp -i -u 5<br
/> pid rchar wchar    syscr    syscw reads writes cwrites command<br
/> 2464    0B    0B        0        0    0B  8192B      0B kjournald<br
/> 3364  515K    0B     1336        0    0B     0B      0B mysqld<br
/> 4664    0B  134B        0        4    0B     0B      0B apache2<br
/> 4685  803K  114K      454       80    0B     0B      0B collectd<br
/> 20758   82K   82K      329      329    0B    84K      0B cronolog<br
/> 26236   67K 3754B       59       27    0B     0B      0B apache2<br
/> ...</code></p><p>The manual page explains each output field:</p><ul><li> <strong>pid</strong>: The process id.</li><li> <strong>rchar</strong>: The number of bytes which this task has caused to be read from storage.</li><li> <strong>wchar</strong>: The number of bytes which this task has caused, or shall cause to be written to disk.</li><li> <strong>syscr</strong>: Count of the number of read I/O operations.</li><li> <strong>syscw</strong>: Count of the number of write I/O operations.</li><li> <strong>rbytes rkb rmb reads</strong>: Count of the number of bytes which this process really did cause to be fetched from the storage layer.</li><li> <strong>wbytes wkb wmb writes</strong>: Count of the number of bytes which this process really did cause to be sent to the storage layer.</li><li> <strong>cwbytes cwkb cwmb cwrites</strong>: The number of bytes which this process caused to not happen, by truncating pagecache.</li><li> <strong>command</strong>: Filename of the executable.</li></ul><p>Other similar tools are <strong><a
href="http://guichaz.free.fr/iotop/" target="_blank">iotop</a> </strong>and <strong>pidstat </strong>from newer <strong>sysstat </strong>packages and I will describe them in a future post.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/09/iopp-howto-get-io-information-per-process/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Mdadm Cheat Sheet</title><link>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/</link> <comments>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/#comments</comments> <pubDate>Sun, 08 Mar 2009 11:19:20 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Centos]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fedora]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Tips & Tricks]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[cheatsheet]]></category> <category><![CDATA[mdadm]]></category> <category><![CDATA[raid]]></category> <category><![CDATA[tips]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=691</guid> <description><![CDATA[Mdadm is the modern tool most Linux distributions use these days to manage software RAID arrays; in the past raidtools was the tool we have used for this. This cheat sheet will show the most common usages of mdadm to manage software raid arrays; it assumes you have a good understanding of software RAID and [...]<p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p> ]]></description> <content:encoded><![CDATA[<p><strong>Mdadm </strong>is the modern tool most Linux distributions use these days to manage <strong>software RAID</strong> arrays; in the past <em>raidtools </em>was the tool we have used for this. This cheat sheet will show the most <em>common usages of mdadm</em> to manage software raid arrays; it assumes you have a good understanding of software RAID and Linux in general, and it will just explain the commands line usage of mdadm. The examples bellow use RAID1, but they can be adapted for any RAID level the Linux kernel driver supports.</p><h3>1. Create a new RAID array</h3><p>Create (mdadm &#8211;create) is used to create a new array:<br
/> <code>mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2</code><br
/> <span
id="more-691"></span>or using the compact notation:<br
/> <code>mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1</code></p><h3>2. /etc/mdadm.conf</h3><p>/etc/mdadm.conf or /etc/mdadm/mdadm.conf (on debian) is the main configuration file for mdadm. After we create our RAID arrays we add them to this file using:<br
/> <code>mdadm --detail --scan &gt;&gt; /etc/mdadm.conf</code><br
/> or on debian<br
/> <code>mdadm --detail --scan &gt;&gt; /etc/mdadm/mdadm.conf</code></p><h3>3. Remove a disk from an array</h3><p>We can&#8217;t remove a disk directly from the array, unless it is failed, so we first have to fail it (if the drive it is failed this is normally already in failed state and this step is not needed):<br
/> <code>mdadm --fail /dev/md0 /dev/sda1</code><br
/> and now we can remove it:<br
/> <code>mdadm --remove /dev/md0 /dev/sda1</code></p><p>This can be done in a single step using:<br
/> <code>mdadm /dev/md0 --fail /dev/sda1 --remove /dev/sda1</code></p><h3>4. Add a disk to an existing array</h3><p>We can add a new disk to an array (replacing a failed one probably):<br
/> <code>mdadm --add /dev/md0 /dev/sdb1</code></p><h3>5. Verifying the status of the RAID arrays</h3><p>We can check the status of the arrays on the system with:<br
/> <code>cat /proc/mdstat</code><br
/> or<br
/> <code>mdadm --detail /dev/md0</code></p><p>The output of this command will look like:</p><pre><code>cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
104320 blocks [2/2] [UU]

md1 : active raid1 sdb3[1] sda3[0]
19542976 blocks [2/2] [UU]

md2 : active raid1 sdb4[1] sda4[0]
223504192 blocks [2/2] [UU]</code></pre><p>here we can see both drives are used and working fine &#8211; <strong>U</strong>. A failed drive will show as <strong>F</strong>, while a degraded array will miss the second disk <strong>-</strong></p><p>Note: while monitoring the status of a RAID rebuild operation using watch can be useful:<br
/> <code>watch cat /proc/mdstat</code></p><h3>6. Stop and delete a RAID array</h3><p>If we want to completely remove a raid array we have to stop if first and then remove it:<br
/> <code>mdadm --stop /dev/md0<br
/> mdadm --remove /dev/md0</code><br
/> and finally we can even delete the superblock from the individual drives:<br
/> <code>mdadm --zero-superblock /dev/sda</code></p><p>Finally in using RAID1 arrays, where we create <strong>identical partitions</strong> on both drives this can be useful to copy the partitions from sda to sdb:<br
/> <code>sfdisk -d /dev/sda | sfdisk /dev/sdb</code></p><p>(this will dump the partition table of sda, removing completely the existing partitions on sdb, so be sure you want this before running this command, as it will not warn you at all).</p><p>There are many other usages of <strong>mdadm </strong>particular for each type of RAID level, and I would recommend to use the manual page (<em>man mdadm</em>) or the help (<em>mdadm &#8211;help</em>) if you need more details on its usage. Hopefully these quick examples will put you on the fast track with how mdadm works.</p><p><a
href="http://www.thycotic.com/zSS_Ducea.html?utm_source=ducea&utm_medium=banner&utm_content=iquit&utm_campaign=SSDucea"><img
src="http://www.ducea.com/images/SS468by60.jpg"></a></p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/feed/</wfw:commentRss> <slash:comments>58</slash:comments> </item> </channel> </rss>
<!-- Served from: www.ducea.com @ 2012-02-06 23:11:48 by W3 Total Cache -->
