<?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>Technology: Learn and Share &#187; Linux System</title>
	<atom:link href="http://crazytoon.com/category/linux-system/feed/" rel="self" type="application/rss+xml" />
	<link>http://crazytoon.com</link>
	<description>Enterprise level solutions, LAMP, Linux, Apache, MySQL, PHP, Perl, Windows, Cache, Optimization</description>
	<lastBuildDate>Fri, 16 Jul 2010 20:24:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Error while compiling apache on CentOS 5.5</title>
		<link>http://crazytoon.com/2010/07/16/error-while-compiling-apache-on-centos-5-5/</link>
		<comments>http://crazytoon.com/2010/07/16/error-while-compiling-apache-on-centos-5-5/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 20:24:40 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux System]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=221</guid>
		<description><![CDATA[I got the following error when I was trying to modify my existing installation of Apache.  Only thing I changed was to add &#8211;with-expires to my configure.  Here is the error: 
libtool: link: cannot find the library `/usr/local/src/httpd-2.2.14/srclib/apr-util/xml/expat/lib/libexpat.la' or unhandled argument `/usr/local/src/httpd-2.2.14/srclib/apr-util/xml/expat/lib/libexpat.la'
I was able to fix this error by adding:  --with-expat=builtin
Remember to [...]]]></description>
			<content:encoded><![CDATA[<p>I got the following error when I was trying to modify my existing installation of Apache.  Only thing I changed was to add &#8211;with-expires to my configure.  Here is the error: </p>
<p><code>libtool: link: cannot find the library `/usr/local/src/httpd-2.2.14/srclib/apr-util/xml/expat/lib/libexpat.la' or unhandled argument `/usr/local/src/httpd-2.2.14/srclib/apr-util/xml/expat/lib/libexpat.la'</code></p>
<p>I was able to fix this error by adding:  <code>--with-expat=builtin</code></p>
<p>Remember to do <code>make clean</code> or untar again before doing configure.  Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2010/07/16/error-while-compiling-apache-on-centos-5-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do you print number of files for each folder in a directory [Linux]</title>
		<link>http://crazytoon.com/2010/04/05/get-file-counts-for-folders-linux/</link>
		<comments>http://crazytoon.com/2010/04/05/get-file-counts-for-folders-linux/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 20:37:06 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=208</guid>
		<description><![CDATA[I have been annoyed by the fact that I couldn&#8217;t easily print file count for all of the folders in certain directory.  Most of the time I just want to see what space each folder is using (du -hs *) but there are times when I need to know how many files are in each [...]]]></description>
			<content:encoded><![CDATA[<p>I have been annoyed by the fact that I couldn&#8217;t easily print file count for all of the folders in certain directory.  Most of the time I just want to see what space each folder is using (du -hs *) but there are times when I need to know how many files are in each folder (checking cache folder, session folders etc).   So I whipped together a command line which does just that for me:</p>
<p><code>for i in `find -maxdepth 1 -type d`; do  echo -n $i " ";find $i|wc -l; done</code></p>
<p>I am sure there are many different ways to show file count for each folder in a directory and I am curious to see what people do so please do post comments with what you do.</p>
<p>Above command is pretty simple and can be expanded to do whatever you need.  For example, you can throw it into a bash script and be able to pass parameters.  For example:  count_files /home/  In this case your command line would look like:</p>
<p><code>for i in `find /home/ -maxdepth 1 -type d`; do  echo -n $i " ";find $i|wc  -l; done</code></p>
<p>only difference would be that /home/ would be argument you passed and therefore will be $1.  Here is a sample script for above example:</p>
<p><code>#!/bin/bash<br />
for i in `find $1 -maxdepth 1 -type d`; do<br />
echo -n $i " ";<br />
find $i|wc -l;<br />
done</code></p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet  carefully. Make backups often. And yeah.. last but not least.. I am not  responsible for any damage caused by this posting. <strong>Use at your  own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2010/04/05/get-file-counts-for-folders-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP: Curl being slow from php call on CentOS 5.4</title>
		<link>http://crazytoon.com/2010/01/19/php-curl-being-slow-from-php-call-on-centos-5-4/</link>
		<comments>http://crazytoon.com/2010/01/19/php-curl-being-slow-from-php-call-on-centos-5-4/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 22:12:28 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=204</guid>
		<description><![CDATA[I ran into an issue where curl request run within few ms from command line but same url fetch was taking over 10 secs.  After doing some debugging and research it turned out that call to check (getaddr ipv6 was timing out.  Obviously you can do multiple things to fix this (including enabling [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into an issue where curl request run within few ms from command line but same url fetch was taking over 10 secs.  After doing some debugging and research it turned out that call to check (getaddr ipv6 was timing out.  Obviously you can do multiple things to fix this (including enabling ipv6 support) but since I did not have a need for ipv6 (it is disabled in my network configuration), I decided to recompile curl and disable ipv6.  Here is the command for recompiling curl and installing into /usr/local/curl directory with ipv6 disabled.</p>
<p>./configure &#8211;prefix=/usr/local/curl &#8211;disable-ipv6</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2010/01/19/php-curl-being-slow-from-php-call-on-centos-5-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Telnet: shell script to issue commands to telnet session.</title>
		<link>http://crazytoon.com/2009/01/03/telnet-shell-script-to-issue-commands-to-telnet-session/</link>
		<comments>http://crazytoon.com/2009/01/03/telnet-shell-script-to-issue-commands-to-telnet-session/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 15:25:43 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=159</guid>
		<description><![CDATA[This is a quick post to show how one can issue commands to telnet session from a shell script or command line with out going into interactive mode.  I use this to get stats from our memcache servers or issue a flush_all via telnet from a script/cron.
So without further delay, following command will telnet [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick post to show how one can issue commands to <a title="man telnet - man page for telnet " href="http://www.lamp-tips.com/man-pages/telnet /" target="_blank">telnet</a> session from a shell script or command line with out going into interactive mode.  I use this to get stats from our memcache servers or issue a flush_all via <a title="man telnet - man page for telnet " href="http://www.lamp-tips.com/man-pages/telnet /" target="_blank">telnet</a> from a script/cron.</p>
<p>So without further delay, following command will telnet to local memcached server on port 11211 and issue one of the memcached commands, stats</p>
<p><code>(sleep .5;echo stats) | telnet localhost 11211</code><br />
You may have to play with the sleep timer to get it to work for your environment but in our .5 was the sweet spot.  Good luck and let me know if you have another shell command.  Obviously we can do this from perl, php, python, etc but the beauty of this is that you do not need any other dependencies plus its a very short command.</p>
<p>Since &#8220;jsled&#8221; commented about <a title="man nc - man page for nc" href="http://www.lamp-tips.com/man-pages/nc/" target="_blank">nc</a> (thanks jsled), here is the syntax to do the same thing with <a title="man nc - man page for nc" href="http://www.lamp-tips.com/man-pages/nc/" target="_blank">nc</a>:</p>
<p><code>echo "stats" | nc localhost 11211</code></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2009/01/03/telnet-shell-script-to-issue-commands-to-telnet-session/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>RewriteRule:  How to avoid passing query string when you redirect.</title>
		<link>http://crazytoon.com/2008/12/11/rewriterule-how-to-avoid-passing-query-string-when-you-redirect/</link>
		<comments>http://crazytoon.com/2008/12/11/rewriterule-how-to-avoid-passing-query-string-when-you-redirect/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 08:01:07 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[RewriteRule]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=162</guid>
		<description><![CDATA[Today I ran into an issue which I could not figure out for quite a while.  I was trying to redirect a url to another url using RewriteRule.  It was supposed to be a pretty straightforward redirect which made it even more annoying than complicated ones.  Hopefully somebody is able to explain [...]]]></description>
			<content:encoded><![CDATA[<p>Today I ran into an issue which I could not figure out for quite a while.  I was trying to redirect a url to another url using RewriteRule.  It was supposed to be a pretty straightforward redirect which made it even more annoying than complicated ones.  Hopefully somebody is able to explain what I am missing here and if my solution is a good solution or not.</p>
<p>I needed to redirect a url:  http://www.example.com/testpage.php?foo=bar to http://www.example.com/</p>
<p>So I added this to .htaccess file:</p>
<p><code>RewriteRule ^testpage\.php / [R=301,L]</code></p>
<p>This did do a 301 redirect as I wanted but query string passed so my redirected url looked like:  http://www.example.com/?foo=bar</p>
<p>Obviously this is not what I wanted so in order for me to fix it, I had to take a rather lame approach.  My new redirect is:</p>
<p><code>RewriteRule ^testpage\.php /<strong>?</strong> [R=301,L]</code></p>
<p>The only difference is the &#8220;?&#8221; after / for target url.  I am just curious to know why query-string was passed.  I have not used rewrites for long time but I do not remember this behavior.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/12/11/rewriterule-how-to-avoid-passing-query-string-when-you-redirect/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>sshfs: How do you install sshfs and fuse? [CentOS/Linux/Redhat]</title>
		<link>http://crazytoon.com/2008/10/07/sshfs-how-do-you-install-sshfs-and-fuse-centoslinuxredhat/</link>
		<comments>http://crazytoon.com/2008/10/07/sshfs-how-do-you-install-sshfs-and-fuse-centoslinuxredhat/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 23:06:50 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[fuse]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[sshfs]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=84</guid>
		<description><![CDATA[One may wonder what is sshfs and why would you want it?  Well simply put, sshfs allows you to mount another server&#8217;s filesystem into a folder on your local system which in the background is doing ssh commands and transfers.  As a mounted folder, you are able to move about and copy files back and [...]]]></description>
			<content:encoded><![CDATA[<p>One may wonder what is sshfs and why would you want it?  Well simply put, sshfs allows you to mount another server&#8217;s filesystem into a folder on your local system which in the background is doing ssh commands and transfers.  As a mounted folder, you are able to move about and copy files back and forth as everything was on local server.  As you can see this makes it very easy for you to work with files on multiple servers.</p>
<p><strong>Note</strong>:  you only have to do the following installations on the server where you are doing the mounts on.</p>
<p>Let us download and install the filesystem framework which is a requirement for sshfs called fuse.</p>
<p><code>wget http://voxel.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.4.tar.gz<br />
tar zxpfv fuse-*.gz<br />
cd fuse*<br />
./configure</code></p>
<p>If you get the following error, you will either have to point to the location of the kernel source or install it if needed.</p>
<p><code>checking kernel source directory... Not found<br />
configure: error:<br />
*** Please specify the location of the kernel source with<br />
*** the '--with-kernel=SRCDIR' option<br />
configure: error: ./configure failed for kernel</code></p>
<p>In our case here, we will be installing the source using yum.</p>
<p><code>yum -y install kernel-devel</code></p>
<p>Once installed, you will have to find out the directory it is installed in</p>
<p><code>ls -l /usr/src/kernels/<br />
total 4.0K<br />
drwxr-xr-x 18 root root 4.0K Oct  7 14:50 <strong>2.6.18-92.1.13.el5-x86_64</strong>/</code></p>
<p><code>./configure --with-kernel=/usr/src/kernels/<strong>2.6.18-92.1.13.el5-x86_64</strong><br />
make &amp;&amp; make install<br />
cd ..</code></p>
<p>Now let us get sshfs source and install it.</p>
<p><code>wget http://voxel.dl.sourceforge.net/sourceforge/fuse/sshfs-fuse-2.1.tar.gz<br />
tar zxpfv sshfs*<br />
cd sshfs-fuse-*<br />
./configure</code></p>
<p>If you get the following error:</p>
<p><code>checking for SSHFS... configure: error: The pkg-config script could not be found or is too old.  Make sure it<br />
is in your PATH or set the PKG_CONFIG environment variable to the full<br />
path to pkg-config.</code></p>
<p>OR</p>
<p><code>checking for SSHFS... configure: error: Package requirements (fuse &gt;= 2.2 glib-2.0 gthread-2.0) were not met:</code></p>
<p>No package &#8216;glib-2.0&#8242; found<br />
No package &#8216;gthread-2.0&#8242; found</p>
<p>You need to install glib2.  Do the following:</p>
<p><code>yum install glib2-devel</code></p>
<p>Once installation is done, continue with configure.</p>
<p><code>./configure<br />
make &amp;&amp; make install</code></p>
<p>After installation is done, we can move on with testing the installation:</p>
<p><code>cd /mnt<br />
mkdir test<br />
sshfs 10.0.0.2:/ test</code></p>
<p>If you get the following error,<br />
<code>sshfs: error while loading shared libraries: libfuse.so.2: cannot open shared object file: No such file or directory</code><br />
execute this:  NOTE:  this is for x64 system.  If you have 32 bit system, you have to symlink to /lib instead.<br />
<code>ln -s /usr/local/lib/libfuse.so.2 /lib64/</code><br />
Let us try mounting again:<br />
<code>sshfs 10.0.0.2:/ test</code><br />
At this point it would be like if you were making a ssh connection to 10.0.0.2  You will have to type in a password to get the mount to happen.  You may get the following error:  <code>fuse: device not found, try 'modprobe fuse' first</code></p>
<p>If you do &#8216;modprobe fuse&#8217;, as they tell you to, and you get:<br />
<code>modprobe fuse<br />
FATAL: Module fuse not found.</code></p>
<p>That means your running kernel is not the same version as the one you compiled with.  You have two options here:<br />
1) you can upgrade your kernel by typing:  yum update kernel<br />
2) find the source files for the kernel you have running and recompile fuse.</p>
<p>I went with option 1.  Once you do the update, reboot and try doing <em>modprobe fuse</em> again.</p>
<p>At this point we can try doing the mount again.<br />
<code>cd /mnt<br />
sshfs 10.0.0.2:/ test</code></p>
<p>If you do not get any errors, do df -h to see the mount:<br />
<code>...<br />
sshfs#10.0.0.2:/  1000G     0 1000G   0% /mnt/test<br />
...</code></p>
<p>At this point you can browse 10.0.0.2 server filesystem as it was local on your server.</p>
<p>————————————-</p>
<p><small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/10/07/sshfs-how-do-you-install-sshfs-and-fuse-centoslinuxredhat/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Linux: How do you find out what your server&#8217;s outgoing ip is?</title>
		<link>http://crazytoon.com/2008/09/04/linux-how-do-you-find-out-what-your-servers-outgoing-ip-is/</link>
		<comments>http://crazytoon.com/2008/09/04/linux-how-do-you-find-out-what-your-servers-outgoing-ip-is/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 14:27:05 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Notes for self]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=110</guid>
		<description><![CDATA[There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.  I used to just login to another external server from the server in question and find out by looking at &#8220;who&#8221; what my external ip is.  Even though it works [...]]]></description>
			<content:encoded><![CDATA[<p>There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.  I used to just login to another external server from the server in question and find out by looking at &#8220;<a title="man who - manpage for who" href="http://www.lamp-tips.com/man-pages/who/" target="_blank">who</a>&#8221; what my external ip is.  Even though it works and I am so used to it, today I decided to figure out a more graceful way of finding my outgoing ip.  As most of us already know, whatismyip.com is the quickest way to find out your outgoing ip from the browser.  So I decided to use the same way on the servers.  So I issued a wget:</p>
<p><code>wget http://www.whatismyip.org</code></p>
<p>Well that does the trick.  But being lazy as I am, I did not want to have to cat the output file to find out the ip (plus there is no point of creating extra files and doing extra work to remove them).  So if you are ssh&#8217;ed in, you can issue following command (I am sure there is another way of doing it, but this is the quickest way I could think of):</p>
<p><code><a title="man wget - manpage for wget" href="http://www.lamp-tips.com/man-pages/wget/" target="_blank">wget</a> -q -O - http://www.whatismyip.org</code></p>
<p>-O tells wget to redirect output to the following file (- being the standard out ).  So it basically echo&#8217;s output to our console.</p>
<p>-q makes wget run in  quiet mode so you do not see all of the connection/download/etc output.</p>
<p>That is it!  I am curious to know what other ways people use to get the same information.  Please share your way if possible.</p>
<p>————————————-</p>
<p><small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/09/04/linux-how-do-you-find-out-what-your-servers-outgoing-ip-is/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Quick tip:  how do you rename all files so spaces are converted to underscores?</title>
		<link>http://crazytoon.com/2008/08/25/quick-tip-how-do-you-rename-all-files-so-spaces-are-converted-to-underscores/</link>
		<comments>http://crazytoon.com/2008/08/25/quick-tip-how-do-you-rename-all-files-so-spaces-are-converted-to-underscores/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 23:36:13 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[man tr]]></category>
		<category><![CDATA[rename files]]></category>
		<category><![CDATA[spaces to underscores]]></category>
		<category><![CDATA[uppercase to lowercase]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=97</guid>
		<description><![CDATA[My friend today asked me how to convert all spaces in filenames under a specified directory to underscores.  Also, at the same time lowercase all of the filenames.  Here is a quick script to do what is needed.  Let us start with creating some test data in a temp directory:
mkdir temp
cd temp
touch [...]]]></description>
			<content:encoded><![CDATA[<p>My friend today asked me how to convert all spaces in filenames under a specified directory to underscores.  Also, at the same time lowercase all of the filenames.  Here is a quick script to do what is needed.  Let us start with creating some test data in a temp directory:</p>
<p><code>mkdir temp<br />
cd temp<br />
touch Foo FooO "Foo Bar" "FOO BAaR"<br />
\ls | while read -r FILENAME<br />
do<br />
mv -v "$FILENAME" `echo $FILENAME| tr ' ' '_'| tr '[A-Z]' '[a-z]'`<br />
done</code></p>
<p>Note:  I intentionally have slash in front of ls (\ls).  \ls means that we want to make sure there is no ls alias overwriting our command.  This is needed if your system has alias setup to display ls in a different way instead of default listing.  mv -v shows us the filenames being renamed as your script goes through the whole dir.  Your output should be like:</p>
<p><code>`Foo' -&gt; `foo'<br />
`FOO BAaR' -&gt; `foo_baar'<br />
`Foo Bar' -&gt; `foo_bar'<br />
`FooO' -&gt; `fooo'</code></p>
<p>One of the very powerful commands in this post is the &#8220;tr&#8221; command.  This command is not as popular as sed or awk but it is very useful and simple to use (<a title="man tr - man page for tr" href="http://www.lamp-tips.com/man-pages/tr/" target="_blank">read more about tr</a>).</p>
<p>If you only needed to convert spaces to underscores and you are using CentOS/Fedora/Redhat, you can use this simpler method.  <strong>NOTE</strong>:  this command is not available on all distributions:  <code>rename " " "_" *</code></p>
<p>Learn more about <a title="man rename - man page for rename" href="http://www.lamp-tips.com/man-pages/rename/" target="_blank">rename </a>command<br />
————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/08/25/quick-tip-how-do-you-rename-all-files-so-spaces-are-converted-to-underscores/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apache/http monitoring:  monitor http traffic in realtime using httptop</title>
		<link>http://crazytoon.com/2008/08/12/apachehttp-monitoring-monitor-http-traffic-in-realtime-using-httptop/</link>
		<comments>http://crazytoon.com/2008/08/12/apachehttp-monitoring-monitor-http-traffic-in-realtime-using-httptop/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 20:05:59 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[apache monitoring]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[realtime monitoring]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=86</guid>
		<description><![CDATA[Server monitoring is a big part of running a solid web site.  As an admin, you must know what is going on your server.  One of the tools most Linux/Unix admins are used to is called &#8220;top&#8221;.  &#8220;top&#8221; by itself is a very powerful tool.  Here is a quick guide on how to read output [...]]]></description>
			<content:encoded><![CDATA[<p>Server monitoring is a big part of running a solid web site.  As an admin, you must know what is going on your server.  One of the tools most Linux/Unix admins are used to is called &#8220;top&#8221;.  &#8220;<a title="Introduction to load averages under &quot;top&quot;" href="http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/" target="_blank">top</a>&#8221; by itself is a very powerful tool.  Here is a quick guide on how to read output from top:  <a title="Introduction to load averages under &quot;top&quot;" href="http://crazytoon.com/2007/01/29/what-is-this-load-average-i-keep-hearing-about/">introduction to load averages under top</a>.  It just makes sense that somebody went and created http<strong>top</strong> to monitor http traffic.</p>
<p>Install perl modules:</p>
<p><code>install Term::ReadKey<br />
install File::Tail<br />
install Time::HiRes<br />
</code><br />
Now copy paste the script below and save it in a location and set +x attribute on it so you can execute it.  On my setup, I have the script under /usr/bin/httptop:</p>
<p><code>#!/usr/bin/perl -w<br />
use Time::HiRes qw( time );<br />
use File::Tail (  );<br />
use Term::ReadKey;<br />
use Getopt::Std;<br />
use strict;<br />
### Defaults you might be interested in adjusting.<br />
my $Update = 2; # update every n secs<br />
my $Backtrack = 250; # backtrack n lines on startup<br />
my @Paths = qw(<br />
%<br />
/title/%/logs/access_log<br />
/var/log/httpd/%/access_log<br />
/usr/local/apache/logs/%/access_log<br />
);<br />
my $Log_Format = "combined";<br />
my %Log_Fields = (<br />
combined =&gt; [qw/ Host x x Time URI Response x Referer Client /],<br />
vhost =&gt; [qw/ VHost Host x x Time URI Response x Referer Client /]<br />
);<br />
### Constants &amp; other thingies. Nothing to see here. Move along.<br />
my $Version = "0.4.1";<br />
sub by_hits_per (  ) { $b-&gt;{Rate} &lt;=&gt; $a-&gt;{Rate} }<br />
sub by_total (  ) { $b-&gt;{Total} &lt;=&gt; $a-&gt;{Total} }<br />
sub by_age (  ) { $a-&gt;{Last} &lt;=&gt; $b-&gt;{Last} }<br />
my $last_field = "Client";<br />
my $index = "Host";<br />
my $show_help = 0;<br />
my $order = \&amp;by_hits_per;<br />
my $Help = "htlwufd?q";<br />
my %Keys = (<br />
h =&gt; [ "Order by hits/second" =&gt; sub { $order = \&amp;by_hits_per } ],<br />
t =&gt; [ "Order by total recorded hits" =&gt; sub { $order = \&amp;by_total } ],<br />
l =&gt; [ "Order by most recent hits" =&gt; sub { $order = \&amp;by_age } ],<br />
w =&gt; [ "Show remote host" =&gt; sub { $index = "Host" } ],<br />
u =&gt; [ "Show requested URI" =&gt; sub { $index = "URI" } ],<br />
f =&gt; [ "Show referring URL" =&gt; sub { $index = "Referer" } ],<br />
d =&gt; [ "Show referring domain" =&gt; sub { $index = "Domain" } ],<br />
'?' =&gt; [ "Help (this thing here)" =&gt; sub { $show_help++ } ],<br />
q =&gt; [ "Quit" =&gt; sub { exit } ]<br />
);<br />
my @Display_Fields = qw/ Host Date URI Response Client Referer Domain /;<br />
my @Record_Fields = qw/ Host URI Referer Domain /;<br />
my $Max_Index_Width = 50;<br />
my $Initial_TTL = 50;<br />
my @Months = qw/ Jan Feb Mar Apr May Jun Jul Aug Sep Nov Dec /;<br />
my %Term = (<br />
HOME =&gt; "\033[H",<br />
CLS =&gt; "\033[2J",<br />
START_TITLE =&gt; "\033]0;", # for xterms etc.<br />
END_TITLE =&gt; "\007",<br />
START_RV =&gt; "\033[7m",<br />
END_RV =&gt; "\033[m"<br />
);<br />
my ( %hist, %opt, $spec );<br />
$SIG{INT} = sub { exit };<br />
END { ReadMode 0 };<br />
### Subs.<br />
sub refresh_output<br />
{<br />
my ( $cols, $rows ) = GetTerminalSize;<br />
my $show = $rows - 3;<br />
my $count = $show;<br />
my $now = (shift || time);<br />
for my $type ( values %hist ) {<br />
for my $peer ( values %$type ) {<br />
# if ( --$peer-&gt;{_Ttl} &gt; 0 ) {<br />
my $delta = $now - $peer-&gt;{Start};<br />
if ( $delta &gt;= 1 ) {<br />
$peer-&gt;{ Rate } = $peer-&gt;{ Total } / $delta;<br />
} else {<br />
$peer-&gt;{ Rate } = 0<br />
}<br />
$peer-&gt;{ Last } = int( $now - $peer-&gt;{ Date } );<br />
# } else {<br />
# delete $type-&gt;{$peer}<br />
# }<br />
}<br />
}<br />
$count = scalar( values %{$hist{$index}} ) - 1 if $show &gt;= scalar values %{$hist{$index}};<br />
my @list = ( sort $order values %{$hist{$index}} )[ 0 .. $count ];<br />
my $first = 0;<br />
$first = ( $first &lt;= $_ ? $_ + 1 : $first ) for map { $_ ? length($_-&gt;{$index}) : 0 } @list;<br />
$first = $Max_Index_Width if $Max_Index_Width &lt; $first;<br />
print $Term{START_TITLE}, "Monitoring $spec at: ", scalar localtime, $Term{END_TITLE} if $ENV{TERM} eq "xterm"; # UGLY!!!<br />
my $help = "Help/?";<br />
my $head = sprintf( "%-${first}s %6s %4s %4s %s (%d total)",<br />
$index, qw{ Hits/s Tot Last }, $last_field,<br />
scalar keys %{$hist{$index}}<br />
);<br />
#<br />
# Truncate status line if need be<br />
#<br />
$head = substr($head, 0, ($cols - length($help)));<br />
print @Term{"HOME", "START_RV"}, $head, " " x ($cols - length($head) - length($help)), $help, $Term{END_RV}, "\n";<br />
for ( @list ) {<br />
# $_-&gt;{_Ttl}++;<br />
my $line = sprintf( "%-${first}s %6.3f %4d %3d %s",<br />
substr( $_-&gt;{$index}, 0, $Max_Index_Width ), @$_{(qw{ Rate Total Last }, $last_field)} );<br />
if ( length($line) &gt; $cols ) {<br />
substr( $line, $cols - 1 ) = "";<br />
} else {<br />
$line .= " " x ($cols - length($line));<br />
}<br />
print $line, "\n";<br />
}<br />
print " " x $cols, "\n" while $count++ &lt; $show;<br />
}<br />
sub process_line<br />
{<br />
my $line = shift;<br />
my $now = ( shift || time );<br />
my %hit;<br />
chomp $line;<br />
@hit{@{$Log_Fields{$Log_Format}}} = grep( $_, split( /"([^"]+)"|\[([^]]+)\]|\s/o, $line ) );<br />
$hit{ URI } =~ s/HTTP\/1\S+//gos;<br />
$hit{ Referer } = "&lt;unknown&gt;" if not $hit{Referer} or $hit{Referer} eq "-";<br />
( $hit{Domain} = $hit{Referer} ) =~ s#^\w+://([^/]+).*$#$1#os;<br />
$hit{ Client } ||= "&lt;none&gt;";<br />
$hit{ Client } =~ s/Mozilla\/[\w.]+ \(compatible; /(/gos;<br />
$hit{ Client } =~ s/[^\x20-\x7f]//gos;<br />
# if $now is negative, try to guess how old the hit is based on the time stamp.<br />
if ( $now &lt; 0 ) {<br />
my @hit_t = ( split( m![:/\s]!o, $hit{ Time } ))[ 0 .. 5 ];<br />
my @now_t = ( localtime )[ 3, 4, 5, 2, 1, 0 ];<br />
my @mag = ( 3600, 60, 1 );<br />
# If the hit didn't parse right, or didn't happen today, the hell with it.<br />
return unless $hit_t[2] == ( $now_t[2] + 1900 )<br />
and $hit_t[1] eq $Months[ $now_t[1] ]<br />
and $hit_t[0] == $now_t[0];<br />
splice( @hit_t, 0, 3 );<br />
splice( @now_t, 0, 3 );<br />
# Work backward to the UNIX time of the hit.<br />
$now = time;<br />
$now -= (shift( @now_t ) - shift( @hit_t )) * $_ for ( 3600, 60, 1 );<br />
}<br />
$hit{ Date } = $now;<br />
for my $field ( @Record_Fields ) {<br />
my $peer = ( $hist{$field}{$hit{$field}} ||= { Start =&gt; $now, _Ttl =&gt; $Initial_TTL } );<br />
@$peer{ @Display_Fields } = @hit{ @Display_Fields };<br />
$peer-&gt;{ Total }++;<br />
}<br />
}<br />
sub display_help {<br />
my $msg = "httptop v.$Version";<br />
print @Term{qw/ HOME CLS START_RV /}, $msg, $Term{END_RV}, "\n\n";<br />
print " " x 4, $_, " " x 8, $Keys{$_}[0], "\n" for ( split "", $Help );<br />
print "\nPress any key to continue.\n";<br />
}<br />
### Init.<br />
getopt( 'frb' =&gt; \%opt );<br />
$Backtrack = $opt{b} if $opt{b};<br />
$Update = $opt{r} if $opt{r};<br />
$Log_Format = $opt{f} if $opt{f};<br />
$spec = $ARGV[0];<br />
die &lt;&lt;End unless $spec and $Log_Fields{$Log_Format};<br />
Usage: $0 [-f &lt;format&gt;] [-r &lt;refresh_secs&gt;] [-b &lt;backtrack_lines&gt;] &lt;logdir | path_to_log&gt;<br />
Valid formats are: @{[ join ", ", keys %Log_Fields ]}.<br />
End<br />
for ( @Paths ) {<br />
last if -r $spec;<br />
( $spec = $_ ) =~ s/%/$ARGV[0]/gos;<br />
}<br />
die "No access_log $ARGV[0] found.\n" unless -r $spec;<br />
my $file = File::Tail-&gt;new(<br />
name =&gt; $spec,<br />
interval =&gt; $Update / 2,<br />
maxinterval =&gt; $Update,<br />
tail =&gt; $Backtrack,<br />
nowait =&gt; 1<br />
) or die "$spec: $!";<br />
my $last_update = time;<br />
my ( $line, $now );<br />
# Backtracking.<br />
while ( $Backtrack-- &gt; 0 ) {<br />
last unless $line = $file-&gt;read;<br />
process_line( $line, -1 );<br />
}<br />
$file-&gt;nowait( 0 );<br />
ReadMode 4; # Echo off.<br />
print @Term{"HOME", "CLS"}; # Home &amp; clear.<br />
refresh_output;<br />
### Main loop.<br />
while (defined( $line = $file-&gt;read )) {<br />
$now = time;<br />
process_line( $line, $now );<br />
while ( $line = lc ReadKey(-1) ) {<br />
$show_help = 0 if $show_help;<br />
$Keys{$line}[1]-&gt;(  ) if $Keys{$line};<br />
}<br />
if ( $show_help == 1 ) {<br />
display_help;<br />
$show_help++; # Don't display help again.<br />
} elsif ( $now - $last_update &gt; $Update and not $show_help ) {<br />
$last_update = $now;<br />
refresh_output( $now );<br />
}<br />
}</code></p>
<p>Save/exit and make sure you make it executable by setting it to +x (<a title="man chmod - man page for chmod" href="http://www.lamp-tips.com/man-pages/chmod/" target="_blank">chmod </a>+x httptop)</p>
<p>Now you can run httptop by typing:  <code>httptop -f combined -r 1 /usr/local/apache2/logs/access_log</code></p>
<p>NOTE:  Your access_log file might be in different location.  Point to the right location.  This sets the refresh rate to 1 sec (-r 1).  Now you can run httptop any time you want to checkout how your http traffic is doing.  Remember to press &#8220;?&#8221; to get help once you are in.</p>
<p>—————</p>
<p><small>DISCLAIMER: As always, if you find any inaccurate information, please comment and let me know. When you do comment, make sure you give me some references to confirm.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/08/12/apachehttp-monitoring-monitor-http-traffic-in-realtime-using-httptop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MySQL:  How do you enable sphinxse (Sphinx Storage Engine) in your mysql installation?</title>
		<link>http://crazytoon.com/2008/08/05/mysql-how-do-you-enable-sphinxse-sphinx-storage-engine-in-your-mysql-installation/</link>
		<comments>http://crazytoon.com/2008/08/05/mysql-how-do-you-enable-sphinxse-sphinx-storage-engine-in-your-mysql-installation/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 22:21:32 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[fulltext search]]></category>
		<category><![CDATA[open source full text search engine]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[sphinx]]></category>
		<category><![CDATA[sphinx storage engine]]></category>
		<category><![CDATA[sphinxse]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=88</guid>
		<description><![CDATA[As you may know mysql fulltext search is not highly scalable.  One of the options to get around this scalability limitation, which I prefer, is to use Sphinx.   You can use Sphinx with out having to alter your mysql installation.  But, if you would like to use from within mysql and not have to [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know mysql fulltext search is not highly scalable.  One of the options to get around this scalability limitation, which I prefer, is to use <a title="Sphinx Homepage" href="http://www.sphinxsearch.com/" target="_blank">Sphinx</a>.   You can use Sphinx with out having to alter your mysql installation.  But, if you would like to use from within mysql and not have to worry about how to pass data between Sphinx and MySQL, you can enable sphinxse (sphinx storage engine).  It is not included with mysql by default so you will have to compile it yourself.</p>
<p>Here are the instructions on how to get sphinxse compiled with your mysql installation on CentOS x64.  I am sure same instructions will work for other flavors but I have not tested it.  I will be compiling the most current version of sphinx (0.9.8) with most current stable version of mysql (5.0.51b) at the time of the writing.  Let&#8217;s get the appropriate packages first:</p>
<p><code>wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz<br />
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz/from/http://mysql.he.net/<br />
tar zxpf sphinx*<br />
tar zxpf mysql*</code></p>
<p>You will also need &#8220;bison&#8221;, &#8220;patch&#8221;, &#8220;automake&#8221; and &#8220;libtool&#8221; installed.  Let us just do a yum install for it.</p>
<p><code>yum -y install bison patch automake libtool</code></p>
<p><strong>NOTE</strong>:  if you don&#8217;t install bison, you will get the following error:<br />
<code>sed '/^#/ s|y\.tab\.c|sql_yacc.cc|' y.tab.c &gt;sql_yacc.cct &amp;&amp; mv sql_yacc.cct sql_yacc.cc<br />
sed: can't read y.tab.c: No such file or directory<br />
make[2]: *** [sql_yacc.cc] Error 2</code></p>
<p>Let us continue with patching mysql source with sphinx storage engine (sphinxse) code and compile/install our new binaries.</p>
<p><code>cd mysql*<br />
patch -p1 &lt; ../sphinx-0.9.8/mysqlse/sphinx.5.0.37.diff #Make sure everything succeeded.<br />
BUILD/autorun.sh<br />
mkdir sql/sphinx<br />
cp ../sphinx-0.9.8/mysqlse/* sql/sphinx<br />
./configure --prefix=/usr/local/mysql --with-sphinx-storage-engine<br />
make<br />
make install</code></p>
<p>Now start your mysql installtion and check if engine support is compiled in:</p>
<p><code>mysql&gt; show engines\G<br />
Engine: SPHINX<br />
Support: YES<br />
Comment: Sphinx storage engine 0.9.8</code></p>
<p>To read more about how to use Sphinx storage engine, please refer to:  <a title="Sphinx Documentation for using Sphinx Storage Engine" href="http://www.sphinxsearch.com/doc.html#sphinxse-using" target="_blank">Sphinx documentation for using sphinx storage engine</a></p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/08/05/mysql-how-do-you-enable-sphinxse-sphinx-storage-engine-in-your-mysql-installation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux:  yum options you may not know exist.</title>
		<link>http://crazytoon.com/2008/06/16/linux-yum-options-you-may-not-know-exist/</link>
		<comments>http://crazytoon.com/2008/06/16/linux-yum-options-you-may-not-know-exist/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 15:18:17 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=85</guid>
		<description><![CDATA[Most of the users who work with distributions such as: centos, fedora, redhat, etc use yum as a package update/installer.  Most of them know how to do &#8220;yum update [packagename]&#8221; (to update all or [certain packages]) or they do &#8220;yum install packagename&#8221; to install certain package(s).  But yum can do so much more. [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the users who work with distributions such as: centos, fedora, redhat, etc use yum as a package update/installer.  Most of them know how to do &#8220;yum update [packagename]&#8221; (to update all or [certain packages]) or they do &#8220;yum install packagename&#8221; to install certain package(s).  But yum can do so much more.  Here are some options you may find useful:</p>
<p>Following command will search for the string you specified.   Generally this will give you all of the packages which has specified string in title or description.  Most of the time you will have to look through a lot of output to find what you are looking for.</p>
<p><code>yum search string</code></p>
<p>Probably one of the most important options for yum is provides/whatprovides.  If you know what command you need, you can find out what package you have to install in order to have that command available to you.</p>
<p><code>yum provides (or whatprovides) command</code><br />
<code></code></p>
<p>Following command is same as above but with less output.</p>
<p><code> yum -d 1 provides command</code></p>
<p>So for example if you are trying to figure out what you need to install to use bunzip2, type:</p>
<p><code>yum -d 1 provides bunzip2</code></p>
<p>you will get a similar output as below.</p>
<p><code># yum -d 1 provides bunzip2<br />
bzip2.x86_64                             1.0.2-13.EL4.3         base<br />
bzip2.x86_64                             1.0.2-13.EL4.3         base<br />
man-pages-fr.noarch                      0.9.7-13.el4           base<br />
man-pages-ja.noarch                      20050215-2.EL4.3       base<br />
man-pages-pl.noarch                      0.23-5                 base</code></p>
<p>As you can see bunzip2 is part of bzip2 package.  So now you can you just install bzip2.x86_64 to get bunzip2.</p>
<p>To learn more about what else is available, <a title="man yum - man page for yum" href="http://www.lamp-tips.com/man-pages/yum/" target="_blank">read man yum</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/06/16/linux-yum-options-you-may-not-know-exist/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache2 gzip compression:  How do I speed up my website download time?</title>
		<link>http://crazytoon.com/2008/05/29/apache-gzip-compression-how-do-i-speed-up-my-website-download-time/</link>
		<comments>http://crazytoon.com/2008/05/29/apache-gzip-compression-how-do-i-speed-up-my-website-download-time/#comments</comments>
		<pubDate>Thu, 29 May 2008 15:54:06 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Server load]]></category>
		<category><![CDATA[System admin]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=76</guid>
		<description><![CDATA[One of the things people tend to forget is the ability for web servers to compress content before sending it back to client.  Client&#8217;s browser then uncompresses the data and displays it to the user.  Pretty much all of the recent browsers support gzip compression.  In this post, I will go over [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things people tend to forget is the ability for web servers to compress content before sending it back to client.  Client&#8217;s browser then uncompresses the data and displays it to the user.  Pretty much all of the recent browsers support gzip compression.  In this post, I will go over how to setup apache2 to use compression.  First let&#8217;s see if your Apache installation has &#8220;deflate&#8221; enabled.  You can check to see if you have deflate by typing:</p>
<p><code># /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES<br />
Loaded Modules:<br />
...<br />
deflate_module (static)<br />
...<br />
Syntax OK</code></p>
<p>If you don&#8217;t have have deflate_module, you would have to recompile your apache with &#8220;&#8211;enable-deflate&#8221; option.</p>
<p>Going forward, I am going to assume you have deflate_module.  Add the following to your apache conf file:</p>
<p><code>&lt;Location /&gt;<br />
SetOutputFilter DEFLATE<br />
BrowserMatch ^Mozilla/4\.0[678] no-gzip\<br />
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html<br />
# Don't compress images<br />
SetEnvIfNoCase Request_URI \<br />
<strong>\.(?:gif|jpe?g|png)$ no-gzip dont-vary</strong><br />
&lt;/Location&gt;</code></p>
<p>The main thing you need to configure is the line which says &#8220;no-gzip dont-vary&#8221; also in bold above.  This tells apache to not compress certain type of files.  I have noticed on some of my sites that swf (flash) files do not work as expected if they are compressed.  So if you have swf files in your site, you may want to add <strong>|swf </strong>right after png.</p>
<p>This is all what it takes for you to enable gzip compression in Apache2.  Once you restart your apache so it reads the conf file, you can test if your site is getting compressed or not by using this tool:  <a title="http://www.gidnetwork.com/tools/gzip-test.php" href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">http://www.gidnetwork.com/tools/gzip-test.php</a></p>
<p>Here are the results for my blog:</p>
<p style="padding-left: 30px;">Results for: http://crazytoon.com<br />
Web page compressed? 	Yes<br />
Compression type? 	gzip<br />
Size, Markup (bytes) 	57,337<br />
Size, Compressed (bytes) 	11,666<br />
Compression % 	79.7</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/05/29/apache-gzip-compression-how-do-i-speed-up-my-website-download-time/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Oh dear MySQL slave, where did you put those rows?</title>
		<link>http://crazytoon.com/2008/05/17/mysql-missing-data-on-slave-mysql-replicatio/</link>
		<comments>http://crazytoon.com/2008/05/17/mysql-missing-data-on-slave-mysql-replicatio/#comments</comments>
		<pubDate>Sat, 17 May 2008 10:35:00 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL backup]]></category>
		<category><![CDATA[uh...]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=75</guid>
		<description><![CDATA[I need help from my fellow mysql users.  I know some of the people who read this are alot better then me with mysql so hopefully you can help  
So today we decided that we are going to migrate one of our master database servers to new hardware.  Since we got the hardware this [...]]]></description>
			<content:encoded><![CDATA[<p>I need help from my fellow mysql users.  I know some of the people who read this are alot better then me with mysql so hopefully you can help <img src='http://crazytoon.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So today we decided that we are going to migrate one of our master database servers to new hardware.  Since we got the hardware this morning and we wanted to move on to it asap, we decided that we will take our slave down, copy data from it, and bring it up on future master server.  At that point, we will let it run as slave to the current master server until its time for us to take it down.  Reason we did that instead of mysqldump/import was to avoid the lag mysqldump creates on our server.</p>
<p>After we did all this and put up the new master server, we started to notice odd issues.  After looking around and comparing old db with new, we found out that new db was missing data.  How it happened is beyond me and is the reason why I am writing this.  We never had issues with the slave which would cause data to be lost; so what happened to those missing rows?  Is this something which is common?  Can we not trust our slave enough to use it as master if master died?  Can we not run backups off the slave with confident that our data is protected and up to date so to keep load down on our master?  All these questions which keep me awake and wondering&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/05/17/mysql-missing-data-on-slave-mysql-replicatio/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Linux:  How do you rename a user account in linux?</title>
		<link>http://crazytoon.com/2008/05/09/linux-how-do-you-rename-a-user-account-in-linux/</link>
		<comments>http://crazytoon.com/2008/05/09/linux-how-do-you-rename-a-user-account-in-linux/#comments</comments>
		<pubDate>Fri, 09 May 2008 11:13:19 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Quick Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=69</guid>
		<description><![CDATA[In Linux, there is no command which will rename a user account. If you make a mistake creating a user account, user changes their name or if user does not like his user name, there is no real easy way of going and making the change.  Only thing I know you can do is [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: line-through;">In Linux, there is no command which will rename a user account.</span> If you make a mistake creating a user account, user changes their name or if user does not like his user name, there is no real easy way of going and making the change.  Only thing I know you can do is to go through some files and rename user manually.  Let us say that we have a user who is named joe and we want to rename him to john.</p>
<p>Note:  you must be logged in as root to do following.</p>
<p>vi /etc/passwd<br />
find joe and change it to john, save/exit</p>
<p>vi /etc/group<br />
find joe and change it to john, save/exit</p>
<p>vi /etc/shadow<br />
find joe and change it to john.  This file is read only and you have to force overwrite it.  In vi it is :w!  once saved, quit.</p>
<p>cd /home<br />
mv joe john</p>
<p>And that should do the trick.</p>
<p>[Edited] Right after I posted this post, I was contacted and was told to look at utility called usermod.  Read more about it <a title="Man usermod:  man page for usermod" href="http://www.lamp-tips.com/man-pages/usermod/" target="_blank">man usermod</a>.  Got to love the quick responses.  </p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/05/09/linux-how-do-you-rename-a-user-account-in-linux/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>MySQL Replication Series (tip #1): what should be replicated and what should not be replicated?</title>
		<link>http://crazytoon.com/2008/04/21/mysql-replication-replicate-by-choice/</link>
		<comments>http://crazytoon.com/2008/04/21/mysql-replication-replicate-by-choice/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 01:26:26 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Replication Series]]></category>
		<category><![CDATA[MySQL cluster]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=62</guid>
		<description><![CDATA[Welcome to Tip #1 in MySQL Replication Series.  In this tip we will go over what to do when you only want to replicate certain data to slave(s).  Most general way to tell what is replicated to which slave is to include following configuration directive in my.cnf file depending on your environment and [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to Tip #1 in MySQL Replication Series.  In this tip we will go over what to do when you only want to replicate certain data to slave(s).  Most general way to tell what is replicated to which slave is to include following configuration directive in my.cnf file depending on your environment and your goals.  We will start with slave server side options since you have more flexibility on slave on what to replicate and what not to.</p>
<p>Slave server options:</p>
<ul>
<li><em>replicate-do-db = dbname</em> (or) <em>replicate-do-db = dbname1, dbname2, &#8230;, dbnameN</em><br />
This option is used on slave server to tell the server to only replicate <em>dbname </em>db on this particular host.  You would want to use this if you have a master which is replicating to multiple slaves and each slave may contain different database for read performance reasons.</li>
<li><em>replicate-ignore-db = dbname</em> (or)  <em>replicate-ignore-db = dbname1, dbname2, &#8230;, dbnameN</em><br />
This option is used on slave server to tell server to ignore database(s) listed.  This is used when you want to replicate every database except certain individual ones.  For example, you may want to replicate-ignore-db=testdb</li>
<li><em>replicate-do-table = dbname.tablename</em><br />
This specifies a table from a database to be replicated.</li>
<li><em>replicate-ignore-table = dbname.tablename</em><br />
This is very useful and often ignored.  If you have logging table which you only do writes to but never read from, there is no real point to replicate that table to slave(s).  This way you ignore specific tables.</li>
<li><em>replicate-wild-do-table=dbname.tablename%</em><br />
This is another option which can prove itself to be very useful.  Let&#8217;s say you have database with multiple type of open source installations (phpbb, wordpress, drupal, etc), and you want to designate slave(s) to only be used for phpbb, you would do:  <em>replicate-wild-do-table=dbname.phpbb%</em></li>
<li><em>replicate-wild-ignore-table=dbname.tablename%<br />
</em>Another option which can be used instead of above example.  Say you wanted everything on this particular slave BUT phpbb tables.  You would put this in your config:  <em>replicate-wild-ignore-table=dbname.phpbb%</em></li>
</ul>
<p style="padding-left: 30px;">NOTE:  for wildcards, you can use generic mysql wildcards.</p>
<p>Master server options:</p>
<ul>
<li><em>binlog-do-db = dbnam</em>e (or) <em>binlog-do-db = dbname1, dbname2, &#8230;, dbnameN</em><br />
This option is used on master server to tell the master server to only log queries for dbname db.  This is helpful if your master has multiple databases but you only want to replicate selected few to all slaves.</li>
<li><em>binlog-ignore-db = dbnam</em>e (or) <em>binlog-</em><em>ignore</em><em>-db = dbname1, dbname2, &#8230;, dbnameN<br />
</em>Ignore specified database and do not log queries referring to list database(s).</li>
</ul>
<p>In order for mysql to know which database queries to log (or not to log) you have to make sure you specify what is your default db by doing mysql_select_db() or issuing &#8220;use dbname&#8221; command.   For example, if you had binlog-do-db=forums and you issue a query:  delete from main.users (basically saying, <em>delete </em>everything from <em>users </em>table in <em>main </em>database), it will still log the command even though <em>main </em>database is not in the binlog-do-db list.  To get around this, you should do the following:  <code>use main; delete from users;</code> If you do not do that, your query &#8220;delete from main.users&#8221; will be logged and executed on slave(s).  There is a high probability that you do not have a test database on your slave.</p>
<p>NOTE:  This post is part of series on MySQL Replication.  Here is the original post: <a title="MySQL Replication Series:  How does MySQL replication work?" href="http://crazytoon.com/2008/04/17/mysql-replication-series-how-does-mysql-replication-works/" target="_blank">MySQL Replication Series:  How does MySQL replication work?</a></p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/04/21/mysql-replication-replicate-by-choice/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQL: How do you set up master-master replication in MySQL? (CentOS, RHEL, Fedora)</title>
		<link>http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/</link>
		<comments>http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 21:40:02 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL cluster]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/</guid>
		<description><![CDATA[Setting up master-master replication in MySQL is very similar to how we set up master/slave replication.  You can read up about how to setup master/slave replication in my previous post: How to set up master/slave replication in MySQL.  There is obviously pros and cons about using master/master replication.  But this is not [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up master-master replication in MySQL is very similar to how we <a href="http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/">set up master/slave replication</a>.  You can read up about how to setup master/slave replication in my previous post: <a href="http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/" title="How to set up master/slave replication in MySQL" target="_blank">How to set up master/slave replication in MySQL</a>.  There is obviously pros and cons about using master/master replication.  But this is not a post which discuses advantages and disadvantages for using master/master replication. One of the differences between master/master set up and master/slave is that in master/master set up, you have true redundancy.  If one server dies, second server can take all the inserts/selects.  In master/slave setup, if master dies, you will have to go through steps to make slave become the master.  Master/master set up we are going to set up is essentially master/slave and slave/master.  Meaning, if you had two servers, db0 and db1, your setup will be db0(master)/db1(slave) and also db0(slave)/db1(master).  Here are some assumptions:</p>
<p><code>Master1 server ip:  10.0.0.1<br />
Master2 server ip:  10.0.0.2<br />
Slave username:  slaveuser<br />
Slave pw:  slavepw<br />
Your data directory is:  /usr/local/mysql/var/</code></p>
<p>Let us go through the steps you must take on Master1 to enable it to act as master and slave by using following configuration which goes  under [mysqld] section:</p>
<p><code># let's make it so auto increment columns behave by having different increments on both servers<br />
auto_increment_increment=2<br />
auto_increment_offset=1<br />
# Replication Master Server<br />
# binary logging is required for replication<br />
log-bin=master1-bin<br />
binlog-ignore-db=mysql<br />
binlog-ignore-db=test<br />
# required unique id between 1 and 2^32 - 1<br />
server-id       = 1<br />
#following is the slave settings so this server can connect to master2<br />
master-host = 10.0.0.2<br />
master-user = slaveuser<br />
master-password = slavepw<br />
master-port = 3306</code></p>
<p>Following is the configuration which goes on master2 under [mysqld] section:</p>
<p><code># let's make it so auto increment columns behave by having different increments on both servers<br />
auto_increment_increment=2<br />
auto_increment_offset=2<br />
# Replication Master Server<br />
# binary logging is required for replication<br />
log-bin=master2-bin<br />
binlog-ignore-db=mysql<br />
binlog-ignore-db=test<br />
# required unique id between 1 and 2^32 - 1<br />
server-id       = 2<br />
#following is the slave settings so this server can connect to master2<br />
master-host = 10.0.0.1<br />
master-user = slaveuser<br />
master-password = slavepw<br />
master-port = 3306</code></p>
<p>On master1 server, go to mysql&gt; prompt and add the appropriate user:</p>
<p><code>mysql&gt; grant replication slave on *.* to slaveuser@'10.0.0.2' identified by 'slavepw';</code></p>
<p>On master2 server do the same but allow right ip:</p>
<p><code>mysql&gt; grant replication slave on *.* to slaveuser@'10.0.0.1' identified by 'slavepw';</code></p>
<p>Restart both of the master servers and check slave status:</p>
<p><code>mysql&gt; show slave status\G</code></p>
<p>That is all you have to do to set up the replication.  Of course there are a lot more configuration options but this should get your replication going and you can tweak from here on.</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/02/29/mysql-how-do-you-set-up-mastermaster-replication-in-mysql-centos-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MySQL:  How do you set up master-slave replication in MySQL? (CentOS, RHEL, Fedora)</title>
		<link>http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/</link>
		<comments>http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 03:12:57 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Data Backup]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL backup]]></category>
		<category><![CDATA[MySQL cluster]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/</guid>
		<description><![CDATA[Before we go into how to set up master-slave replication in MySQL, let us talk about some of the reasons I have set up master-slave replication using MySQL.
1)    Offload some of the queries from one server to another and spread the load:  One of the biggest advantages to have master-slave set [...]]]></description>
			<content:encoded><![CDATA[<p>Before we go into how to set up master-slave replication in MySQL, let us talk about some of the reasons I have set up master-slave replication using MySQL.</p>
<p>1)    Offload some of the queries from one server to another and spread the load:  One of the biggest advantages to have master-slave set up in MySQL is to be able to use master for all of the inserts and send some, if not all, select queries to slave.  This will most probably speed up your application without having to diving into optimizing all the queries or buying more hardware.</p>
<p>2)    Do backups from slave:  One of the advantages people overlook is that you can use MySQL slave to do backups from.  That way site is not affected at all when doing backups.  This becomes a big deal when your database has grown to multiple gigs and every time you do backups using mysqldump, site lags when table locks happen.  For some sites, this could mean that site goes down for few secs to minutes.  If you have slave, you just take slave out of rotation (should be built into code) and run backups off the slave.  You can even stop slave MySQL instance and copy the var folder instead of doing mysqldump.</p>
<p>Ok let us dive into how to setup master-slave replication under MySQL.  There are many configuration changes you can do to optimize your MySQL set up.  I will just touch on very basic ones to get the replication to work.  Here are some assumptions:</p>
<blockquote><p>Master server ip:  10.0.0.1<br />
Slave server ip:  10.0.0.2<br />
Slave username:  slaveuser<br />
Slave pw:  slavepw<br />
Your data directory is:  /usr/local/mysql/var/</p></blockquote>
<p>Put the following in your master my.cnf file under [mysqld] section:</p>
<p><code># changes made to do master<br />
server-id           = 1<br />
relay-log           = /usr/local/mysql/var/mysql-relay-bin<br />
relay-log-index     = /usr/local/mysql/var/mysql-relay-bin.index<br />
log-error           = /usr/local/mysql/var/mysql.err<br />
master-info-file    = /usr/local/mysql/var/mysql-master.info<br />
relay-log-info-file = /usr/local/mysql/var/mysql-relay-log.info<br />
datadir             = /usr/local/mysql/var<br />
log-bin             = /usr/local/mysql/var/mysql-bin<br />
# end master</code></p>
<p>Copy the following to slave&#8217;s my.cnf under [mysqld] section:</p>
<p><code># changes made to do slave<br />
server-id           = 2<br />
relay-log           = /usr/local/mysql/var/mysql-relay-bin<br />
relay-log-index     = /usr/local/mysql/var/mysql-relay-bin.index<br />
log-error           = /usr/local/mysql/var/mysql.err<br />
master-info-file    = /usr/local/mysql/var/mysql-master.info<br />
relay-log-info-file = /usr/local/mysql/var/mysql-relay-log.info<br />
datadir             = /usr/local/mysql/var<br />
# end slave setup</code></p>
<p>Create user on master:<br />
<code>mysql&gt; grant replication slave on *.* to slaveuser@'10.0.0.2' identified by 'slavepw';</code></p>
<p>Do a dump of data to move to slave<br />
<code>mysqldump -u root --all-databases --single-transaction --master-data=1 &gt; masterdump.sql</code></p>
<p>import dump on slave<br />
<code>mysql &lt; masterdump.sql</code></p>
<p>After dump is imported go in to mysql client by typing mysql.  Let us tell the slave which master to connect to and what login/password to use:<br />
<code>mysql&gt; CHANGE MASTER TO MASTER_HOST='10.0.0.1',  MASTER_USER='slaveuser', MASTER_PASSWORD='slavepw';</code></p>
<p>Let us start the slave:<br />
<code>mysql&gt; start slave;</code></p>
<p>You can check the status of the slave by typing<br />
<code>mysql&gt; show slave status\G</code></p>
<p>The last row tells you how many seconds its behind the master.  Don’t worry if it doesn’t say 0, the number should be going down over time until it catches up with master (at that time it will show Seconds_Behind_Master: 0)  If it shows NULL, it could be that slave is not started (you can start by typing:  start slave) or it could be that it ran into an error (shows up in Last_errno: and Last_error under show slave status\G).</p>
<p>Related posts:</p>
<ul>
<li><a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" title="How do I dump all tables in a database into separate files?" target="_blank">How do I dump all tables in a database into separate files?</a></li>
<li><a href="http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/" title="How do I import individual table dump files in to MySQL using shell script?" target="_blank">How do I import individual table dump files in to MySQL using shell script?</a></li>
<li><a href="http://crazytoon.com/2007/01/23/mysql-backups-using-mysqldump/" title="MySQL backups using mysqldump" target="_blank">MySQL backups using mysqldump</a></li>
</ul>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2008/01/29/mysql-how-do-you-set-up-masterslave-replication-in-mysql-centos-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>PHP:  How do I install phpsh, interactive shell prompt for php under CentOS or Fedora?</title>
		<link>http://crazytoon.com/2007/12/11/php-how-do-i-install-phpsh-interactive-shell-prompt-for-php-under-centos-or-fedora/</link>
		<comments>http://crazytoon.com/2007/12/11/php-how-do-i-install-phpsh-interactive-shell-prompt-for-php-under-centos-or-fedora/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 08:26:48 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/12/11/php-how-do-i-install-phpsh-interactive-shell-prompt-for-php-under-centos-or-fedora/</guid>
		<description><![CDATA[phpsh requires readline support built into python.  It also requires python version 2.4+. You can check which version of python you have installed by typing:
python -V
Let us download and install readline:
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar zxf readline-5.2.tar.gz
cd readline-5.2
./configure
make install
Now let us install python with readline support:

wget http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tgz
tar zxf Python-2.5.1.tgz
cd Python-2.5.1

I had some problems on one of the [...]]]></description>
			<content:encoded><![CDATA[<p>phpsh requires readline support built into python.  It also requires python version 2.4+. You can check which version of python you have installed by typing:</p>
<p><code>python -V</code></p>
<p>Let us download and install readline:</p>
<p><code>wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz<br />
tar zxf readline-5.2.tar.gz<br />
cd readline-5.2<br />
./configure<br />
make install</code></p>
<p>Now let us install python with readline support:<br />
<code><br />
wget http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tgz<br />
tar zxf Python-2.5.1.tgz<br />
cd Python-2.5.1<br />
</code></p>
<p>I had some problems on one of the servers where it would not compile readline support in to python.  I was able to compile reading support in to python by:</p>
<p><code>echo "readline readline.c -lreadline -ltermcap" &gt;&gt; Modules/Setup.local</code></p>
<p>Now let us continue with python installation.</p>
<p><code>./configure --prefix=/usr/local/python-2.5.1 --enable-readline<br />
make -i install</code></p>
<p>If you do not do &#8220;make -i install&#8221;, install may fail with following error (-i means ignore any errors):<br />
<code>Compiling /usr/lib/python2.5/zipfile.py ...<br />
make: *** [libinstall] Error 1</code></p>
<p>If you scroll up, you will find following error which seems to be the root cause:</p>
<p><code>Compiling /usr/lib/python2.5/test/test_multibytecodec.py ...<br />
Sorry: UnicodeError: ("\\N escapes not supported (can't load unicodedata module)",)</code></p>
<p>Once you do python install with make -i install, that library (unicodedata.so which is not built until later stage of build process) gets installed.  If you want, you can type make install once again (without ignoring errors) and it will complete without errors.</p>
<p>Once you have python installed, you would want to use the new version.  I like to keep a backup of old files in case I have to use older version for any reason.  Run following which creates symbolic links and makes backups of current files:</p>
<p><code>for binaries in `find /usr/local/python-2.5.1/bin/*` ; do<br />
mv /usr/bin/`basename ${binaries}` /usr/bin/`basename ${binaries}`.bak<br />
ln -s ${binaries} /usr/bin/`basename ${binaries}`<br />
done</code></p>
<p>Now let us get phpsh and try it out:</p>
<p><code>wget http://www.phpsh.org/phpsh-latest.tgz<br />
tar zxf phpsh-latest.tgz<br />
cd ../phpsh<br />
chmod +x phpsh<br />
./phpsh</code></p>
<p>At this point you should be at the shell:  php&gt;</p>
<p>Following is a snippet from README file which comes with phpsh.  You should take a look since it has more details on how to use phpsh:</p>
<p><code>Type php commands and they will be evaluated each time you hit enter. Ex:<br />
php&gt; $msg = "hello world"<br />
Put = at the beginning of a line as syntactic sugar for return. Ex:<br />
php&gt; = 2 + 2<br />
If you end a line with a backlash (\), you can enter multi-line input.<br />
For example,<br />
php&gt; print "like \<br />
... this"<br />
like   this<br />
php&gt;</code></p>
<p>There we go.  Now you have a great interactive php shell prompt.  Note that there is interactive mode built into php as well.  I personally do not like it as much but you can try it out for yourself by typing:</p>
<p><code>php -a<br />
Interactive mode enabled<br />
echo "Hello world";<br />
Hello world</code></p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/12/11/php-how-do-i-install-phpsh-interactive-shell-prompt-for-php-under-centos-or-fedora/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQL:  How do I import individual table dump files in to MySQL using shell script?</title>
		<link>http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/</link>
		<comments>http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 03:35:49 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL backup]]></category>
		<category><![CDATA[Notes for self]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/</guid>
		<description><![CDATA[After I wrote the post: How do I dump all tables in a database into separate files? I got emails from couple people asking how to import the individual table files back in to MySQL.  First way to import each sql file created by  the post is to import each file individually by [...]]]></description>
			<content:encoded><![CDATA[<p>After I wrote the post: <a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" rel="bookmark" title="MySQL:  How do I dump all tables in a database into separate files?">How do I dump all tables in a database into separate files?</a> I got emails from couple people asking how to import the individual table files back in to MySQL.  First way to import each sql file created by  <a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" rel="bookmark" title="MySQL:  How do I dump all tables in a database into separate files?">the post</a> is to import each file individually by typing:<code>mysql db_name &lt; table1.sql</code>  This will work as long as you are only importing few files.  But if you need to import all of the files in the directory, which could be in 100&#8217;s, this method does not scale well.  To achieve this I wrote a shell script which does the work for me.  Of course, there are other ways to do this and I am only showing you one way of doing it.  This works for me so here it is:</p>
<p><code>#!/bin/bash<br />
db=$1<br />
if [ "$db" = "" ]; then<br />
echo "Usage: $0 db_name"<br />
exit 1<br />
fi<br />
mkdir done<br />
clear<br />
for sql_file in *.sql; do<br />
echo "Importing $sql_file";<br />
mysql $db&lt; $sql_file;<br />
mv $sql_file done;<br />
done</code></p>
<p>Related posts:</p>
<ul>
<li><a href="http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/" title="How do I dump all tables in a database into separate files?" target="_blank">How do I dump all tables in a database into separate files?</a></li>
<li><a href="http://crazytoon.com/2007/01/23/mysql-backups-using-mysqldump/" title="MySQL backups using mysqldump" target="_blank">MySQL backups using mysqldump</a></li>
</ul>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/11/28/mysql-how-do-i-import-individual-table-dump-files-in-to-mysql-using-shell-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MySQL Cluster:  Changing datamemory requires node restart with &#8211;initial?</title>
		<link>http://crazytoon.com/2007/11/13/mysql-cluster-changing-datamemory-requires-node-restart-with-initial/</link>
		<comments>http://crazytoon.com/2007/11/13/mysql-cluster-changing-datamemory-requires-node-restart-with-initial/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 02:52:57 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL cluster]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/11/13/mysql-cluster-changing-datamemory-requires-node-restart-with-initial/</guid>
		<description><![CDATA[I ran into something with mysql cluster today which boggles my mind.  On http://dev.mysql.com/doc/refman/5.0/en/mysql-cluster-config-params-ndbd.html page, it is documented that if we you change datamemory parameter in the config.ini under mysql-cluster like below, you would have to restart nodes to reread the configuration.
[NDBD]
id=2
HostName=10.0.0.2   # the IP of the first data node
DataMemory=6G
IndexMemory=512M
But when I tried the: [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into something with mysql cluster today which boggles my mind.  On <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-cluster-config-params-ndbd.html" title="MySQL cluster configuration Documentation" target="_blank">http://dev.mysql.com/doc/refman/5.0/en/mysql-cluster-config-params-ndbd.html</a> page, it is documented that if we you change datamemory parameter in the config.ini under mysql-cluster like below, you would have to restart nodes to reread the configuration.</p>
<p>[NDBD]<br />
id=2<br />
HostName=10.0.0.2   # the IP of the first data node<br />
DataMemory=6G<br />
IndexMemory=512M</p>
<p>But when I tried the: 2 restart in the mysql cluster managment console (ndb_mgm), it didn&#8217;t re-read the new configuration.  DataMemory was initially set to 2G and it continued using that configuration.  I even tried: 2 stop, and than logged on the node server and started ndbd manually, but it refused to read the new configuration.  It is only when I did ndbd &#8211;initial, nodes read in the configuration and were able to use more than 2 gigs of ram.</p>
<p>Did anybody else run into this?  Am I reading the documentation on MySQL site incorrectly?</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/11/13/mysql-cluster-changing-datamemory-requires-node-restart-with-initial/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Linux:  How do I mass find and replace text in files under linux using perl?</title>
		<link>http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/</link>
		<comments>http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 07:00:08 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/</guid>
		<description><![CDATA[Few friends have asked me how to do mass find and replace text in files under linux.  There are quite a bit of options in linux to achieve mass replacing of text in files.  If you are doing it file by file, you can achieve that in vi by opening, running replace and [...]]]></description>
			<content:encoded><![CDATA[<p>Few friends have asked me how to do mass find and replace text in files under linux.  There are quite a bit of options in linux to achieve mass replacing of text in files.  If you are doing it file by file, you can achieve that in vi by opening, running replace and closing and going to next file.  But sometimes that can be very tedious and you would rather do mass replacement on all files containing certain extension.  We can do this by using sed or perl.  Since most people are familiar with perl (at least most system admins and programmers), I will show you a perl way of doing it which you can use with sed as well if you wish.  First step is to get perl to do what we want on one file</p>
<p><code>perl -w -i -p -e "s/search_text/replace_text/g" filename</code></p>
<p>-w turns warnings on<br />
-i  makes Perl operate on files in-place (if you would like to make backups, use -i.bak, this will save filename.bak files)<br />
-p loops over the whole input<br />
-e specifies Perl expression<br />
filename  works on one file at a time</p>
<p>Once we get the results we want, we can now pass it multiple files by doing something like:</p>
<p><code>perl -w -i -p -e "s/search_text/replace_text/g" *.php</code></p>
<p>This will search and replace within all php files in the directory you are in.</p>
<p>Now, let us say you want to go through your whole web directory and replace every place where you have &#8220;Perl is good&#8221; to &#8220;Perl is great&#8221;, you would use following command:</p>
<p><code>find /www_root -name "*.php"|xargs  perl -w -i -p -e "s/Perl is good/perl is great/g"</code></p>
<p>find will start at /www_root, look for filenames which have .php extension, xargs takes that filename and passes it to perl as an arguement.</p>
<p>————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/10/29/linux-how-do-i-mass-find-and-replace-text-in-files-under-linux-using-perl/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Linux virus scan:  How do I check my linux installation for viruses using ClamAV? (CentOS, Linux, Redhat)</title>
		<link>http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/</link>
		<comments>http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 03:50:32 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/</guid>
		<description><![CDATA[There are quite a bit of antivirus software exist for Linux nowadays.  One of the popular antivirus software is ClamAV.  We will install Clam AntiVirus software from source and install it to a custom directory.  We will also install gmp-devel package which installs GMP library.  GMP library is used to verify [...]]]></description>
			<content:encoded><![CDATA[<p>There are quite a bit of antivirus software exist for Linux nowadays.  One of the popular antivirus software is <a href="http://www.clamav.org/" title="ClamAV website" target="_blank">ClamAV</a>.  We will install Clam AntiVirus software from source and install it to a custom directory.  We will also install gmp-devel package which installs GMP library.  GMP library is used to verify the digital signature of the virus database.</p>
<p><code>yum -y install gmp-devel<br />
wget http://freshmeat.net/redir/clamav/29355/url_tgz/clamav-0.91.2.tar.gz<br />
adduser -M -s /bin/false clamav<br />
tar zxf clamav-0.91.2.tar.gz<br />
cd clamav-0.91.2<br />
./configure --prefix=/usr/local/clamav<br />
make install<br />
for binaries in `find /usr/local/clamav/bin/*` ; do ln -s ${binaries} /usr/bin/; done</code></p>
<p>At this point Clam AntiVirus is installed and ready for use.   Edit the configuration file and remove the line which says: Example  It is there to ensure.  If you want, you can look at other options but we don&#8217;t need to change anything else here to make ClamAV work for us.</p>
<p><code>vi /usr/local/clamav/etc/freshclam.conf #remove Example</code></p>
<p>Now let us run the <em>freshclam </em>which will download virus database and bring our virus database up to date.   We should do this manually and make sure it didn&#8217;t give any errors.  If this works, you will a lot of &#8220;downloading&#8221; messages.</p>
<p><code>/usr/bin/freshclam</code></p>
<p>If everything checks out, let us add this to our crontab to ensure our virus database is updated hourly.  I chose to be updated every 9 minutes in to every hour.  You can change to fit your needs or leave it as it is.<br />
<code><br />
crontab -e</code></p>
<p>9 * * * *       /usr/bin/freshclam &#8211;quiet</p>
<p>At this point our ClamAV virus database is up to date and now we can scan whichever directory we want.  Go to the directory you want to scan and type:</p>
<p><code>clamscan -r -i</code></p>
<p>Once it is done scanning, it will display something similar to below.<br />
-r parameter tells clamscan to recurse into directories<br />
-i will print out infected filenames</p>
<p><code>----------- SCAN SUMMARY -----------<br />
Known viruses: 159855<br />
Engine version: 0.91.2<br />
Scanned directories: 1437<br />
Scanned files: 8836<br />
Infected files: 0<br />
Data scanned: 464.83 MB<br />
Time: 103.678 sec (1 m 43 s)</code></p>
<p>Happy scanning!<br />
————————————-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/10/19/linux-virus-scan-how-do-i-check-my-linux-installation-for-viruses-using-clamav-centos-linux-redhat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL:  How do I reset MySQL to have only the databases when I first installed it? (CentOS, Redhat, Fedora, Linux)</title>
		<link>http://crazytoon.com/2007/09/13/mysql-reset-mysql-have-only-databases-when-first-installed-centos-redhat-fedora-linux/</link>
		<comments>http://crazytoon.com/2007/09/13/mysql-reset-mysql-have-only-databases-when-first-installed-centos-redhat-fedora-linux/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 06:44:07 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/09/13/mysql-how-do-i-reset-mysql-to-have-only-the-databases-when-i-first-installed-it-centos-redhat-fedora-linux/</guid>
		<description><![CDATA[One of my clients asked me today to make their MySQL installation go back to default database install.  Basically they wanted me to get rid of all their databases (in this case test databases) so they can start fresh and go live with only the databases they needed.  So here are the steps [...]]]></description>
			<content:encoded><![CDATA[<p>One of my clients asked me today to make their MySQL installation go back to default database install.  Basically they wanted me to get rid of all their databases (in this case test databases) so they can start fresh and go live with only the databases they needed.  So here are the steps I followed.</p>
<p>Note:  I have installed their MySQL from source and installed MySQL in to /usr/local/mysql folder.  Your installation path might be different.</p>
<p><code>service mysql stop<br />
cd /usr/local/mysql<br />
mv var var.bak<br />
mkdir var<br />
bin/mysql_install_db<br />
chown -R mysql.mysql  var<br />
chmod 700 -R var<br />
service mysql start<br />
</code><br />
At this point we should have fresh MySQL db setup.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/09/13/mysql-reset-mysql-have-only-databases-when-first-installed-centos-redhat-fedora-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Subversion (SVN):  How do you set up backup for your Subversion repositories?</title>
		<link>http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-repositories/</link>
		<comments>http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-repositories/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 01:00:51 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[Linux Tips]]></category>
		<category><![CDATA[Redhat]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-reposiotries/</guid>
		<description><![CDATA[Subversion is becoming more and more popular every day.  To get quick installation guide, see my post on installing Subversion.  Once you have Subversion set up, make sure you have backups of repository setup!  This is one of those things most people forget to do.  If you followed the installation guide [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion is becoming more and more popular every day.  To get quick installation guide, see my post on <a href="http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/" title="How do you install Subversion?">installing Subversion</a>.  Once you have Subversion set up, make sure you have backups of repository setup!  This is one of those things most people forget to do.  If you followed the installation guide and did source install, you already have a tool available to you.  You can find <span><strong class="command">hot-backup.py </strong></span>tool in the         <tt class="filename">tools/backup/</tt> directory of the Subversion         source distribution.   One thing about this script is that it doesn&#8217;t backup all your repositories.  Which might be an issue if you create more repositories but forget to create a script to backup that particular repository.  Here is a very simple shell script to help you backup all of your subversion repositories.  You can edit it to point to different /svn location if you didn&#8217;t install to default location.  Make sure you copy hot-backup.py to a location which is included in your path so your scripts will work.</p>
<p><code>mkdir /backups/repos -p<br />
for repostobackup in `ls /svn/` ; do<br />
filename=`basename ${repostobackup}`<br />
if [ ! $filename = "" ]; then<br />
hot-backup.py --archive-type=bz2 /svn/${filename} /backups/repos<br />
fi<br />
done</code></p>
<p>This will create your backup files and compress them using bzip2.  You can also use zip or gz if you prefer.  Another thing you should do is to edit the hot-backup.py script and change num_backups to be whatever you think is a good number.  I personally use:  num_backups = 10</p>
<p>That&#8217;s all there is to it.  Just add this script to your crons and your backups will be automated.  You may want to consider moving your backups to another server by adding ftp, scp or rsync at the end of the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/16/subversion-svn-how-do-you-set-up-backup-for-your-subversion-repositories/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>MySQL:  InnoDB: ERROR: the age of the last checkpoint is [number]</title>
		<link>http://crazytoon.com/2007/08/16/mysql-innodb-error-the-age-of-the-last-checkpoint-is-number/</link>
		<comments>http://crazytoon.com/2007/08/16/mysql-innodb-error-the-age-of-the-last-checkpoint-is-number/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 21:32:59 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Data Backup]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux System]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL backup]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/08/16/mysql-innodb-error-the-age-of-the-last-checkpoint-is-number/</guid>
		<description><![CDATA[One of the mysql database servers I manage started to have issues with doing backups yesterday.  mysqldump was running but nothing was happening on the backup side.  I started to investigate to see why our full backups were failing.  I opened up the mysql error log file (mine is at:  /usr/local/mysql/var/hostname.err) [...]]]></description>
			<content:encoded><![CDATA[<p>One of the mysql database servers I manage started to have issues with doing backups yesterday.  mysqldump was running but nothing was happening on the backup side.  I started to investigate to see why our full backups were failing.  I opened up the mysql error log file (mine is at:  /usr/local/mysql/var/hostname.err) and notice there were many instances of following error.</p>
<p><code>070815 15:31:46  InnoDB: ERROR: the age of the last checkpoint is 9433957,<br />
InnoDB: which exceeds the log group capacity 9433498.<br />
InnoDB: If you are using big BLOB or TEXT rows, you must set the<br />
InnoDB: combined size of log files at least 10 times bigger than the<br />
InnoDB: largest such row.</code></p>
<p>I poked around and found out our log files were set to default (5 mb) and they needed to be increased.  After doing some calculations and research, I decided going to 50 mb at this point would be a good way to go.   So I made the change in my.cnf file and added:  <code>innodb_log_file_size = 50M </code></p>
<p>I then stopped our mysql server and restarted it.  And to my horror I saw following error messages show up in the mysql error logs:</p>
<p><code>070815 17:37:40 [ERROR] /usr/local/mysql/libexec/mysqld: Incorrect information in file: './dbname/table_name.frm'<br />
070815 17:37:40 [ERROR] /usr/local/mysql/libexec/mysqld: Incorrect information in file: './dbname/table_name.frm'</code></p>
<p>I stopped the mysql server right away.  I then remember, by help of a friend, that I have to remove the old log files if I change the size by changing <code>innodb_log_file_size</code>.  So I issued a command:  <code>mv ib_logfile? ..</code></p>
<p>This command moves both ib_logfile1 and ib_logfile2 down one directory.  I didn&#8217;t want to just remove &#8216;em so instead I moved them.  After that, I restarted mysql again and to my comfort, everything came back up without errors.  So lesson learned:  if you change ib_logfile size by using  <code>innodb_log_file_size</code> setting, make sure you move existing log files before you start mysql again.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
<small>DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. <strong>Use at your own risk</strong>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/16/mysql-innodb-error-the-age-of-the-last-checkpoint-is-number/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
