<?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>ServerAdminBlog &#187; Tips &amp; Tricks</title>
	<atom:link href="http://www.serveradminblog.com/category/tips-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serveradminblog.com</link>
	<description>Short Circuit...</description>
	<lastBuildDate>Sat, 04 Feb 2012 16:56:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL Performance – Howto – part 2 (write cache dependance)</title>
		<link>http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/</link>
		<comments>http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 16:23:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=379</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/' addthis:title='MySQL Performance – Howto – part 2 (write cache dependance) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>I already wrote about Sysbench and MySQL tunning scripts. Those articles can be found HERE and HERE. Now lets do some tests and lets see the dependance from write cache enabled/disabled option on your disks. Keep in mind that RH based distros will probably disable write cache (I tried Ubuntu on this server and the [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/' addthis:title='MySQL Performance – Howto – part 2 (write cache dependance) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>I already wrote about Sysbench and MySQL tunning scripts. Those articles can be found <a href="http://www.serveradminblog.com/2010/02/sysbench-on-centos-howto/">HERE</a> and <a href="http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/">HERE</a>. </p>
<p>Now lets do some tests and lets see the dependance from write cache enabled/disabled option on your disks. Keep in mind that RH based distros will probably disable write cache (I tried Ubuntu on this server and the same thing happen &#8211; write cache was disabled after installation). </p>
<p><span id="more-379"></span></p>
<p>The first step is to check the disk with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@s1 sysbench-0.4.12]# hdparm -i /dev/sda
&nbsp;
/dev/sda:
&nbsp;
 Model=GB0250EAFYK                             , FwRev=HPG1    , SerialNo=WCAT1E535427
 Config={ HardSect NotMFM HdSw&gt;15uSec SpinMotCtl Fixed DTR&gt;5Mbs FmtGapReq }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50
 BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=268435455
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4
 DMA modes:  mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 udma2
 AdvancedPM=no WriteCache=disabled
 Drive conforms to: unknown:  ATA/ATAPI-1 ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6 ATA/ATAPI-7</pre></div></div>

<p>Note <strong>WriteCache=disabled</strong> line</p>
<p>I suppose you know how to create a database, assign a user and set password</p>
<p>Read-write test for InnoDB</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># sysbench --num-threads=16 --max-requests=10000 --test=oltp --oltp-table-size=500000 --mysql-socket=/var/lib/mysql/mysql.sock --oltp-test-mode=complex --mysql-user=test_database --mysql-password=test_database_password run</pre></div></div>

<p>gave me the next results</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&nbsp;
No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 16
&nbsp;
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using &quot;BEGIN&quot; for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
&nbsp;
OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (42.63 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (809.95 per sec.)
    other operations:                    20000  (85.26 per sec.)
&nbsp;
Test execution summary:
    total time:                          234.5821s
    total number of events:              10000
    total time taken by event execution: 3751.1329
    per-request statistics:
         min:                                 17.33ms
         avg:                                375.11ms
         max:                               3850.27ms
         approx.  95 percentile:             766.79ms
&nbsp;
Threads fairness:
    events (avg/stddev):           625.0000/1.73
    execution time (avg/stddev):   234.4458/0.08</pre></div></div>

<p><strong>The total time is more than 234 seconds which is terrible result.</strong> </p>
<p>Now, delete sbtest table and recreate it again (please see the sysbench howto). </p>
<p>Enable write cache with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># hdparm -W1 /dev/sda</pre></div></div>

<p>and start test again</p>
<p>The result is</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 16
&nbsp;
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using &quot;BEGIN&quot; for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
&nbsp;
OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (621.08 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (11800.43 per sec.)
    other operations:                    20000  (1242.15 per sec.)
&nbsp;
Test execution summary:
    total time:                          16.1011s
    total number of events:              10000
    total time taken by event execution: 255.8624
    per-request statistics:
         min:                                  2.49ms
         avg:                                 25.59ms
         max:                                689.84ms
         approx.  95 percentile:              41.84ms
&nbsp;
Threads fairness:
    events (avg/stddev):           625.0000/4.68
    execution time (avg/stddev):   15.9914/0.03</pre></div></div>

<p><strong>Now we have a 16.1011 seconds for a complete test. </strong> I repeated the test several time with the same results. </p>
<p>We have a 14.62 times better result.</p>
<p>It is obvious that write cache is very important for MySQL but keep in mind that something can be lost in case of power failure and you should think about battery backups. </p>
<p><strong>Tuning Kernel parameters</strong></p>
<p>It is good idea to tune a few kernel parameters too. For this purpose you can install ktune (yum install ktune). (more info https://fedorahosted.org/ktune/)</p>
<p>With &#8220;service ktune start&#8221; you will set up scheduler on deadline instead of cfq (which can be up to 20% slower)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@s1 bekap]# service ktune start
Applying ktune sysctl settings:
/etc/sysctl.ktune:                                         [  OK  ]
Applying sysctl settings from /etc/sysctl.conf:            [  OK  ]
Applying deadline elevator: sda                            [  OK  ]</pre></div></div>

<p>After Ktune I have a little faster time (around 15 seconds)</p>
<p>More info about disk elevators can be found here <a href="http://www.redhat.com/magazine/008jun05/features/schedulers/" target="_blank">http://www.redhat.com/magazine/008jun05/features/schedulers/</a></p>
<p><strong>Optimizing the EXT3 file system on CentOS</strong></p>
<p>noatime<br />
This mount option tells the system not to update inode access times. This is a good option for web servers, news servers or other uses with high access file systems.</p>
<p>Open  /etc/fstab and add noatime like shown below</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/dev/VolGroup00/LogVol00 /                       ext3    defaults,noatime        1 1</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/12/mysql-performance-%e2%80%93-howto-%e2%80%93-part-2-write-cache-dependance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List the last created file</title>
		<link>http://www.serveradminblog.com/2011/11/list-the-last-created-file/</link>
		<comments>http://www.serveradminblog.com/2011/11/list-the-last-created-file/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 15:00:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=375</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/11/list-the-last-created-file/' addthis:title='List the last created file '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you want to find the newest file inside directory, you can use the ls &#038; tail combination. ls -t &#124; head -1 Output bash$ ls -t &#124; head -1 id695.txt Another option is with the next command ls -lrth &#124; tail -1 Output bash$ ls -lrth &#124; tail -1 -rw-r----- 1 user ugroup 85 [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/11/list-the-last-created-file/' addthis:title='List the last created file '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you want to find the newest file inside directory, you can use the ls &#038; tail combination.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ls -t | head -1</pre></div></div>

<p>Output</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">bash$ ls -t | head -1
id695.txt</pre></div></div>

<p>Another option is with the next command</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ls -lrth | tail -1</pre></div></div>

<p>Output</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">bash$ ls -lrth | tail -1
-rw-r-----   1 user      ugroup         85 Nov 11 15:38 id695.txt</pre></div></div>

<p>Note:<br />
| is used to send the output of the first command as input to the second one.<br />
tail &#8212; outputs the last files<br />
-1 &#8212; denotes the number of lines u want to display (in case you don&#8217;t set -1, by default you will get the last 10 lines)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/11/list-the-last-created-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dafizilla Table2Clipboard Firefox addon</title>
		<link>http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/</link>
		<comments>http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 22:39:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=371</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/' addthis:title='Dafizilla Table2Clipboard Firefox addon '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>If you need to copy HTML tables into Excel, Libreoffice Calc or other datasheet applications, you can think about Firefox and Dafizilla Table2Clipboard firefox addon. This addon will allow you to select rows and columns from a table simply pressing Control key and picking rows/columns with left mouse button. The selection can be copied to [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/' addthis:title='Dafizilla Table2Clipboard Firefox addon '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>If you need to copy HTML tables into Excel, Libreoffice Calc or other datasheet applications, you can think about Firefox and Dafizilla Table2Clipboard firefox addon. </p>
<p>This addon will allow you to select rows and columns from a table simply pressing Control key and picking rows/columns with left mouse button. The selection can be copied to clipboard and pasted into datasheet applications but without ugly results. </p>
<p>Pasting in plain text editors is also supported as CSV file.</p>
<p>Here is the <a href="https://addons.mozilla.org/en-US/firefox/addon/dafizilla-table2clipboard/" target="_blank">LINK</a> for this great tool. </p>
<p>Do not forget to donate <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/10/dafizilla-table2clipboard-firefox-addon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>scp, ssh and rsync without prompting for password &#8211; howto</title>
		<link>http://www.serveradminblog.com/2011/09/scp-ssh-and-rsync-without-prompting-for-password-howto/</link>
		<comments>http://www.serveradminblog.com/2011/09/scp-ssh-and-rsync-without-prompting-for-password-howto/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 10:15:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=358</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/09/scp-ssh-and-rsync-without-prompting-for-password-howto/' addthis:title='scp, ssh and rsync without prompting for password &#8211; howto '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Using scp, rsync and ssh requires the password unless you add the public key from src host to authorised_keys on destination host. scp and rsync commands are used to transfer or backup files between known hosts or by the same user on both the hosts. Lets say you want to copy between two hosts SOURCE [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/09/scp-ssh-and-rsync-without-prompting-for-password-howto/' addthis:title='scp, ssh and rsync without prompting for password &#8211; howto '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Using scp, rsync and ssh requires the password unless you add the public key from src host to authorised_keys on destination host.</p>
<p>scp and rsync commands are used to transfer or backup files between known hosts or by the same user on both the hosts. </p>
<p>Lets say you want to copy between two hosts SOURCE and DESTINATION. SOURCE is the host where you would run the scp, ssh or rsync command.</p>
<p>On the SOURCE host, run</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># ssh-keygen -t rsa</pre></div></div>

<p>It will prompt for a passphrase but do not enter anything. Instead, just press the enter key. It&#8217;ll generate an identification (private key) and a public key. Do not ever share the private key with anyone!<br />
The public key will be generated in ~/.ssh/id_rsa.pub. </p>
<p>For example in root/.ssh/id_rsa.pub</p>
<p>Copy id_rsa.pub file to DESTINATION inside the /root/.ssh/<br />
On DESTINATION host, login as the remote user which you plan to use (in this case root) and copy the contents of id_rsa.pub to /root/.ssh/authorized_keys</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># cat id_rsa.pub &gt;&gt; /root/.ssh/authorized_keys
# chmod 700 /root/.ssh/authorized_keys</pre></div></div>

<p>If this file authorized_keys does not exists, the command above will create it. Make sure you remove permission for others to read this file. </p>
<p>On some distros, ssh by default does not allow root to log in. To enable root login, edit /etc/ssh/sshd_config and changing the option of PermitRootLogin from no to yes (on DESTINATION host). Restart sshd to apply changes and that is it. </p>
<p>In case you want to ssh, scp or rsync from DESTINATION to SOURCE host you will be asked for password. You can reverse the steps above (generate the public key on DESTINATION and copy it to the SOURCE host) and it will work in both directions. </p>
<p>In case that one server gets hacked, the other one will be too <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/09/scp-ssh-and-rsync-without-prompting-for-password-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disk usage analysis</title>
		<link>http://www.serveradminblog.com/2011/07/disk-usage-analysis/</link>
		<comments>http://www.serveradminblog.com/2011/07/disk-usage-analysis/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 10:37:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=267</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/07/disk-usage-analysis/' addthis:title='Disk usage analysis '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Taking care about disk usage is a very good habit. There are several options for this and now I will only describe df and du commands. The df utility displays the disk space usage on all mounted filesystems. [root@abc ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 35772016 20297132 13628408 60% / /dev/sda1 [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/07/disk-usage-analysis/' addthis:title='Disk usage analysis '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Taking care about disk usage is a very good habit. There are several options for this and now I will only describe df and du commands.</p>
<p>The df utility displays the disk space usage on all mounted filesystems.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">[root@abc ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      35772016  20297132  13628408  60% /
/dev/sda1               101086     17692     78175  19% /boot
tmpfs                   513044         0    513044   0% /dev/shm</pre></div></div>

<p>Adding the -T option (type) will print the filesystem type. Also, the good idea is to add -h option because df measures the size in 1K blocks, which is difficult for a desktop user to recalculate.</p>
<p>Now we have</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@abc ~]# df -h -T
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
              ext3     35G   20G   13G  60% /
/dev/sda1     ext3     99M   18M   77M  19% /boot
tmpfs        tmpfs    502M     0  502M   0% /dev/shm</pre></div></div>

<p>As you can see, it is much easier to understand.</p>
<p>You can use the du command to determine which files or directories need to be deleted or reduced. A simple du will print usage for the present working directory and its subdirectories, along with the size of each directory.</p>
<p>du directory will print the size of an particular dir.</p>
<p>Avilable options:<br />
-h &#8211; print the size of the podcasts directory in a more readable format<br />
-c &#8211; prints the grand total size of the directory at the end.<br />
-a &#8211; displays the file names along with directories<br />
-s &#8211; display a summary, without showing all of the subdirectories.</p>
<p>For example, <strong>du -ch | grep total</strong> prints just one line with the total size of the directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/07/disk-usage-analysis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Performance &#8211; Howto &#8211; part 1 (high performance tuning scripts)</title>
		<link>http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/</link>
		<comments>http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 09:24:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=40</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/' addthis:title='MySQL Performance &#8211; Howto &#8211; part 1 (high performance tuning scripts) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Often the server admin has little control over the applications which uses MySQL and it is hard to find the bottlenecks. This blog post can&#8217;t bring the peace in the world, or help NASA to finally land on the Mars. Instead those tasks, I&#8217;ll try to solve something else and present my own experiences with [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/' addthis:title='MySQL Performance &#8211; Howto &#8211; part 1 (high performance tuning scripts) '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Often the server admin has little control over the applications which uses MySQL and it is hard to find the bottlenecks. This blog post can&#8217;t bring the peace in the world, or help NASA to finally land on the Mars. Instead those tasks, I&#8217;ll try to solve something else and present my own experiences with MySQL storage engines (at least for MyISAM and InnoDB as the most popular).<br />
<span id="more-40"></span></p>
<p>Keep in mind that I&#8217;m not an expert in this field. When I have problems with MySQL, I dig with my both hands (and head) to solve them without casualties. Every app has its own queries and you&#8217;ll need to track them down via slow query log. </p>
<p>Before you do anything, keep in mind that default MySQL installation usually works fine. Unfortunately maximum performances can&#8217;t be achieved without adjustments to increase performance and stability.</p>
<p>Before you can do anything, you need to enable slow query log. </p>
<p>Exec</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># touch /var/log/slow-query.log</pre></div></div>

<p>to create slow-query.log file. Then add</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">log-slow-queries = /var/log/slow-query.log
long_query_time = 4
log-queries-not-using-indexes</pre></div></div>

<p>(for MySQL 5.0.x)</p>
<p>to /etc/my.cnf (inside [mysqld] section) and restart mysql. Wait at least 24-48 hours before you proceed to the next step. </p>
<p>(For MySQL 5.1.x check here: <a href="http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html">LINK</a>)</p>
<p><strong>High performance tuning scripts</strong></p>
<p><strong>Mysqltuner</strong></p>
<p>MySQLTuner is a script written in Perl that will assist you with your MySQL configuration and make recommendations for increased performance and stability.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># wget mysqltuner.pl
# chmod +x mysqltuner.pl
# ./mysqltuner.pl</pre></div></div>

<p>Read output and try to follow the recommendations.</p>
<p><strong>Tuning-primer</strong></p>
<p>Tuning-primer is another script who takes information from &#8220;SHOW STATUS LIKE&#8230;&#8221; and &#8220;SHOW VARIABLES LIKE&#8230;&#8221; to produce readable recommendations for tuning server variables.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># wget http://www.day32.com/MySQL/tuning-primer.sh
# ./tuning-primer.sh</pre></div></div>

<p>Also, read output and try to see what you can do to fix problems. Keep in mind that you need to restart mysql after you add something to /etc/my.cnf. In case something goes wrong, check mysql log (usually /var/log/mysqld.log</p>
<p><strong>MyTOP</strong></p>
<p>Mytop is a console-based (non-gui) tool for monitoring the threads and overall performance of a MySQL</p>
<p>To install mytop,</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
# tar -xvzf mytop-1.6.tar.gz
# cd mytop-1.6
# perl Makefile.PL
# make
# make install</pre></div></div>

<p>In case some Perl libraries are missing, you should install them via cpan.</p>
<p>For example, Term::ReadKey is required and you can get it via cpan.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># cpan
(pres Enter several times until you get cpan shell)
cpan&gt; install Term::ReadKey
cpan&gt; quit</pre></div></div>

<p>Usage: # mytop -d DATABASE -u USERNAME -p PASSWORD</p>
<p>(replace the DATABASE, USERNAME and PASSWORD with your parameters. </p>
<p><strong>MySQLReport</strong></p>
<p>mysqlreport makes a friendly report of important MySQL status values. mysqlreport transforms the values from SHOW STATUS into an easy-to-read report that provides an in-depth understanding of how well MySQL is running. mysqlreport is a better alternative (and practically the only alternative) to manually interpreting SHOW STATUS.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># wget http://hackmysql.com/mysqlreport
# chmod +x mysqlreport
# ./mysqlreport --user root --password</pre></div></div>

<p>Enter password for root and check output. More info can be found here. <a href="http://hackmysql.com/mysqlreport">LINK</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple FTP backup script</title>
		<link>http://www.serveradminblog.com/2011/01/simple-ftp-backup-script/</link>
		<comments>http://www.serveradminblog.com/2011/01/simple-ftp-backup-script/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 12:05:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Web Hosting]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=230</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/01/simple-ftp-backup-script/' addthis:title='Simple FTP backup script '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>The first post for this year&#8230; Simple FTP backup script # nano backup_script Add next lines and save. #!/bin/sh DM=$(date +&#34;%b-%d-%Y&#34;) tar -Pzcf /backup/backup_$DM.tar.gz /backup/some_dir/ cd /backup ftp -nv &#60;&#60;EOF open 192.168.1.2 user ftp_username ftp_password bin put backup_$DM.tar.gz quit EOF echo -e &#34;FTP backup done!&#34; Make it executable with # chmod +x backup_script Of course, [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2011/01/simple-ftp-backup-script/' addthis:title='Simple FTP backup script '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The first post for this year&#8230; </p>
<p>Simple FTP backup script</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># nano backup_script</pre></div></div>

<p>Add next lines and save.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">#!/bin/sh
DM=$(date +&quot;%b-%d-%Y&quot;)
tar -Pzcf /backup/backup_$DM.tar.gz /backup/some_dir/
cd /backup
ftp -nv &lt;&lt;EOF
open 192.168.1.2
user ftp_username ftp_password
bin
put backup_$DM.tar.gz
quit
EOF
echo -e  &quot;FTP backup done!&quot;</pre></div></div>

<p>Make it executable with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># chmod +x backup_script</pre></div></div>

<p>Of course, you need to replate ftp_username and ftp_password with valid username and password. Also, IP address should be replaced with your ftp server IP address.</p>
<p>Add this script to cron (for example once per day at 4:00AM)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2011/01/simple-ftp-backup-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing ibdata1 &#8211; howto</title>
		<link>http://www.serveradminblog.com/2010/12/reducing-ibdata1-howto/</link>
		<comments>http://www.serveradminblog.com/2010/12/reducing-ibdata1-howto/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 12:54:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=221</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/12/reducing-ibdata1-howto/' addthis:title='Reducing ibdata1 &#8211; howto '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>One of the biggest mistakes you can make with MySQL is to leave its default configuration. It will work, but not as it should. For example, default MySQL installation (5.0x) will keep all InnoDB data in one file &#8211; ibdata1. This file is usually located in /var/lib/mysql (at least on RH and Debian based distros) [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/12/reducing-ibdata1-howto/' addthis:title='Reducing ibdata1 &#8211; howto '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>One of the biggest mistakes you can make with MySQL is to leave its default configuration. It will work, but not as it should. </p>
<p>For example, default MySQL installation (5.0x) will keep all InnoDB data in one file &#8211; ibdata1. This file is usually located in /var/lib/mysql (at least on RH and Debian based distros) and after few months this file can became very big (in my case it was 20GB). This file has a initial size of 10Mb and it automatically extends but it can’t be reduced with DELETE, TRUNCATE or DROP. The file could reach the maximum size allowed by the filesystem if no limit is set in the my.cnf file (Debian/Ubuntu -/etc/mysql/my.cnf or RH based distros /etc/my.cnf). The best idea is to force MySQL to create an ibd file for each InnoDB table (add <em>innodb_file_per_table</em> in my.cnf and restart mysql). Unf. this won&#8217;t affect old tables which are already created and which are in use. </p>
<p>You can &#8220;FIX&#8221; this on several ways but no matter what option do you choose, BACKUP YOUR WHOLE MYSQL DATA DIRECTORY and stop services connected to your MySQL server (httpd, radius, postfix, dovecot, etc).</p>
<p>Keep in mind that converting InnoDB table to MyISAM will kill foreign keys so do not do it unless you know how to recreate your foreign keys. </p>
<p>The best option is to dump all your databases in one sql file. </p>
<p><strong>Step 1</strong></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"># <span style="color: #66cc66;">/</span>usr<span style="color: #66cc66;">/</span>bin<span style="color: #66cc66;">/</span>mysqldump ––extended<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">INSERT</span> ––all<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">DATABASES</span> ––add<span style="color: #66cc66;">-</span>drop<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">DATABASE</span> ––disable<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">KEYS</span> ––flush<span style="color: #66cc66;">-</span>privileges ––quick ––routines ––triggers <span style="color: #66cc66;">&gt;</span> backup<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">SQL</span></pre></div></div>

<p><strong>Step 2</strong></p>
<p>Stop mysql server with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># service mysqld stop</pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># /etc/init.d/mysqld stop</pre></div></div>

<p><strong>Step 3</strong></p>
<p>Backup complete mysql data dir (/var/lib/mysql).</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># cd /var/lib/
# mv mysql mysql_backup
# mkdir mysql
# chown mysql:mysql mysql</pre></div></div>

<p>Then you should have something like</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">drwxr-xr-x  5 mysql     mysql     4096 2010-12-30 13:38 mysql</pre></div></div>

<p><strong>Step 4</strong></p>
<p>Add <em>innodb_file_per_table</em> option in /etc/my.cnf file and save file</p>
<p><strong>Step 5</strong></p>
<p>Re-initialize the database with the following commands</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># su mysql
$ mysql_install_db
$ exit</pre></div></div>

<p><strong>Step 6</strong></p>
<p>Start mysql server with <em>service mysqld start</em> and get into mysql console with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># mysql -u root</pre></div></div>

<p>Then exec next commands</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SET</span> FOREIGN_KEY_CHECKS<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">0</span>;
<span style="color: #993333; font-weight: bold;">SOURCE</span> backup<span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">SQL</span>;
<span style="color: #993333; font-weight: bold;">SET</span> FOREIGN_KEY_CHECKS<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;</pre></div></div>

<p><strong>Step 7</strong></p>
<p>Restart mysql server with <em>service mysqld restart</em></p>
<p>That should be all. </p>
<p>In case that something goes wrong you still have mysql_backup dir which contains all you databases and files. Simple rename the new mysql dir to mysql_new and mysql_backup to mysql. Then restart mysql.</p>
<p>Keep in mind that this operation will kill all services who depends on mysql. So, be quick <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Also, good idea is to execute command mysql_secure_installation which will &#8220;tight&#8221; your MySQL server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/12/reducing-ibdata1-howto/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Remove spikes from RRD graphs &#8211; howto</title>
		<link>http://www.serveradminblog.com/2010/11/remove-spikes-from-rrd-graphs-howto/</link>
		<comments>http://www.serveradminblog.com/2010/11/remove-spikes-from-rrd-graphs-howto/#comments</comments>
		<pubDate>Sat, 27 Nov 2010 16:08:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RRDTool]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=207</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/11/remove-spikes-from-rrd-graphs-howto/' addthis:title='Remove spikes from RRD graphs &#8211; howto '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Round robin works with a fixed amount of data, and a pointer to the current element. This can be described like a circle with N dots plotted on the edge of the circle. Those dots are the places where data can be stored. The pointer can be described like an arrow from the center of [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/11/remove-spikes-from-rrd-graphs-howto/' addthis:title='Remove spikes from RRD graphs &#8211; howto '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Round robin works with a fixed amount of data, and a pointer to the current element. This can be described like a circle with N dots plotted on the edge of the circle. Those dots are the places where data can be stored. The pointer can be described like an arrow from the center of the circle to one of the dots. It shows to the current dot. When the current data is read or written, the pointer moves to the next element. As we are on a circle there is no beginning nor an end, you can go on and on. After a while, all the available places will be used and the process automatically reuses old locations. It is easy to understand that this database will not grow and the file size is always the same.</p>
<p><span id="more-207"></span></p>
<p>RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data (it uses Round Robin Databases (RRDs)). RRDTool is  created by Tobias Oetiker.</p>
<p>For traffic stats, RRD stores the difference in values (between the last value and current) in the database, rather than the value itself. This type of data source is called COUNTER. This type is for continuous incrementing counters like the ifInOctets counter in a router. (assumes that the counter never decreases, except when a counter overflows). It is easy to work with but you will have a problem when routers or modems are rebooted. The counters on the interfaces will be cleared and you will have spikes on your graphs (because the difference between the last value and current is abnormal &#8211; for example you will see 100Mbps on 1Mbps link).</p>
<p>To see what I&#8217;m walking about, check the next image </p>
<p style="text-align: center;"><img class="size-full wp-image-209 aligncenter" title="spike" src="http://www.serveradminblog.com/wp-content/uploads/2011/01/spike.png" alt="" width="483" height="171" /></p>
<p>It is noticeable that the only thing we can see on this graph is the spike. Other details are not visible unless we remove this/those spike(s).</p>
<p>Here is the one solution.</p>
<p>The first thing you should do is to backup your rrd. The second step is to identify data sources used inside the router.rrd file. You can achieve this with next command:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rrdtool info router.rrd | more</pre></div></div>

<p>When you find your data sources, you will need to tune them.  (I suppose those DSes are In and Out and we will limit them on 5000000 (5Mbps)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rrdtool tune router.rrd -a Out:5000000
# rrdtool tune router.rrd -a In:5000000</pre></div></div>

<p>Dump rrd data inside XML file with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rrdtool dump router.rrd &gt; fix.xml</pre></div></div>

<p>And delete router.rrd file</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rm -fr router.rrd</pre></div></div>

<p>Then import data from XML file in new router.rrd</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rrdtool restore fix.xml router.rrd -r</pre></div></div>

<p>That&#8217;s it.</p>
<p>The graph is OK now.</p>
<p style="text-align: center;"><img class="size-full wp-image-210 aligncenter" title="spike2" src="http://www.serveradminblog.com/wp-content/uploads/2011/01/spike2.png" alt="" width="483" height="171" /></p>
<p>As you can see, the spike is limited to 5Mbps. You can decrease this limit to less then 5000000 if you don&#8217;t expect values above 5Mbps.</p>
<p>I suppose you already know how to generate graphs. If you don&#8217;t know how check rrdtool tutorial or leave a comment and I&#8217;ll write a small article about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/11/remove-spikes-from-rrd-graphs-howto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>YUM problem: rpmdb: Lock table is out of available locker entries</title>
		<link>http://www.serveradminblog.com/2010/10/yum-problem-rpmdb-lock-table-is-out-of-available-locker-entries/</link>
		<comments>http://www.serveradminblog.com/2010/10/yum-problem-rpmdb-lock-table-is-out-of-available-locker-entries/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 21:00:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.serveradminblog.com/?p=187</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/10/yum-problem-rpmdb-lock-table-is-out-of-available-locker-entries/' addthis:title='YUM problem: rpmdb: Lock table is out of available locker entries '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div>Few days ago I had a strange problem with yum and instead of clean install and update process I got Python errors and rpm message &#8220;rpmdb: Lock table is out of available locker entries&#8221;. After few minutes I found out that during installation or update process, rpm accesses the Berkeley database files and it makes [...]]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.serveradminblog.com/2010/10/yum-problem-rpmdb-lock-table-is-out-of-available-locker-entries/' addthis:title='YUM problem: rpmdb: Lock table is out of available locker entries '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Few days ago I had a strange problem with yum and instead of clean install and update process I got Python errors and rpm message &#8220;rpmdb: Lock  table is out of available locker entries&#8221;. After few minutes I found out that during installation or update process, rpm accesses the Berkeley database files and it makes temporary locker entries within the tables while it searches for data. Sometimes the locks are never cleared and we have a problem&#8230; Don&#8217;t worry&#8230; It can be fixed&#8230; </p>
<p>First here is the complete error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@myserver ~]# yum install firefox
Loading &quot;fastestmirror&quot; plugin
rpmdb: Lock table is out of available locker entries
rpmdb: Unknown locker ID: 3929
error: db4 error(22) from db-&gt;close: Invalid argument
error: cannot open Packages index using db3 - Cannot allocate memory (12)
error: cannot open Packages database in /var/lib/rpm
Traceback (most recent call last):
  File &quot;/usr/bin/yum&quot;, line 29, in ?
    yummain.main(sys.argv[1:])
  File &quot;/usr/share/yum-cli/yummain.py&quot;, line 85, in main
    base.getOptionsConfig(args)
  File &quot;/usr/share/yum-cli/cli.py&quot;, line 163, in getOptionsConfig
    disabled_plugins=self.optparser._splitArg(opts.disableplugins))
  File &quot;/usr/lib/python2.4/site-packages/yum/__init__.py&quot;, line 164, in _getConf
ig
    self._conf = config.readMainConfig(startupconf)
  File &quot;/usr/lib/python2.4/site-packages/yum/config.py&quot;, line 685, in readMainCo
nfig
    yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.dist
roverpkg)
  File &quot;/usr/lib/python2.4/site-packages/yum/config.py&quot;, line 755, in _getsysver
    idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed</pre></div></div>

<p>It looks scary <img src='http://www.serveradminblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>The first step is to backup /var/lib/rpm (in case that something goes wrong) with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># mkdir /backup
# tar cvzf /backup/rpm-backup.tar.gz /var/lib/rpm</pre></div></div>

<p><strong>You don&#8217;t need to backup but it is highly recommended. </strong></p>
<p>Remove the Berkeley databases that rpm uses with</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rm /var/lib/rpm/__db.00*</pre></div></div>

<p>Note: Probably there will be several files. Confirm all removal with &#8220;y&#8221;</p>
<p>Make rpm rebuild the databases from scratch (this may take a minute or two)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rpm --rebuilddb</pre></div></div>

<p>And that should be enough to fix this problem. Additionally you can list rpms to be sure that everything is OK.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># rpm -qa | sort</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.serveradminblog.com/2010/10/yum-problem-rpmdb-lock-table-is-out-of-available-locker-entries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

