<?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>Tue, 13 Jul 2010 02:03:18 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0</generator> <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 [...]]]></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>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/08/03/apache2-umask/feed/</wfw:commentRss> <slash:comments>3</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 [...]]]></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>]]></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 [...]]]></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>]]></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 [...]]]></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>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/18/iptables-geoip-match-on-debian-lenny/feed/</wfw:commentRss> <slash:comments>10</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;= [...]]]></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>]]></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 [...]]]></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>]]></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 [...]]]></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>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/feed/</wfw:commentRss> <slash:comments>27</slash:comments> </item> <item><title>HowTo force remote devices (routers/switches) to refresh their arp cache entry for a machine</title><link>http://www.ducea.com/2009/03/06/howto-force-remote-devices-routersswitches-to-refresh-their-arp-cache-entry-for-a-machine/</link> <comments>http://www.ducea.com/2009/03/06/howto-force-remote-devices-routersswitches-to-refresh-their-arp-cache-entry-for-a-machine/#comments</comments> <pubDate>Fri, 06 Mar 2009 20:02:14 +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[arp]]></category> <category><![CDATA[arping]]></category> <category><![CDATA[router]]></category> <category><![CDATA[switch]]></category> <category><![CDATA[tips]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=679</guid> <description><![CDATA[The Address Resolution Protocol (ARP) is the method for finding a host&#8217;s link layer (hardware) address when only its Internet Layer (IP) or some other Network Layer address is known. ARP is a Link Layer protocol (Layer 2) because it only operates on the local area network or point-to-point link that a host is connected [...]]]></description> <content:encoded><![CDATA[<p>The <strong><a
href="http://en.wikipedia.org/wiki/Address_Resolution_Protocol" target="_blank">Address Resolution Protocol</a> (ARP)</strong> is the method for finding a host&#8217;s link layer (hardware) address when only its Internet Layer (IP) or some other Network Layer address is known. ARP is a Link Layer protocol (Layer 2) because it only operates on the local area network or point-to-point link that a host is connected to. When we <strong>migrate one IP</strong> from a machine to another one, we might have problems caused by &#8216;<strong>arp caching</strong>&#8216;. Various devices will cache the arp information for a specified amount of time and even after we moved the IP this will not be seen by some devices that will still use the cached information. I am talking about directly connected <strong>switches or routers</strong>, that we might have control or maybe not. If we have control on all the external devices, normally we just connect to the router or switch and remove the arp entry, forcing the device to query again for the information. This post will try to help in the situation where<em> we <strong>don&#8217;t </strong>have direct control on the external devices </em>(we are collocated or use rented servers in a remote datacenter, etc.), to <strong>minimize the downtime</strong> associated with this type of IP migration.</p><p>It is quite frequent to use separate IPs for various services on the same machine, and move those IPs to another server if needed. These are sometimes called <strong>portable IPs</strong> that can be migrated to any server in a particular colo/lan. This is done normally to minimized downtime and keep maintenance of such operations minimal (and to not rely on dns changes). Still <strong>arp caching</strong> on various network devices can cause big problems. Let&#8217;s assume we moved the IP from one server to another one in the same LAN to move away some service from our main web server. Taking down the IP from the existing server and bringing it up on the new server will complete our direct work if we don&#8217;t have access on the switches/routers in front of us. <em>Again if you have control on all devices just connect to them and delete the arp cache for this ip to allow it to be re-cached on the new machine.</em></p><p><span
id="more-679"></span>So after we have the IP moved on the new machine and now have to wait&#8230; The arp cache depends on the actual devices and can be anything from <em>5 minutes to not expire</em>. Let&#8217;s assume for this example that the ip is <em>192.168.0.101</em> and after we run <strong>ifup </strong>and <strong>ifdown </strong>we have the IP correctly showing on the new server, <em>srv02</em>. If we don&#8217;t want to wait helpless for this to happen automatically, the solution is to <strong>broadcast </strong>from our new machine the arp with the source of the IP. Hopefully this will make the remote device to verify and invalidate its existing cache entry. For this we can use <strong>arping</strong>; installation is simple as it should be in most modern linux distributions by default. On debian you would install arping just by running:<br
/> <code>aptitude install arping</code><br
/> finally we use a command like:<br
/> <code>arping -S &lt;our_IP&gt; -B</code><br
/> that will <strong>broadcast </strong>our source IP and direct it to the broadcast address (255.255.255.255) . If your arp command uses different parameters notations, you should looks for something similar (to set the source and ping the broadcast). In our example with the IP 192.168.0.101 we would use:<br
/> <code>srv02:~# arping -S 192.168.0.101 -B<br
/> ARPING 255.255.255.255<br
/> --- 255.255.255.255 statistics ---<br
/> 16 packets transmitted, 0 packets received, 100% unanswered</code><br
/> (stop it with CTRL-C once it is working).</p><p>Normally after this, all should be ok and the remote device should <strong>cache the new arp entry</strong>, invalidating the existing cached one. If this is not the case, then call your datacenter to minimize the downtime <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . I would always suggest testing this first and seeing what downtime to expect and if you can minimize it like this with <strong>arping</strong>, first try with a non-production test IP. Don&#8217;t do this with live, production IP/service until you know what to expect. I hope this post will help you if you will have to deal with a similar situation. If this doesn’t work as expected in your case, please let us know what devices you found problematic, and if you were able to use a different workaround.</p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/03/06/howto-force-remote-devices-routersswitches-to-refresh-their-arp-cache-entry-for-a-machine/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Bcfg2 0.9.6 debian package for etch</title><link>http://www.ducea.com/2009/02/12/bcfg2-096-debian-package-for-etch/</link> <comments>http://www.ducea.com/2009/02/12/bcfg2-096-debian-package-for-etch/#comments</comments> <pubDate>Thu, 12 Feb 2009 09:31:37 +0000</pubDate> <dc:creator>- Marius -</dc:creator> <category><![CDATA[Configuration management]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[apt]]></category> <category><![CDATA[bcfg2]]></category> <category><![CDATA[deb]]></category> <category><![CDATA[debian-etch]]></category> <category><![CDATA[debian_packages]]></category> <category><![CDATA[debuild]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=570</guid> <description><![CDATA[The Bcfg2 version available in debian etch is quite old (v0.8.6), while the one in lenny is newer v0.9.5.7, it still isn&#8217;t the latest stable version 0.9.6 that was released in November last year. Since this version fixes many bugs it is the version that is recommended to use in production at this time (unfortunately [...]]]></description> <content:encoded><![CDATA[<p>The <a
href="http://trac.mcs.anl.gov/projects/bcfg2" target="_blank"><strong>Bcfg2</strong></a> version available in <strong>debian etch</strong> is quite old (<a
href="http://packages.debian.org/etch/bcfg2" target="_blank">v0.8.6</a>), while the one in <strong>lenny </strong>is newer <a
href="http://packages.debian.org/lenny/bcfg2" target="_blank">v0.9.5.7</a>, it still isn&#8217;t the latest stable version <strong>0.9.6</strong> that was released in November last year. Since this version fixes many bugs it is the version that is recommended to use in production at this time (<em>unfortunately it breaks the reporting system, that will not be fixed until the release 1.0 planed for the next months)</em>. This post will show how we can <a
href="http://www.ducea.com/2008/03/06/howto-recompile-debian-packages/">rebuild a debian package</a> for the latest stable bcfg2 release so we can easily deploy it on several machines.</p><p><strong>Bcfg2 </strong>is a <em>debian friendly project</em>, meaning they provide inside the source package all what is needed to build a debian package very easy. We will use for this a debian etch system, but this should work on any debian based system.<span
id="more-570"></span></p><h3>1. Download</h3><p>First we need to <a
href="http://trac.mcs.anl.gov/projects/bcfg2/wiki/Download" target="_blank">download</a> the source package:<br
/> <code>wget ftp://ftp.mcs.anl.gov/pub/bcfg/bcfg2-0.9.6.tar.gz<br
/> tar -zxvf bcfg2-0.9.6.tar.gz<br
/> cd bcfg2-0.9.6</code></p><h3>2. Install dependencies</h3><p>Next we need to install the dependencies necessary to build the package. Depending on the state of your system this might look different from the output bellow. You will need to have basic debian building tools; in case you don&#8217;t have them already install them now:<br
/> <code>apt-get install devscripts build-essential fakeroot cdbs pbuilder</code></p><p>Since the package is prepared for multiple distributions types and versions of python, we will have to select that we want to use it for <strong>debian etch pycentral</strong>:<br
/> <code>cd debian<br
/> ./buildsys-select.sh pycentral</code><br
/> (the available choices are <em>2.3, 2.4 and pycentral</em>)</p><p>Now we can move on and install the rest of the dependencies (python-dev, etc.):<br
/> <code>cd ..<br
/> /usr/lib/pbuilder/pbuilder-satisfydepends</code></p><h3>3. Build and deploy the package</h3><p>Finally we can now rebuild the package:<br
/> <code><strong>debuild -us -uc</strong><br
/> cd ..<br
/> ls *.deb<br
/> <em>bcfg2-server_0.9.6-0.1_all.deb<br
/> bcfg2_0.9.6-0.1_all.deb</em></code><br
/> Probably you will want to put the resulted packages in a local debian repository to perform the upgrade easily on several systems, maybe even using bcfg2 itself <img
src='http://www.ducea.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/02/12/bcfg2-096-debian-package-for-etch/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>HowTo ignore some files/folders from awstats reports</title><link>http://www.ducea.com/2009/02/09/howto-ignore-some-filesfolders-from-awstats-reports/</link> <comments>http://www.ducea.com/2009/02/09/howto-ignore-some-filesfolders-from-awstats-reports/#comments</comments> <pubDate>Mon, 09 Feb 2009 12:14:42 +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[News from Outside]]></category> <category><![CDATA[RHEL]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[awstats]]></category><guid
isPermaLink="false">http://www.ducea.com/?p=565</guid> <description><![CDATA[Awstats will consider as a page hit any entry from the log it processes. By default some file extensions (for regular image types and css/js) are excluded from what awstats will consider as a page: NotPageList="css js class gif jpg jpeg png bmp ico"(this is the default). All other file types will be counted as [...]]]></description> <content:encoded><![CDATA[<p><strong>Awstats </strong>will consider as a page hit any entry from the log it processes. <em>By default some file extensions</em> (for regular image types and css/js) are excluded from what awstats will consider as a page:<br
/> <code>NotPageList="css js class gif jpg jpeg png bmp ico"</code>(this is the default). All other file types will be counted as pages. Now, if we want to completely ignore some files, or even all the content of one folder from the awstats processing we can use the <strong>SkipFiles </strong>parameter. We might want to do this to ignore some frames, hidden pages, ajax calls, etc.</p><p><span
id="more-565"></span>The <strong>SkipFiles </strong>parameter is <em>by default empty</em>, and in order to use it we have to add the appropriate config in our <em>awstats.conf</em> file.  For example to ignore a file called <em>somefile.php</em> we will add <em>&#8220;/somefile.php</em>&#8220;:<br
/> <code>SkipFiles="/somefile.php"</code><br
/> while if we want to ignore all the pages in a folder called <em>somefolder </em>we will have to use a regex value like: <em>&#8220;REGEX[^\/somefolder]&#8220;</em><br
/> We can add several rules separated by spaces:<br
/> <code>SkipFiles="/somefile.php REGEX[^\/somefolder]"</code></p><p><em>Note</em>: this will be effective only for <strong>new updates</strong>; meaning existing data will not be affected by this (if really needed you will have to regenerate your stats to get rid of those pages in old stats).</p>]]></content:encoded> <wfw:commentRss>http://www.ducea.com/2009/02/09/howto-ignore-some-filesfolders-from-awstats-reports/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Served from: www.ducea.com @ 2010-07-31 16:50:42 by W3 Total Cache -->