<?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; Enterprise level solutions</title>
	<atom:link href="http://crazytoon.com/category/enterprise-level-solutions/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>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>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>MySQL:  How do you use symlinks with MySQL tables?</title>
		<link>http://crazytoon.com/2008/05/02/mysql-how-do-you-use-symlinks-with-mysql-tables/</link>
		<comments>http://crazytoon.com/2008/05/02/mysql-how-do-you-use-symlinks-with-mysql-tables/#comments</comments>
		<pubDate>Fri, 02 May 2008 07:48:34 +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[MySQL]]></category>
		<category><![CDATA[mysql table symlinks]]></category>
		<category><![CDATA[symlinks]]></category>

		<guid isPermaLink="false">http://crazytoon.com/?p=66</guid>
		<description><![CDATA[Creating table symlinks in MySQL is very easy and it is probably one of the features a lot of MySQL users overlook or never think about.  You may ask, why would I want to use symlinks? Some of the reasons you would want symlinks is if you are running low on disk space on [...]]]></description>
			<content:encoded><![CDATA[<p>Creating table symlinks in MySQL is very easy and it is probably one of the features a lot of MySQL users overlook or never think about.  You may ask, why would I want to use symlinks? Some of the reasons you would want symlinks is if you are running low on disk space on the partition where your data generally is and/or you want to move one (or more) table(s) on to a different disk/partition for performance reasons.</p>
<p>One of the things worth mentioning is that MySQL documentation states:  &#8220;Symlinks are fully supported only for MyISAM tables. For files used by tables for other storage engines, you may get strange problems if you try  to use symbolic links.&#8221;  Keeping that in mind, if you have a innodb table and would like to create symlinks for, you should change the engine type to myisam before symlinking. Although, I have heard and personally used symlinks for innodb databases with no side affects.</p>
<p>First let us find out if your MySQL configuration allows symlinks:</p>
<p><code class="literal">mysql&gt; SHOW VARIABLES LIKE 'have_symlink'\G<br />
*************************** 1. row ***************************<br />
Variable_name: have_symlink<br />
Value: YES</code></p>
<p>I am going to make following assumptions:</p>
<ul>
<li>MySQL installation is in /usr/local/mysql.</li>
<li>You want to create new tables under /mnt/another_partition/mysql/var
<ol>
<li>you must create the dir: mkdir /mnt/another_partition/mysql/var -p</li>
<li>Make it owned by mysql user:  chown mysql /mnt/another_partition/mysql/var</li>
</ol>
</li>
</ul>
<p>We will create some test data.  Following are the steps:</p>
<p><code>mysql&gt; create database db1;<br />
Query OK, 1 row affected (0.05 sec)<br />
mysql&gt; use db1;<br />
Database changed<br />
mysql&gt; CREATE TABLE `users` ( `id` int(11) default NULL, `name` varchar(255) default NULL ) ENGINE=myisam, <strong>data directory="/mnt/another_partition/mysql/var", index directory="/mnt/another_partition/mysql/var"</strong>;<br />
Query OK, 0 rows affected (0.09 sec)<br />
mysql&gt; show tables;<br />
+---------------+<br />
| Tables_in_db1 |<br />
+---------------+<br />
| users         |<br />
+---------------+</code></p>
<p>Drop back to command prompt and &#8220;ls&#8221; your db1 directory as shown below.  Here you can see that users table&#8217;s data file (users.MYD) is a symbolic link to the location we specified.  You can see that users index file (users.MYI) is symlinked to the location we specified as well.<br />
<code><br />
# ls -al /usr/local/mysql/var/db1/<br />
total 24K<br />
drwx------   2 mysql mysql 4.0K May  2 00:03 ./<br />
drwx------  23 mysql mysql 4.0K May  1 23:59 ../<br />
-rw-rw----   1 mysql mysql   65 May  1 09:33 db.opt<br />
-rw-rw----   1 mysql mysql 8.4K May  2 00:03 users.frm<br />
lrwxrwxrwx   1 mysql mysql   42 May  2 00:03 users.MYD -&gt; /mnt/another_partition/mysql/var/users.MYD<br />
lrwxrwxrwx   1 mysql mysql   42 May  2 00:03 users.MYI -&gt; /mnt/another_partition/mysql/var/users.MYI</code></p>
<p>Here are the real files which above symlinks are pointing to:</p>
<p><code># ls -al /mnt/another_partition/mysql/var/<br />
total 12K<br />
drwxr-xr-x  2 mysql root  4.0K May  2 00:03 ./<br />
drwxr-xr-x  3 root  root  4.0K May  1 23:39 ../<br />
-rw-rw----  1 mysql mysql    <strong>0</strong> May  2 00:03 users.MYD<br />
-rw-rw----  1 mysql mysql 1.0K May  2 00:03 users.MYI</code></p>
<p>If you go back in to mysql prompt and insert couple rows, you can see the size of users.MYD increase:</p>
<p><code>mysql&gt; insert into db1.users values (1,"test1");<br />
Query OK, 1 row affected (0.01 sec)<br />
mysql&gt; insert into db1.users values (2,"test2");<br />
Query OK, 1 row affected (0.01 sec)<br />
# ls -al /mnt/another_partition/mysql/var/<br />
total 16K<br />
drwxr-xr-x  2 mysql root  4.0K May  2 00:03 ./<br />
drwxr-xr-x  3 root  root  4.0K May  1 23:39 ../<br />
-rw-rw----  1 mysql mysql   <strong>40</strong> May  2 00:08 users.MYD<br />
-rw-rw----  1 mysql mysql 1.0K May  2 00:08 users.MYI</code></p>
<p>If you already have data file and index file you would like to move, I recommend shutting down your MySQL server and moving the files manually and create symbolic links by using &#8220;ln -s&#8221; command.  You can read more about ln by doing <a title="man ln:  man page for ln" href="http://www.lamp-tips.com/man-pages/ln/" target="_blank">man ls</a></p>
<p><strong>NOTE: </strong>Even though MySQL documentation says this is only supported 100% for myisam tables, I  have read few posts where people say they have done this with innodb tables without any problems.  If anybody else can comment on this, I would greatly appreciate it.</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/02/mysql-how-do-you-use-symlinks-with-mysql-tables/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MySQL: Solution for ERROR 1442 (HY000): Can&#8217;t update table &#8216;t1&#8242; in stored function/trigger because it is already used by statement which invoked this stored function/trigger.</title>
		<link>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/</link>
		<comments>http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 02:42:02 +0000</pubDate>
		<dc:creator>Tracy</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Triggers]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/</guid>
		<description><![CDATA[Here is a sample table you can create to test following problem/solution on:
CREATE TABLE `t1` (
`a` char(1) default NULL,
`b` smallint(6) default NULL
);
insert into t1 values ('y','1');
I have a table t1 which has column a and b, I want column a to be updated to &#8216;n&#8217; when column b = 0. Here is the first version [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a sample table you can create to test following problem/solution on:</p>
<p><code>CREATE TABLE `t1` (<br />
`a` char(1) default NULL,<br />
`b` smallint(6) default NULL<br />
);<br />
insert into t1 values ('y','1');</code></p>
<p>I have a table t1 which has column a and b, I want column a to be updated to &#8216;n&#8217; when column b = 0. Here is the first version I created:</p>
<p><code>DELIMITER |<br />
CREATE TRIGGER trigger1 AFTER UPDATE ON t1<br />
FOR EACH ROW UPDATE t1 SET a= 'n' WHERE b=0;<br />
|<br />
DELIMITER ;</code></p>
<p>The trigger created successfully but I got this error when I tried to do an update on column b on table t1:<br />
<code>mysql&gt; update t1 set b=0;<br />
ERROR 1442 (HY000): Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.<br />
</code></p>
<p>After searching online for a while and trying different solutions, I finally found a way to update the table which has trigger on it:<br />
<code><br />
drop trigger trigger1;<br />
DELIMITER |<br />
CREATE TRIGGER trigger1 BEFORE UPDATE ON t1<br />
FOR EACH ROW<br />
BEGIN<br />
IF NEW.b=0 THEN<br />
SET NEW.a = 'n';<br />
END IF;<br />
END<br />
|<br />
DELIMITER ;</code></p>
<p>After the new trigger is in, I issued the same update query and &#8220;<small>ERROR 1442 (HY000): Can&#8217;t update table &#8216;t1&#8242; in stored function/trigger because it is already used by statement which invoked this stored function/trigger.</small>&#8221;  didn&#8217;t show up and it updated the col a value to &#8220;n&#8221; as it suppose to.</p>
<p><code>mysql&gt; update t1 set b=0;<br />
Query OK, 1 row affected (0.01 sec)<br />
Rows matched: 1  Changed: 1  Warnings: 0<br />
mysql&gt; select * from t1\G<br />
*************************** 1. row ***************************<br />
a: <strong>n</strong><br />
b: 0</code></p>
<p>Therefore, if you want to create a trigger on the table which will update itself, make sure you use the NEW.column_name to refer to the row after it&#8217;s updated and don&#8217;t do the full update statement!</p>
<p>However, if you are updating some other table, then you can use the regular update statement:</p>
<p><code>DELIMITER |<br />
CREATE TRIGGER trigger1 AFTER UPDATE ON <strong>t1 </strong><br />
FOR EACH ROW UPDATE<strong> t2 </strong>SET a= 'n' WHERE b=0;<br />
|<br />
DELIMITER ;</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/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used-by-statement-which-invoked-this-stored-functiontrigger/feed/</wfw:commentRss>
		<slash:comments>17</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>Memcached:  How do you install memcached?  (CentOS 64 bit, Linux, Redhat, Fedora)</title>
		<link>http://crazytoon.com/2008/01/20/memcached-how-do-you-install-memcached-centos-64-bit-linux-redhat-fedora/</link>
		<comments>http://crazytoon.com/2008/01/20/memcached-how-do-you-install-memcached-centos-64-bit-linux-redhat-fedora/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 22:52:32 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Caching]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[Linux Apache MySQL PHP]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2008/01/20/memcached-how-do-you-install-memcached-centos-64-bit-linux-redhat-fedora/</guid>
		<description><![CDATA[ [updated 5/16/2010]
Memcached is a very popular open source object caching server.  It was developed to speed up livejournal.com by Danga Interactive.  We use memcached for a lot of our sites.  We use it for different purposes but one main purpose is to cache query results so we don&#8217;t have to keep hitting database.  [...]]]></description>
			<content:encoded><![CDATA[<p> [updated 5/16/2010]</p>
<p>Memcached is a very popular open source object caching server.  It was developed to speed up livejournal.com by Danga Interactive.  We use memcached for a lot of our sites.  We use it for different purposes but one main purpose is to cache query results so we don&#8217;t have to keep hitting database.  As most of the people who work with databases know it is costly to keep hitting database for same information over and over.</p>
<p>When you run the Memcached daemon, it runs and listens on a specific port.  One of the things Memcached does lack is security.  Memcached will let anybody who can make a connection to its port have full access to all objects.  So you would have to run a firewall to block unauthorized access.  It is usually wise to do put firewall on it even if you trust everybody on the same network since accidents do happen.  That said, let&#8217;s get memcached installed!</p>
<p>Let&#8217;s get libevent which is required by Memcached:</p>
<p>wget http://monkey.org/~provos/libevent-1.3e.tar.gz<br />
tar zxpfv libevent*<br />
cd libevent*<br />
./configure<br />
make install</p>
<p>Now let&#8217;s download the newest Memcached source (at time of update to this post 1.4.5 was the latest)</p>
<p>wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz<br />
tar zxpfv memcached*<br />
cd memcached*<br />
./configure<br />
make install</p>
<p>Let&#8217;s add Memcached user to run daemon as since we don&#8217;t need it to run as root privileges.</p>
<p>adduser memcached</p>
<p>We will start the server to use 48 megs of ram (-m 48), listen on ip 10.0.0.2 (-l 10.0.0.2) and run on port 11211 (-p 11211) as user memcached (-u memcached)</p>
<p>./memcached -u memcached -d -m 48 -l 10.0.0.2 -p 11211</p>
<p>If you get the following error (which you will get if you are doing this under CentOS 64 bit):</p>
<p>./memcached: error while loading shared libraries: libevent-1.3e.so.1: cannot open shared object file: No such file or directory</p>
<p>You can fix this by simply doing this:</p>
<p>ln -s /usr/local/lib/libevent-1.3e.so.1 /lib64/</p>
<p>That is all there is to it.  You can see if daemon is running by telneting to the port.</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/01/20/memcached-how-do-you-install-memcached-centos-64-bit-linux-redhat-fedora/feed/</wfw:commentRss>
		<slash:comments>17</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:  How do I dump all tables in a database into separate files?</title>
		<link>http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/</link>
		<comments>http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 00:22:53 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Data Backup]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL backup]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/11/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/</guid>
		<description><![CDATA[There have been numerous occasions where I needed to make backups of individual tables from selected database.  Usually I can achieve this by typing:
mysqldump database_name table1 &#62; table1.sql
mysqldump database_name table2 &#62; table2.sql

This could be very painful if you have 10’s or 100’s of tables. Until today, I never ran into a situation where I [...]]]></description>
			<content:encoded><![CDATA[<p>There have been numerous occasions where I needed to make backups of individual tables from selected database.  Usually I can achieve this by typing:</p>
<p><code>mysqldump database_name table1 &gt; table1.sql<br />
mysqldump database_name table2 &gt; table2.sql<br />
</code><br />
This could be very painful if you have 10’s or 100’s of tables. Until today, I never ran into a situation where I had to deal with dumping more than few tables at a time.   Today I had to do a dump of 181 tables.  I was not going to sit there and type in that command with 181 table names.  It is not just time consuming but it is also stupid.  So I wrote this script to help me with this task.  We still use mysqldump command as described above, except we do it programmatically to make it easier on us:</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 $$<br />
cd $$<br />
clear<br />
for table in `mysql $db -e 'show tables' | egrep -v 'Tables_in_' `; do<br />
echo "Dumping $table"<br />
mysqldump --opt -Q $db $table &gt; $table.sql<br />
done<br />
if [ "$table" = "" ]; then<br />
echo "No tables found in db:  $db"<br />
fi</code></p>
<p>You can also compress your files by adding bzip2, zip or any other compression commands after mysqldump command.  Here is the same script with bzip2 command added:<br />
<code>#!/bin/bash<br />
db=$1<br />
if [ "$db" = "" ]; then<br />
echo "Usage: $0 db_name"<br />
exit 1<br />
fi<br />
mkdir $$<br />
cd $$<br />
clear<br />
for table in `mysql $db -e 'show tables' | egrep -v 'Tables_in_' `; do<br />
echo "Dumping $table"<br />
mysqldump --opt -Q $db $table &gt; $table.sql<br />
bzip2 $table.sql<br />
done<br />
if [ "$table" = "" ]; then<br />
echo "No tables found in db:  $db"<br />
fi</code></p>
<p>I do not recommend doing compression on a production server since most compression program put descent amount of load on the server.  Also note that this will delay your dump considerably.  You may also want to use different parameters for running mysqldump.  Type <a href="http://www.lamp-tips.com/man-pages/mysqldump/" title="man mysqldump - man page for mysqldump" target="_blank"><code>man mysqldump</code></a> in your shell to read more.</p>
<p>Related posts:</p>
<ul>
<li><a href="http://crazytoon.com/2007/03/19/mysql-database-backup-file-compression-gzip-vs-bzip2/" target="_blank" title="MySQL database backup file compress gzip vs bzip2">MySQL database backup file compress gzip vs bzip2</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/26/mysql-how-do-i-dump-all-tables-in-a-database-into-separate-files/feed/</wfw:commentRss>
		<slash:comments>18</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:  Slave lag behind master and data corruption.</title>
		<link>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/</link>
		<comments>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 00:09:10 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Enterprise level solutions]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/</guid>
		<description><![CDATA[I am reaching out to mysql experts out there!  We just inherited a site which uses MySQL master/slave replication.  We set up the master and slaves per MySQL documents and did some of our own tweaking in my.cnf to get things working.  Things were great when we were testing the site but [...]]]></description>
			<content:encoded><![CDATA[<p>I am reaching out to mysql experts out there!  We just inherited a site which uses MySQL master/slave replication.  We set up the master and slaves per MySQL documents and did some of our own tweaking in my.cnf to get things working.  Things were great when we were testing the site but than after we put it up, we started to notice missing data on slaves.  At first, we thought maybe we missed something with the import of data on slaves, so we re-imported.  All tables in our db, at that time, were myisam.  After a day or so, we started to see data corruption on some of the slaves.   We went through and repaired all the tables.  Few hours after the repair, we checked row counts and the repaired tables didn&#8217;t have same count as master did.   Eventually most of our slaves were at the same state so we decided to re-import data from master again.</p>
<p>Before we went ahead and re-imported, we made a decision to move to innodb for *most* of our crucial tables.  After altering on master, we did a dump/import.  Converting tables to innodb got rid of our data corruption problem but our missing rows issue is still there.  Hardware on the master is 4&#215;1.86Ghz, 8 gigs of ram; slaves hardware is: 4&#215;1.86, 4 gigs of ram.</p>
<p>Here is the config running on our master:<br />
<code>&lt; some of the part of the config has been cut off to keep it short/simple and to the point &gt;<br />
skip-locking<br />
ft_min_word_len=2<br />
long_query_time=30<br />
max_connect_errors=10000<br />
max_connections=1000<br />
#skip-grant-tables<br />
skip-bdb<br />
delay-key-write=ALL<br />
key_buffer = 1G<br />
read_buffer_size = 2M<br />
read_rnd_buffer_size = 8M<br />
myisam_sort_buffer_size = 64M<br />
thread_concurrency = 8<br />
skip-name-resolve<br />
max_allowed_packet = 32M<br />
#low-priority-updates<br />
table_cache = 1024<br />
thread_cache = 8<br />
query_cache_size = 64M<br />
#<br />
# added by sunny &gt;<br />
wait_timeout = 120<br />
tmp_table_size = 128M<br />
sort_buffer_size = 128M   # Sort buffer is used to perform sorts for some ORDER BY and GROUP BY queries.<br />
read_rnd_buffer_size = 8M # Read the rows in sorted order by using the row<br />
# pointers in the result file. To optimize this,<br />
# we read in a big block of row pointers, sort them,<br />
# and use them to read the rows in sorted order into a row buffer.<br />
thread_cache_size = 8<br />
#<br />
# Try number of CPU's*2 for thread_concurrency<br />
thread_concurrency = 16<br />
log_slow_queries<br />
log_long_format<br />
#<br />
# INNODB Settings<br />
innodb_additional_mem_pool_size = 32M # was 16<br />
innodb_buffer_pool_size = 4G<br />
innodb_file_per_table<br />
innodb_log_file_size = 50M<br />
innodb_log_buffer_size = 8M<br />
innodb_flush_log_at_trx_commit = 0<br />
innodb_lock_wait_timeout = 50<br />
innodb_flush_method=O_DIRECT</code></p>
<p>Here is the config running on our slave:</p>
<p><code># The MySQL server<br />
[mysqld]<br />
port                = 3306<br />
socket              = /tmp/mysql1.sock<br />
pid-file            = /usr/local/mysql/var/mysql.pid<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 />
server-id           = 31<br />
skip-slave-start<br />
skip-locking<br />
skip-name-resolve<br />
ft_min_word_len=2<br />
long_query_time=30<br />
max_connect_errors=10000<br />
max_connections=1000<br />
#skip-grant-tables<br />
skip-bdb<br />
delay-key-write=ALL<br />
key_buffer = 512M<br />
max_allowed_packet = 1M<br />
table_cache = 512M<br />
myisam_sort_buffer_size = 64M<br />
thread_cache_size = 4<br />
read-only<br />
#slave-skip-errors=all<br />
#<br />
# added by sunny &gt;<br />
wait_timeout = 120<br />
tmp_table_size = 128M<br />
read_buffer_size = 2M<br />
sort_buffer_size = 128M   # Sort buffer is used to perform sorts for some ORDER BY and GROUP BY queries.<br />
read_rnd_buffer_size = 8M # Read the rows in sorted order by using the row<br />
# pointers in the result file. To optimize this,<br />
# we read in a big block of row pointers, sort them,<br />
# and use them to read the rows in sorted order into a row buffer.<br />
thread_cache_size = 8<br />
query_cache_size =  16M # changed to 16 3/1/07<br />
#<br />
# Try number of CPU's*2 for thread_concurrency<br />
thread_concurrency = 8<br />
log_slow_queries<br />
log_long_format<br />
#<br />
# INNODB Settings<br />
default_table_type = INNODB<br />
innodb_additional_mem_pool_size = 32M # was 16<br />
innodb_buffer_pool_size = 2G<br />
innodb_file_per_table<br />
innodb_log_file_size = 50M<br />
innodb_log_buffer_size = 8M<br />
innodb_flush_log_at_trx_commit = 0<br />
innodb_lock_wait_timeout = 50<br />
innodb_flush_method=O_DIRECT</code></p>
<p>Please feel free to comment/scrutinize any of these settings.  If you think they should be different, please give quick summary about why they should be different.  Some of these settings were inherited from old setup of mysql (where they had it hosted before).</p>
<p>Right now we are just trying to find out why we have missing rows and why our slaves lag behind constantly.  We have refreshed data almost every day for last two weeks.  We barely have load average above 1 or 2.  What can we do to track down the problem?   What are the things we should be looking out for?</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/10/15/mysql-slave-lag-behind-master-and-data-corruption/feed/</wfw:commentRss>
		<slash:comments>12</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>
		<item>
		<title>Cron:  crond will not read/honor new entries in crontab file. (CentOS, Redhat, Fedora)</title>
		<link>http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/</link>
		<comments>http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 21:15:59 +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/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/</guid>
		<description><![CDATA[I ran in to something really odd.  I have been using crontab for LONG time and never seen this issue before.  Basically I added new entry into my crontab by type crontab -e and as always saved/exited.  For some reason that command never ran at the time I specified.  I tested [...]]]></description>
			<content:encoded><![CDATA[<p>I ran in to something really odd.  I have been using crontab for LONG time and never seen this issue before.  Basically I added new entry into my crontab by type <code>crontab -e</code> and as always saved/exited.  For some reason that command never ran at the time I specified.  I tested few more times and no luck.  So I started looking on google to find out why crond will not ready my new entries from crontab.  And then while I was looking, I decided to restart crond by issuing:  service crond restart  and to my surprise, my new schedule started working.</p>
<p>While I was looking around for solution for this problem on Google, I came upon few pages where they talked about if you have empty line before command, that command will not work.  For example:</p>
<p><code>#this is a cron file</code></p>
<p><code>* * * * * /do/something</code></p>
<p>In this example, /do/something will not run since there is a blank line before it.  You can fix this by moving that command up or put another comment above it.  This is a very odd thing and I have never experienced it myself but I figured if you stumble upon this post looking for help, blank line before command in crontab might be your issue.  Please comment if you had to delete a blank line to fix your crontab file.  Also mention which OS you are using.  To learn more about crond, see <a href="http://www.lamp-tips.com/man-pages/crond/" title="man crond - man page for crond" target="_blank">man crond</a> and <a href="http://www.lamp-tips.com/man-pages/crontab/" title="man crontab - man page for crontab" target="_blank">man crontab</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/08/16/cron-crond-will-not-readhonor-new-entries-in-crontab-file-centos-redhat-fedora/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH:  Getting error ssh_exchange_identification: Connection closed by remote host</title>
		<link>http://crazytoon.com/2007/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/</link>
		<comments>http://crazytoon.com/2007/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 09:37:37 +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/08/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/</guid>
		<description><![CDATA[Today I was working on setting up public key authentication over SSH on few servers I inherited recently.  I have done this many times and never ran in to following error:
ssh_exchange_identification: Connection closed by remote host
After doing further research on the server I was trying to connect to (looking at logs) I noticed the server [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was working on setting up <a href="http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/" title="Public key authentication over SSH">public key authentication over SSH</a> on few servers I inherited recently.  I have done this many times and never ran in to following error:</p>
<p>ssh_exchange_identification: Connection closed by remote host</p>
<p>After doing further research on the server I was trying to connect to (looking at logs) I noticed the server was denying connection based on ip.  I put my servers ip in /etc/hosts.allow and tried again.  This time I was connected without any problems.  Note that you do not have to restart SSH for hosts.allow change to take affect.</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/05/ssh-getting-error-ssh_exchange_identification-connection-closed-by-remote-host/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH:  Setting up public key authentication over SSH (CentOS, Redhat, Linux, Fedora)</title>
		<link>http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/</link>
		<comments>http://crazytoon.com/2007/08/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 09:10:47 +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/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/</guid>
		<description><![CDATA[Before we go in to details on how to set up public key authentication, I would like to talk about pros and cons about doing this.  After you know the pros and cons, you can make an educated decision.  First, let us talk about biggest benefit about setting up public key authentication over [...]]]></description>
			<content:encoded><![CDATA[<p>Before we go in to details on how to set up public key authentication, I would like to talk about pros and cons about doing this.  After you know the pros and cons, you can make an educated decision.  First, let us talk about biggest benefit about setting up public key authentication over ssh.  Once you set up the keys correctly, you will not need to enter password to access the other server.  For example, you can just type <code>ssh example.com</code> and you will be logged in.  This is the method you must use if you want to set up scripts which are run from crontab.  For example, you may have rsync script running which does backups from one server to another every night.  With every good thing, comes a bad thing.  So let us say &#8220;somebody&#8221; has access to server1 as root.  This somebody could be designated user or it could be a hacker who has gain root access to server1.  Now since we have public key authentication over ssh setup between server1 and server2, this &#8220;somebody&#8221; now can access server2.  As you can see, this can be a problematic.   Now you know number one pro and con about setting up public key authentication over ssh.  Let us now go on and actually go through process to setup keys.</p>
<p>On server1, you type:   <code>ssh-keygen -t rsa</code> (just press enter to keep accepting defaults).  You should see something like this:</p>
<p><code>ssh-keygen -t rsa<br />
Generating public/private rsa key pair.<br />
Enter file in which to save the key (/root/.ssh/id_rsa):<br />
Created directory '/root/.ssh'.<br />
Enter passphrase (empty for no passphrase):<br />
Enter same passphrase again:<br />
Your identification has been saved in /root/.ssh/id_rsa.<br />
Your public key has been saved in /root/.ssh/id_rsa.pub.<br />
The key fingerprint is:<br />
a2:b2:aw:w2:63:25:2a:62:fs:d5:ff:fd:11:f1:aa:60 root@server1</code></p>
<p>Fingerprint for your server will be different.  Now <code>cat /root/.ssh/id_rsa.pub</code> Copy the contents it displays.  You will need this for server2.  Paste it into notepad or any other text editor and make sure it pastes as one line.  This is very crucial you check this.</p>
<p>Now login to server2.  Create the public key by typing:  <code>ssh-keygen -t rsa</code> (this is same thing we did on server1).  Once you are done, type <code>vi /root/.ssh/authorized_keys2</code></p>
<p>Paste the content you copied earlier on server1.  Make sure it is all on one line.  Save/exit.   At this point, we should change the permissions on the file to make sure sshd likes it:  <code>chmod 600 /root/.ssh/authorized_keys2 </code></p>
<p>Go back to server1 and type ssh server2  You should be logged in with out having to put in a password.  If you are prompted for password still, check server2 /root/.ssh/authorized_keys2 file and make sure everything you pasted is one line.</p>
<p>That is all you have to do set up public key authentication over ssh!</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/05/ssh-setting-up-public-key-authentication-over-ssh-centos-redhat-linux-fedora/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Bind:  Quick install guide to install and setup Bind (DNS server) in secure (chroot) environment in Linux (CentOS, Redhat Enterprise (RHEL), Fedora).</title>
		<link>http://crazytoon.com/2007/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/</link>
		<comments>http://crazytoon.com/2007/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/#comments</comments>
		<pubDate>Fri, 22 Jun 2007 06:55:02 +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/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/</guid>
		<description><![CDATA[There are a lot of great articles on setting up Bind and some of them even go in great details on setting up secure DNS server using Bind.  I have used one them time after time called:  Linux Howto:  Chroot Bind How To.  One of the things I do not like [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of great articles on setting up Bind and some of them even go in great details on setting up secure DNS server using Bind.  I have used one them time after time called:  Linux Howto:  <a href="http://www.faqs.org/docs/Linux-HOWTO/Chroot-BIND-HOWTO.html" title="Chroot Bind How To" target="_blank">Chroot Bind How To</a>.  One of the things I do not like about it is that I had to read over things which I really do not need to know or already know.  So I have put together this quick wow To based on this great how to.  Setting up secure DNS server using bind is not very complicated.</p>
<p>Let us dive into this.  First we create user and set up directory structure.</p>
<p><code>echo "named:x:200:200:Nameserver:/chroot/named:/bin/false" &gt;&gt; /etc/passwd<br />
echo "named:x:200:" &gt;&gt; /etc/group<br />
mkdir -p /chroot/named<br />
cd /chroot/named<br />
mkdir -p dev etc/namedb/slave var/run<br />
chown -R named:named /chroot/named/etc/namedb/slave<br />
chown named:named /chroot/named/var/run<br />
mknod /chroot/named/dev/null c 1 3<br />
mknod /chroot/named/dev/random c 1 8<br />
chmod 666 /chroot/named/dev/{null,random}<br />
cp /etc/localtime /chroot/named/etc/</code></p>
<p><code>vi /etc/sysconfig/syslog</code><br />
edit the line which starts with SYSLOGD_OPTIONS and edit it to look like: SYSLOGD_OPTIONS=&#8221;-m 0 -a /chroot/named/dev/log&#8221;<br />
Let us restart syslog to use new settings and let us secure the physical files on the server.</p>
<p><code>/etc/rc.d/init.d/syslog stop<br />
/etc/rc.d/init.d/syslog start<br />
chown root /chroot<br />
chmod 700 /chroot<br />
chown named:named /chroot/named<br />
chmod 700 /chroot/named<br />
cd /chroot/named<br />
chattr +i etc/localtime var</code></p>
<p>Let us clean up previous bind install since most linux installations have named (bind)  pre-installed.<br />
<code><br />
rpm -qa |grep bind<br />
rpm -e --nodeps &lt;copy-paste-all-the-packages-separated-by-space&gt;</code></p>
<p>Let us get the source files for bind and install it.  At time of writing, bind 9.4.1 is the latest.</p>
<p><code>wget http://ftp.isc.org/isc/bind9/9.4.1/bind-9.4.1.tar.gz<br />
tar zxpfv bind-*.gz<br />
cd bind*<br />
./configure<br />
make &amp;&amp; make install</code></p>
<p>copy following content to <code>/etc/init.d/named</code></p>
<p><code>#!/bin/sh<br />
#<br />
# named           This shell script takes care of starting and stopping<br />
#                 named (BIND DNS server).<br />
#<br />
# chkconfig: 345 55 45<br />
# description: named (BIND) is a Domain Name Server (DNS) \<br />
# that is used to resolve host names to IP addresses.<br />
# probe: true<br />
#<br />
# Source function library.<br />
. /etc/rc.d/init.d/functions<br />
#<br />
# Source networking configuration.<br />
. /etc/sysconfig/network<br />
#<br />
# Check that networking is up.<br />
[ ${NETWORKING} = "no" ] &amp;&amp; exit 0<br />
#<br />
[ -f /usr/local/sbin/named ] || exit 0<br />
[ -f /chroot/named/etc/named.conf ] || exit 0<br />
#<br />
# See how we were called.<br />
case "$1" in<br />
start)<br />
# Start daemons.<br />
echo -n "Starting named: "<br />
daemon /usr/local/sbin/named -u named -t /chroot/named -c /etc/named.conf<br />
echo<br />
touch /var/lock/subsys/named<br />
;;<br />
stop)<br />
# Stop daemons.<br />
echo -n "Shutting down named: "<br />
kill `pidof named`<br />
echo<br />
rm -f /var/lock/subsys/named<br />
;;<br />
status)<br />
status named<br />
exit $?<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
exit $?<br />
;;<br />
reload)<br />
/usr/local/sbin/rndc reload<br />
exit $?<br />
;;<br />
probe)<br />
# named knows how to reload intelligently; we don't want linuxconf<br />
# to offer to restart every time<br />
/usr/local/sbin/rndc reload &gt;/dev/null 2&gt;&amp;1 || echo start<br />
exit 0<br />
;;<br />
#<br />
*)<br />
echo "Usage: named {start|stop|status|restart|reload}"<br />
exit 1<br />
esac<br />
#<br />
exit 0</code></p>
<p>Make it executable:  <code>chmod +x /etc/init.d/named</code><br />
Let us set it so &#8220;named&#8221; will automatically start at boot up:  <code>chkconfig --add named</code></p>
<p>Save follow code into <code>/chroot/named/etc/named.conf</code><br />
<code>options {<br />
recursion no; // this will disable lookups against our server recursion no;<br />
directory "/etc/namedb"; // Working directory<br />
pid-file "/var/run/named.pid"; // Put pid file in working dir<br />
forwarders {<br />
10.10.10.10; //ip of dns server to forward requests to<br />
};<br />
statistics-file "/var/run/named.stats";<br />
query-source address * port 53;<br />
version "Bind 10";<br />
};<br />
controls {<br />
inet 127.0.0.1 port 953<br />
allow { 127.0.0.1; } keys { "rndc-key"; };<br />
};<br />
// Root server hints<br />
zone "." {<br />
type hint;<br />
file "root.hint";<br />
};<br />
// Provide a reverse mapping for the loopback address 127.0.0.1<br />
zone "0.0.127.in-addr.arpa" {<br />
type master;<br />
file "db.127.0.0";<br />
notify no;<br />
};</code></p>
<p>Save following in /chroot/named/etc/namedb/root.hint</p>
<p><code>;       This file holds the information on root name servers needed to<br />
;       initialize cache of Internet domain name servers<br />
;       (e.g. reference this file in the "cache  .  &lt;file&gt;"<br />
;       configuration file of BIND domain name servers).<br />
;<br />
;       This file is made available by InterNIC<br />
;       under anonymous FTP as<br />
;           file                /domain/named.root<br />
;           on server           FTP.INTERNIC.NET<br />
;<br />
;       last update:    Nov 5, 2002<br />
;       related version of root zone:   2002110501<br />
;<br />
;<br />
; formerly NS.INTERNIC.NET<br />
;<br />
.                        3600000  IN  NS    A.ROOT-SERVERS.NET.<br />
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4<br />
;<br />
; formerly NS1.ISI.EDU<br />
;<br />
.                        3600000      NS    B.ROOT-SERVERS.NET.<br />
B.ROOT-SERVERS.NET.      3600000      A     128.9.0.107<br />
;<br />
; formerly C.PSI.NET<br />
;<br />
.                        3600000      NS    C.ROOT-SERVERS.NET.<br />
C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12<br />
;<br />
; formerly TERP.UMD.EDU<br />
;<br />
.                        3600000      NS    D.ROOT-SERVERS.NET.<br />
D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90<br />
;<br />
; formerly NS.NASA.GOV<br />
;<br />
.                        3600000      NS    E.ROOT-SERVERS.NET.<br />
E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10<br />
;<br />
; formerly NS.ISC.ORG<br />
;<br />
.                        3600000      NS    F.ROOT-SERVERS.NET.<br />
F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241<br />
;<br />
; formerly NS.NIC.DDN.MIL<br />
;<br />
.                        3600000      NS    G.ROOT-SERVERS.NET.<br />
G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4<br />
;<br />
; formerly AOS.ARL.ARMY.MIL<br />
;<br />
.                        3600000      NS    H.ROOT-SERVERS.NET.<br />
H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53<br />
;<br />
; formerly NIC.NORDU.NET<br />
;<br />
.                        3600000      NS    I.ROOT-SERVERS.NET.<br />
I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17<br />
;<br />
; operated by VeriSign, Inc.<br />
;<br />
.                        3600000      NS    J.ROOT-SERVERS.NET.<br />
J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30<br />
;<br />
; housed in LINX, operated by RIPE NCC<br />
;<br />
.                        3600000      NS    K.ROOT-SERVERS.NET.<br />
K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129<br />
;<br />
; operated by IANA<br />
;<br />
.                        3600000      NS    L.ROOT-SERVERS.NET.<br />
L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12<br />
;<br />
; housed in Japan, operated by WIDE<br />
;<br />
.                        3600000      NS    M.ROOT-SERVERS.NET.<br />
M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33<br />
; End of File</code></p>
<p>This should get you started.  Now just create appropriate zone files and you are good to go.</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/06/21/bind-quick-install-guide-to-install-and-setup-bind-dns-server-in-secure-chroot-environment-in-linux-centos-redhat-enterprise-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ramdisk:  How do you install and set up Ramdisk under Linux (CentOS, RHEL, Fedora)?</title>
		<link>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/</link>
		<comments>http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 23:36:21 +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[Server load]]></category>
		<category><![CDATA[System admin]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/</guid>
		<description><![CDATA[Ramdisk is very good to have if you want something to stay in memory.   Files in memory makes it so you can access them with out having to access hard drive all the time.  Perfect candidates would be things which do not change eg. web images or downloadable files, etc.  If you have Linux Kernel [...]]]></description>
			<content:encoded><![CDATA[<p>Ramdisk is very good to have if you want something to stay in memory.   Files in memory makes it so you can access them with out having to access hard drive all the time.  Perfect candidates would be things which do not change eg. web images or downloadable files, etc.  If you have Linux Kernel 2.4 or later, you already have support of ramdisk built in.  You can check if ramdisk is setup by doing: </p>
<p><code># dmesg | grep RAMDISK<br />
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize</code></p>
<p>You should get above output on CentOS and RHEL.  Other linux flavors will have similar output as well.  If you would like to see how they are named and what you would need to refer to, do the following:</p>
<p><code># ls -l /dev/ram*<br />
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ram -&gt; ram1<br />
brw-rw---- 1 root disk 1, 0 Apr 24 12:05 /dev/ram0<br />
brw-rw---- 1 root disk 1, 1 Apr 24 12:05 /dev/ram1<br />
brw-rw---- 1 root disk 1, 10 Apr 24 12:05 /dev/ram10<br />
brw-rw---- 1 root disk 1, 11 Apr 24 12:05 /dev/ram11<br />
brw-rw---- 1 root disk 1, 12 Apr 24 12:05 /dev/ram12<br />
brw-rw---- 1 root disk 1, 13 Apr 24 12:05 /dev/ram13<br />
brw-rw---- 1 root disk 1, 14 Apr 24 12:05 /dev/ram14<br />
brw-rw---- 1 root disk 1, 15 Apr 24 12:05 /dev/ram15<br />
brw-rw---- 1 root disk 1, 2 Apr 24 12:05 /dev/ram2<br />
brw-rw---- 1 root disk 1, 3 Apr 24 12:05 /dev/ram3<br />
brw-rw---- 1 root disk 1, 4 Apr 24 12:05 /dev/ram4<br />
brw-rw---- 1 root disk 1, 5 Apr 24 12:05 /dev/ram5<br />
brw-rw---- 1 root disk 1, 6 Apr 24 12:05 /dev/ram6<br />
brw-rw---- 1 root disk 1, 7 Apr 24 12:05 /dev/ram7<br />
brw-rw---- 1 root disk 1, 8 Apr 24 12:05 /dev/ram8<br />
brw-rw---- 1 root disk 1, 9 Apr 24 12:05 /dev/ram9<br />
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ramdisk -&gt; ram0</code></p>
<p>All those ramdisks listed have same size.  In above example, they are all 16MB.  Let us change that so we have more space allowed.  Note that I say allowed and not allocated.  We allocate space in one of the later steps by formatting one of the drives above.   Let us set it up so we have 128 MB.  Since this has to be in multiples of 1024, we will setup Ramdisk to have 131072K. </p>
<p><code>vi /etc/grub.conf</code></p>
<p>Find first line which looks similar to following:</p>
<p><code>kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00</code></p>
<p>add ramdisk_size=131072 to the end of the line.  Now your line should look like:</p>
<p><code>kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 <strong>ramdisk_size=131072</strong></code><strong> </strong>Save and exit grub.conf.  At this point you have it configured to have ramdisk with new size but it does not take effect until you reboot your system.  Once you have rebooted your system, we can start doing rest of configurations.</p>
<p><code>mke2fs -m 0 /dev/ram0</code></p>
<p>This will format the ram0 ramdrive for us to use. At this point, kernel will allocate space for you.  Let us setup Ramdisk mount point so we can use it.  We will also have it be owned by user &#8220;sunny&#8221; so that user can read/write to that mount.</p>
<p><code>mkdir /home/ramdisk<br />
mount /dev/ram0 /home/ramdisk<br />
chown sunny.sunny /home/ramdisk</code></p>
<p>At this point you should be able to type:  <strong>mount </strong>and see your new Ramdisk drive mounted on /home/ramdisk</p>
<p>Remember that everything you put on this drive will be gone if you reboot your server.  If you unmounted the Ramdisk drive and remounted it, your files will still be there.  It is because your system has that much ram set aside for your Ramdisk and will not use it for anything else.   If you would like to setup Ramdisk the same next time you boot up, add these lines to your /etc/rc.local files.</p>
<p><code>mke2fs -m 0 /dev/ram0<br />
mount /dev/ram0 /home/ramdisk<br />
chown sunny.sunny /home/ramdisk</code></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/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion:  How do you install and set up Subversion for revision control?</title>
		<link>http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/</link>
		<comments>http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 20:32:24 +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>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/</guid>
		<description><![CDATA[Code revision control is very crucial part of development.  It ensures you know who has changed which files and you are able to rollback to older versions in case new changes are breaking your website page or entire project.  There are few options for you if you are looking into setting up code revision control.  My preferred [...]]]></description>
			<content:encoded><![CDATA[<p>Code revision control is very crucial part of development.  It ensures you know who has changed which files and you are able to rollback to older versions in case new changes are breaking your website page or entire project.  There are few options for you if you are looking into setting up code revision control.  My preferred option is Subversion.  <a target="_blank" href="http://subversion.tigris.org/" title="Subversion: An open-source revision control system.">Subversion</a> is an open-source revision control system which is becoming more and more popular every day.  It is very easy to install and setup your project under Subversion.  If you want detailed instructions, please see the <a target="_blank" href="http://svnbook.org/" title="Subversion Book">Subversion Book</a>.  They do a great job explaining what revision control is, what are the different types of revision control are out there, detailed instructions on installing subversion, doing administrator tasks, etc.  Here are instructions on how to set up Subversion under CentOS.  Same instructions apply to most linux distributions. </p>
<p><strong>YUM Install</strong> </p>
<p>Easiest way to install subversion is via &#8220;yum&#8221; by typing:</p>
<p><code>yum install subversion</code></p>
<p>Once install is done, confirm it by typing &#8220;svn&#8221; at the prompt and you should get:</p>
<p><code>Type 'svn help' for usage.</code></p>
<p>At this point you can skip to &#8220;Setting up Subversion repository&#8221; part.</p>
<p><strong>SOURCE Install</strong></p>
<p>Obtain source from:  <a target="_blank" href="http://subversion.tigris.org/" title="Subversion: An open-source revision control system.">Subversion</a>.  At the time of writing, latest (1.4.3) version can be obtain from this link:  <a href="http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz">http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz</a></p>
<p><code>tar zxf subversion*<br />
cd subversion*<br />
./configure<br />
make &amp;&amp; make install</code></p>
<p>after everything goes well, type svn at the prompt and you should get:</p>
<p><code>Type 'svn help' for usage.</code></p>
<p><strong>Setting up Subversion repository</strong></p>
<p><code>adduser svnusers<br />
mkdir repos/branches -p<br />
mkdir repos/trunk -p<br />
mkdir repos/tags -p<br />
mkdir /svn<br />
svnadmin create /svn/demorepo<br />
svn import --message "Initial set up" repos <a href="file:///svn/demorepo">file:///svn/demorepo</a><br />
cd /svn/demorepo<br />
chown .svnusers . -R<br />
chmod 775 * -R<br />
chmod +s db</code></p>
<p>Thats all there is to it to setup Subversion repository.  At this point, you should <em>add any users</em> you want to have access to the repository by adding them to &#8220;svnusers&#8221; group.</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/06/01/subversion-how-do-you-install-and-set-up-subversion-for-revision-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache:  How do you set up log rotation and archiving for Apache logs?</title>
		<link>http://crazytoon.com/2007/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/</link>
		<comments>http://crazytoon.com/2007/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/#comments</comments>
		<pubDate>Thu, 31 May 2007 23:53:39 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Data Backup]]></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/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/</guid>
		<description><![CDATA[If you have a website and never have archived your apache logs, you may be surprised one day by running out of space due to logs using up all the free space on specific partition. Most people don&#8217;t think about archiving until it is too late. Here we set up a simple log rotation script [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a website and never have archived your apache logs, you may be surprised one day by running out of space due to logs using up all the free space on specific partition. Most people don&#8217;t think about archiving until it is too late. Here we set up a simple log rotation script which will work for apache 1.x and also for apache 2.x version as well. I have included comments in the script itself to help you understand what is going on throughout.</p>
<p><code>#!/bin/sh<br />
#<br />
# Created by:  Sunny Walia<br />
# Date created:  5/24/03<br />
# Date Modified:  5/29/07<br />
# Purpose:  do any type of preprocessing before log.php can do its work.<br />
#           Also does log rotation and backup.<br />
#<br />
# Modification history:<br />
#   5/25/03:    added comments.<br />
#               Gzip and move to backup logs folder<br />
#               added config info on top<br />
#<br />
#<br />
# configuration info<br />
SERVERNAME="svr1"<br />
WORKINGDIR="/admin/backups/$SERVERNAME/logs/"<br />
BACKUPLOGSDIR="/admin/backups/$SERVERNAME/logs/archived/"<br />
BACKUP_DIR="/admin/backups/$SERVERNAME/"<br />
LOGDIR="/usr/local/apache2/logs/"<br />
DATE=`date +%m%d%y%H`<br />
APACHCTL_LOC="/usr/local/apache2/bin/"<br />
#<br />
mkdir $WORKINGDIR -p<br />
mkdir $BACKUPLOGSDIR -p<br />
mkdir $BACKUP_DIR -p<br />
#<br />
# move the logs into their temp name so apache can continue to write to it<br />
mv ${LOGDIR}access_log ${LOGDIR}${SERVERNAME}_access_log.old<br />
mv ${LOGDIR}error_log ${LOGDIR}${SERVERNAME}_error_log.old<br />
#<br />
# restart apache gracefully so it will finish what its doing and start a new log file<br />
# when done serving current requests<br />
${APACHCTL_LOC}apachectl graceful<br />
#<br />
# give some time to apache to finish serving pending requests (in secs)<br />
sleep 15<br />
#<br />
# copy the files to our directory for processing<br />
cp ${LOGDIR}${SERVERNAME}_access_log.old ${WORKINGDIR}${SERVERNAME}_access_log<br />
cp ${LOGDIR}${SERVERNAME}_error_log.old ${WORKINGDIR}${SERVERNAME}_error_log<br />
#<br />
mv ${LOGDIR}${SERVERNAME}_access_log.old ${LOGDIR}${SERVERNAME}_access_log.$DATE<br />
mv ${LOGDIR}${SERVERNAME}_error_log.old ${LOGDIR}${SERVERNAME}_error_log.$DATE<br />
gzip ${LOGDIR}${SERVERNAME}_access_log.$DATE<br />
gzip ${LOGDIR}${SERVERNAME}_error_log.$DATE<br />
#<br />
# we move instead of copy than delete since if mv fails, we still have originals<br />
# mv can fail if target location is full<br />
mv ${LOGDIR}${SERVERNAME}_access_log.$DATE.gz $BACKUPLOGSDIR<br />
mv ${LOGDIR}${SERVERNAME}_error_log.$DATE.gz $BACKUPLOGSDIR<br />
</code></p>
<p>Let us make the script executable:<br />
<code>chmod +x  script_name.sh</code></p>
<p>You can automate this to happen every day by putting it in your crontab:<br />
<code>crontab -e</code></p>
<p><code>1 0 * * * /path/to/this/script</code></p>
<p>This will rotate your logs at 12:01 AM every day.</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/05/31/apache-how-do-you-set-up-log-rotation-and-archiving-for-apache-logs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rsync:  Using rsync to backup data from one server to another over SSH.  Quick rsync tutorial.</title>
		<link>http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/</link>
		<comments>http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/#comments</comments>
		<pubDate>Thu, 24 May 2007 22:30:05 +0000</pubDate>
		<dc:creator>Sunny Walia</dc:creator>
				<category><![CDATA[Data Backup]]></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>
		<category><![CDATA[Windows System]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/</guid>
		<description><![CDATA[Rsync is a great tool which can be used to do many tasks which involved copying/moving data.  If privacy/security is of concern, which it always should be, you can use rsync to do all the copying/moving of data over SSH.  Read through &#8220;man rsync&#8221; to get deeper understanding of rsync.  Here is [...]]]></description>
			<content:encoded><![CDATA[<p>Rsync is a great tool which can be used to do many tasks which involved copying/moving data.  If privacy/security is of concern, which it always should be, you can use rsync to do all the copying/moving of data over SSH.  Read through &#8220;man rsync&#8221; to get deeper understanding of rsync.  Here is my attempt to a short <strong>tutorial on rsync</strong>.   Let us start with most simple example of using rsync over ssh.</p>
<p><code> rsync -ae ssh server1:/home /home/backups/server1_home_backup/</code></p>
<p>This command will download all the files/directories from /home on server1 and copies them to /home/backups/server1_home_backup/<br />
-a = archive mode.  This will preserve permissions, timestamps, etc.<br />
-e = specify which remote shell to use.  In our case, we want to use ssh which follow right after  &#8220;e&#8221;</p>
<p>Let us improve on this and add couple more parameters:</p>
<p><code>rsync -zave ssh --progress server1:/home /home/backups/server1_home_backup/</code><br />
-z = adds zip compression.<br />
-v = verbose<br />
&#8211;progress = my favorite parameter when I am doing rsync manually, not so good when you have it in cron.  This show progress (how_many_files_left/how_many_files_total) and speed along with some other useful data.</p>
<p>Great.. we are moving along pretty good.  Let us add some security to make sure things work the way we want to.</p>
<p><code>rsync --delete-after -zave ssh --progress server1:/home /home/backups/server1_home_backup/</code></p>
<p>&#8211;delete-after = this will delete files on backup server which are missing from source <em>after</em> ALL syncing is done.  If you don&#8217;t care of having extra files on your backup server and have plenty of disk space to spare, do not use this parameter.</p>
<p>Lastly, one of the VERY handy parameters,</p>
<p><code>rsync --delete-after -zave ssh --progress server1:/home /home/backups/server1_home_backup/ -n</code></p>
<p>The -n (or &#8211;dry-run) parameter is great to use for testing.  It will not transfer or delete any files, rather will report to you what it would have done if it was ran with out -n parameter.  This way you can test it with out destroying or transfering data just to find out that is not what you wanted.</p>
<p>For further reading:  <a href="http://www.lamp-tips.com/man-pages/rsync/" title="man rsync - man page for rsync" target="_blank">man rsync</a></p>
]]></content:encoded>
			<wfw:commentRss>http://crazytoon.com/2007/05/24/rsync-using-rsync-to-backup-data-from-one-server-to-another-over-ssh-quick-rsync-tutorial/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
