<?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>Linux Admin Zone &#187; database</title>
	<atom:link href="http://linuxadminzone.com/category/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Simple and efficient MongoDB Backup using script</title>
		<link>http://linuxadminzone.com/simple-and-efficient-mongodb-backup-using-script/</link>
		<comments>http://linuxadminzone.com/simple-and-efficient-mongodb-backup-using-script/#comments</comments>
		<pubDate>Wed, 09 May 2012 10:17:54 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[mongodump]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=511</guid>
		<description><![CDATA[MongoDB Backup types and strategies are neatly explained in its documentation, which you can check here. In case you are not familiar with MongoDB backup types and strategies, please have a look at its documentation. What I am describing here is a simple script which we are using since months to take MongoDB backup and [...]]]></description>
			<content:encoded><![CDATA[<p>MongoDB Backup types and strategies are neatly explained in its documentation, which you can check <a href="http://www.mongodb.org/display/DOCS/Backups" target="_blank">here</a>. In case you are not familiar with MongoDB backup types and strategies, please have a look at its documentation.</p>
<p>What I am describing here is a simple script which we are using since months to take MongoDB backup and transfer it over to our Backup server. Here are few things its doing:</p>
<ul>
<li>As we have multiple MongoDB Replica Sets, the script identify current replica set and check whether current server is Master or Slave, exit if its Master. We take backup only from Slave host.</li>
<li>Take Backup using mongodump command.</li>
<li>Upon successful completion of dump, transfer that to our Backup server. Ensure that ssh key based authentication is setup between both servers to implement seamless and secure transfer. It creates new directory based on current timestamp under replicaset directory in specified path at Backup server and transfer dump there.</li>
<li>Log each steps described above, send alert mail if any step fail with description or send confirmation mail upon successful execution with essential details.</li>
<li>Sample confirmation mail is below:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Subject: Backup <span style="color: #000000; font-weight: bold;">for</span>  <span style="color: #000000; font-weight: bold;">done</span> on  at 09<span style="color: #000000; font-weight: bold;">/</span>May<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span> 08:00:01 AM
Body: Mongo Backup Status <span style="color: #000000; font-weight: bold;">for</span>  on 09<span style="color: #000000; font-weight: bold;">/</span>May<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">12</span> 08:00:01 AM. 
&nbsp;
08:00:01 AM:  is slave and looks OK.
08:00:01 AM: Starting Dump, executing <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mongodb<span style="color: #000000; font-weight: bold;">/</span>mongo<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mongodump <span style="color: #660033;">--out</span> <span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>dump <span style="color: #660033;">--host</span> ...
08:<span style="color: #000000;">34</span>:06 AM: Mongodump <span style="color: #7a0874; font-weight: bold;">command</span> completed. Backup <span style="color: #c20cb9; font-weight: bold;">size</span> is 25G. 
08:<span style="color: #000000;">34</span>:<span style="color: #000000;">10</span> AM: Directory created on backup server, copying data using scp...
08:<span style="color: #000000;">57</span>:00 AM: Copied dump to backup server <span style="color: #000000; font-weight: bold;">in</span> directory <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>Mongodump<span style="color: #000000; font-weight: bold;">/</span>replicaset<span style="color: #000000; font-weight: bold;">/</span>datestamp<span style="color: #000000; font-weight: bold;">/</span>.
08:<span style="color: #000000;">57</span>:00 AM: Mongo Backup process completed successfully.</pre></div></div>

<p>Here is the full bash script, please note that you need to update variables properly and have to check and update it to run in your environment which can be entirely different from mine. Its just an idea to automate MongoDB backup:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">##</span>
<span style="color: #666666; font-style: italic;"># Script to take mongo backup using mongodump and store it in Backup Server</span>
<span style="color: #666666; font-style: italic;">##</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Set variables</span>
<span style="color: #007800;">TodayDate</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%d/%b/%g %r&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">DateStamp</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>y<span style="color: #000000; font-weight: bold;">%</span>H<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #000000; font-weight: bold;">%</span>S<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">CurrentTime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%r&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #007800;">MongoBinPath</span>=<span style="color: #ff0000;">&quot;/usr/local/mongodb/mongo/bin&quot;</span>
<span style="color: #007800;">ReplicaSet</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'rs.status()'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$MongoBinPath</span><span style="color: #000000; font-weight: bold;">/</span>mongo <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">&quot;set&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">\&quot;</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">MongoHost</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">LocalBackupPath</span>=<span style="color: #ff0000;">&quot;/databases/dump&quot;</span>
&nbsp;
<span style="color: #007800;">LogFile</span>=<span style="color: #ff0000;">&quot;/var/log/mongo-backup.log&quot;</span>
<span style="color: #007800;">IsOK</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">CmdStatus</span>=<span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
<span style="color: #007800;">BackupHost</span>=xx.xx.xx.xx
<span style="color: #007800;">BackupHostPath</span>=<span style="color: #ff0000;">&quot;/home/backup/mongobackup&quot;</span>
<span style="color: #007800;">BackupHostPort</span>=<span style="color: #000000;">22</span>
&nbsp;
<span style="color: #007800;">MailNotification</span>=<span style="color: #ff0000;">&quot;admin@domain.com anotheradmin@domain.com&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Mongo Backup Status for <span style="color: #007800;">$ReplicaSet</span> on <span style="color: #007800;">$TodayDate</span>. <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Check whether host is slave and in good state for backup</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;rs.status()&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$MongoBinPath</span><span style="color: #000000; font-weight: bold;">/</span>mongo <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">\&quot;</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-d</span> :<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
 <span style="color: #007800;">IsMaster</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;db.isMaster()&quot;</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$MongoBinPath</span><span style="color: #000000; font-weight: bold;">/</span>mongo <span style="color: #660033;">--host</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> ismaster<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-d</span> ,<span style="color: #000000; font-weight: bold;">`</span>;
 <span style="color: #007800;">TheState</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;rs.status()&quot;</span><span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$MongoBinPath</span><span style="color: #000000; font-weight: bold;">/</span>mongo <span style="color: #660033;">--host</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> mystate <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-d</span> ,<span style="color: #000000; font-weight: bold;">`</span>;
 <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$IsMaster</span> == <span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #007800;">$TheState</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">2</span>  <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">MongoHost</span>=<span style="color: #007800;">$i</span>
  <span style="color: #007800;">IsOK</span>=<span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: <span style="color: #007800;">$MongoHost</span> is slave and looks OK.&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  <span style="color: #7a0874; font-weight: bold;">break</span>
 <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #007800;">CurrentTime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%r&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Exit if not good</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$IsOK</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Error: Either <span style="color: #007800;">$MongoHost</span> is not slave or not in good state. Aborting Backup, Please check!&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
   mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Backup error for <span style="color: #007800;">$ReplicaSet</span> from <span style="color: #007800;">$MongoHost</span> on <span style="color: #007800;">$TodayDate</span>&quot;</span> <span style="color: #007800;">$MailNotification</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #007800;">$LogFile</span>    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>; <span style="color: #000000; font-weight: bold;">fi</span> <span style="color: #666666; font-style: italic;">## Remove earlier backup CmdStatus=$(rm -rf $LocalBackupPath/*) ## Start backup process echo &quot;$CurrentTime: Starting Dump, executing $MongoBinPath/mongodump --out $LocalBackupPath --host $MongoHost...&quot; &amp;gt;&amp;gt; $LogFile</span>
&nbsp;
<span style="color: #007800;">CmdStatus</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #007800;">$MongoBinPath</span><span style="color: #000000; font-weight: bold;">/</span>mongodump <span style="color: #660033;">--out</span> <span style="color: #007800;">$LocalBackupPath</span> <span style="color: #660033;">--host</span> <span style="color: #007800;">$MongoHost</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: There is an issue while trying to take dump in <span style="color: #007800;">$MongoHost</span>. Aborting dump process, please check! &quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$CmdStatus</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Backup error for <span style="color: #007800;">$ReplicaSet</span> from <span style="color: #007800;">$MongoHost</span> on <span style="color: #007800;">$TodayDate</span>&quot;</span> <span style="color: #007800;">$MailNotification</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #007800;">$LogFile</span>   <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">fi</span> <span style="color: #007800;">CurrentTime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%r&quot;</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #007800;">BackupSize</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-sh</span> <span style="color: #007800;">$LocalBackupPath</span><span style="color: #000000; font-weight: bold;">/</span>. <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1 }'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Mongodump command completed. Backup size is <span style="color: #007800;">$BackupSize</span>. &quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## dump is fine then scp it to backup server</span>
<span style="color: #666666; font-style: italic;">## create directory first</span>
<span style="color: #007800;">CmdStatus</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$BackupHostPort</span> <span style="color: #007800;">$BackupHost</span> <span style="color: #ff0000;">&quot;mkdir -p  <span style="color: #007800;">$BackupHostPath</span>/<span style="color: #007800;">$ReplicaSet</span>/<span style="color: #007800;">$DateStamp</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Either failing to connect Backup server using ssh or destination directory already exist!&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$CmdStatus</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Backup error for <span style="color: #007800;">$ReplicaSet</span> from <span style="color: #007800;">$MongoHost</span> on <span style="color: #007800;">$TodayDate</span>&quot;</span> <span style="color: #007800;">$MailNotification</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #007800;">$LogFile</span>   <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">fi</span> <span style="color: #007800;">CurrentTime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%r&quot;</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Directory created on backup server, copying data using scp...&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
&nbsp;
<span style="color: #007800;">CmdStatus</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-P</span> <span style="color: #007800;">$BackupHostPort</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$LocalBackupPath</span><span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #007800;">$BackupHost</span>:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$BackupHostPath</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$ReplicaSet</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$DateStamp</span><span style="color: #000000; font-weight: bold;">/`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Unable to scp dump to <span style="color: #007800;">$BackupHost</span>:/<span style="color: #007800;">$BackupHostPath</span>/<span style="color: #007800;">$ReplicaSet</span>/<span style="color: #007800;">$DateStamp</span> using port <span style="color: #007800;">$BackupHostPort</span>. &quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$CmdStatus</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
  mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Backup error for <span style="color: #007800;">$ReplicaSet</span> from <span style="color: #007800;">$MongoHost</span> on <span style="color: #007800;">$TodayDate</span>&quot;</span> <span style="color: #007800;">$MailNotification</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #007800;">$LogFile</span>   <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">fi</span> <span style="color: #007800;">CurrentTime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%r&quot;</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Copied dump to backup server in directory <span style="color: #007800;">$BackupHost</span><span style="color: #007800;">$BackupHostPath</span>/<span style="color: #007800;">$ReplicaSet</span>/<span style="color: #007800;">$DateStamp</span>/.&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CurrentTime</span>: Mongo Backup process completed successfully.&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LogFile</span>
mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Backup for <span style="color: #007800;">$ReplicaSet</span> done on <span style="color: #007800;">$MongoHost</span> at <span style="color: #007800;">$TodayDate</span>&quot;</span> <span style="color: #007800;">$MailRecipients</span> <span style="color: #007800;">$MailNotification</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #007800;">$LogFile</span></pre></div></div>

<p>Its just a basic script and may needs further enhancements. In case you have suggestion/queries, please put it below in comments.</p>
<p><span style="text-decoration: underline;">More Related and helpful articles:</span></p>
<ul>
<li><a href="http://linuxadminzone.com/optimize-mysql-on-a-large-database-server/"> Setup multiple MySQL database servers in a single Linux host</a></li>
<li><a href="http://linuxadminzone.com/optimize-mysql-on-a-large-database-server/">Optimize MySQL on a large Database Server </a></li>
<li><a href="http://linuxadminzone.com/recover-or-reset-root-password-of-mysql-and-postgresql-servers/">Recover or reset root password of MySQL and PostgreSQL Servers </a></li>
<li><a href="http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/"> Optimize and fix MySQL Server running slow without any load </a></li>
<li><a href="http://linuxadminzone.com/find-out-the-clients-of-your-mysql-server/"> How to find out the clients connecting to your MySQL server </a></li>
<li><a href="http://linuxadminzone.com/quickly-repair-a-huge-corrupted-or-crashed-table-in-mysql/"> Quickly repair huge corrupted or crashed table in MySQL </a></li>
<li><a href="http://linuxadminzone.com/install-and-configure-phpmyadmin-to-manage-multiple-mysql-servers/"> Install and configure PhpMyAdmin to manage multiple MySQL Servers </a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/simple-and-efficient-mongodb-backup-using-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix mysql memory table error: The table xtable is full</title>
		<link>http://linuxadminzone.com/fix-mysql-memory-table-error-the-table-xtable-is-full/</link>
		<comments>http://linuxadminzone.com/fix-mysql-memory-table-error-the-table-xtable-is-full/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 08:34:55 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[memory table]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=474</guid>
		<description><![CDATA[Replication just stopped in one Slave server with error: The table xtable is full which means no more records are permitted to insert in this table by MySQL and hence this has broken the replication. I checked that xtable is having storage engine as Memory. In such tables, the max. no. of records you can [...]]]></description>
			<content:encoded><![CDATA[<p>Replication just stopped in one Slave server with error: The table xtable is full which means no more records are permitted to insert in this table by MySQL and hence this has broken the replication. </p>
<p>I checked that xtable is having storage engine as Memory. In such tables, the max. no. of records you can insert is controlled by variable <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_heap_table_size" target="_blank">max_heap_table_size</a>. When checking the size of this variable, I found that this is having default value:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> show variables like <span style="color: #ff0000;">'max_heap_table_size'</span>;
+---------------------+----------+
<span style="color: #000000; font-weight: bold;">|</span> Variable_name       <span style="color: #000000; font-weight: bold;">|</span> Value    <span style="color: #000000; font-weight: bold;">|</span>
+---------------------+----------+
<span style="color: #000000; font-weight: bold;">|</span> max_heap_table_size <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">16777216</span> <span style="color: #000000; font-weight: bold;">|</span>
+---------------------+----------+
<span style="color: #000000;">1</span> row <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>So we need to increase the value of this variable and then issue Alter Table command to make it effective. Also do not forget to add variable with new value in your my.cnf. </p>
<p>Change the variable value:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">set</span>  <span style="color: #007800;">max_heap_table_size</span>=<span style="color: #000000;">268435456</span>;
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> show variables like <span style="color: #ff0000;">'max_heap_table_size'</span>;
+---------------------+-----------+
<span style="color: #000000; font-weight: bold;">|</span> Variable_name       <span style="color: #000000; font-weight: bold;">|</span> Value     <span style="color: #000000; font-weight: bold;">|</span>
+---------------------+-----------+
<span style="color: #000000; font-weight: bold;">|</span> max_heap_table_size <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">268435456</span> <span style="color: #000000; font-weight: bold;">|</span>
+---------------------+-----------+
<span style="color: #000000;">1</span> row <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Now let&#8217;s truncate the table and issue Alter table on it to make the value effective for this table:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> truncate table xtable;
Query OK, <span style="color: #000000;">0</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.00</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> alter table xtable <span style="color: #007800;">ENGINE</span>=MEMORY;
Query OK, <span style="color: #000000;">88</span> rows affected <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0.06</span> sec<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Records: <span style="color: #000000;">88</span>  Duplicates: <span style="color: #000000;">0</span>  Warnings: <span style="color: #000000;">0</span></pre></div></div>

<p>After this fix, the issue has been resolved. Make sure that you do not run the truncate command on table which have important data. I have issued truncate because it contains temporary/transactional data so we are fine with removing all records here.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/fix-mysql-memory-table-error-the-table-xtable-is-full/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed up large MySQL backup, dump, restore processes</title>
		<link>http://linuxadminzone.com/speed-up-large-mysql-backup-dump-restore-process/</link>
		<comments>http://linuxadminzone.com/speed-up-large-mysql-backup-dump-restore-process/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 07:34:55 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=335</guid>
		<description><![CDATA[In general, MySQL is quite fast at restoring data, but I observed that while restoring 20gb of backup its taking more than the usual time. This can happen when you don&#8217;t have enough memory or if key_buffer_size is not set high enough, then it can take very long time to re-index the data. In CentOS [...]]]></description>
			<content:encoded><![CDATA[<p>In general, MySQL is quite fast at restoring data, but I observed that while restoring 20gb of backup its taking more than the usual time. This can happen when you don&#8217;t have enough memory or if <strong>key_buffer_size</strong> is not set high enough, then it can take very long time to re-index the data. In CentOS 5.2 server with 6gb of RAM, I noticed <strong>key_buffer_size</strong> is set to just 800M which is very low. You should set it at least 20-25% of total RAM. After increasing the value to 2gb, MySQL is able to reload data quite fast. </p>
<p>Though this does trick for me but there are other helpful suggestions also which you can try/check to speed up your backup/restore process, few are as follows: </p>
<p>* Increase value of <strong>key_buffer_size</strong> variable in my.cnf to 20-25% of available RAM as mentioned above. Be aware that, if you make the value too large like setting more than 50% of total RAM, your machine may start to page and become extremely slow. This is because MySQL relies on the operating system to perform file system caching for data reads, so you must leave some room for the file system cache. Anyhow, remember that on 32 bit system, the maximum value <strong>key_buffer_size</strong> can take is 4gb only and setting any greater might crash your MySQL server.</p>
<p>* For InnoDB engine, another very important setting you should consider is to set <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit">innodb_flush_log_at_trx_commit</a> = 2. Reset it to 1 again after restore if you need ACID.</p>
<p>* Again for InnoDB and foreing keys, you could also disable foreign key checks and re-enable it at the end (using SET FOREIGN_KEY_CHECKS=0 and SET FOREIGN_KEY_CHECKS=1).</p>
<p>* Few <a href="http://www.maatkit.org/">maatkit</a>  tools like <a href="http://www.maatkit.org/doc/mk-parallel-dump.html">mk-parallel-dump</a> / <a href="http://www.maatkit.org/doc/mk-parallel-restore.html">mk-parallel-restore</a> will add capability to do dump/restore with multithreaded support utilizing available no. of CPUs but beware maatkit itself not recommending using these tools for backup.</p>
<p>* Try using Extended inserts in dumps but again as client has a fixed size buffer for each line it is reading and extended inserts may exceeds that limit, there&#8217;s possibility that you may not be able to restore your very large dumps.</p>
<p>* Backup/Dump data with &#8211;tab format to make use of mysqlimport, which is faster than mysql < dumpfile. </p>
<p>* You can try importing data with multiple threads, means start individual process to import each table.</p>
<p>* Change database engine if possible. Importing into a heavily transactional engine like innodb is painfully slow. Inserting into a non-transactional engine like MyISAM is much much faster.</p>
<p>* You can also try turning off foreign key checks and turn on auto-commit.</p>
<p>* Also check usage of --disable-keys with InnoDB. </p>
<p>* If you think network may be bottleneck, try --compress when using mysqldump.</p>
<p>* Last but not the least here, you can better take directory dump and restore it when required if your MySQL version is similar. You just need to stop your MySQL server, copy whole data or mysql directory, compress it and store at your backup location. Restore in same way when needed. Its one of the fastest method available and I would recommend using it if you are having separate slave hosts which is taking regular backups etc. You can also check lvmbackup/snapshot etc for more efficiency. </p>
<p>Do you know any other tip/tricks which can speed up taking/restore MySQL dump? Please share by putting a comment below.</p>
<p><strong>More related and helpful articles: </strong><br />
* <a href="http://linuxadminzone.com/optimize-mysql-on-a-large-database-server/"> Optimize MySQL on a large Database Server </a><br />
* <a href="http://linuxadminzone.com/recover-or-reset-root-password-of-mysql-and-postgresql-servers/"> Recover or reset root password of MySQL and PostgreSQL Servers </a><br />
* <a href="http://linuxadminzone.com/setting-up-a-mysql-cluster-7-0-in-redhat-based-linux/"> How to setup MySQL Cluster 7.0 in Redhat based Linux </a><br />
* <a href="http://linuxadminzone.com/optimize-and-fix-mysql-server-running-slow-without-any-load/"> Optimize and fix MySQL Server running slow without any load </a><br />
* <a href="http://linuxadminzone.com/quick-web-based-php-script-to-check-replication-status-of-mysql/"> Quick and simple php based script to check replication status of multiple MySQL Servers </a> </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/speed-up-large-mysql-backup-dump-restore-process/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>quick web based php script to check replication status of MySQL</title>
		<link>http://linuxadminzone.com/quick-web-based-php-script-to-check-replication-status-of-mysql/</link>
		<comments>http://linuxadminzone.com/quick-web-based-php-script-to-check-replication-status-of-mysql/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 16:42:14 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=314</guid>
		<description><![CDATA[This is a basic PHP script to check replication status of single or multiple MySQL servers. You have to update variables in the script to run in browser like user, password, ip of server etc. Here is the script code: &#60;? ########## # # dbrepstatus.php by Jagbir Singh (jags@jagbir.com) # # ######### ?&#62; &#160; &#60;html&#62;&#60;head&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>This is a basic PHP script to check replication status of single or multiple MySQL servers. You have to update variables in the script to run in browser like user, password, ip of server etc. </p>
<p>Here is the script code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">##########
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;"># dbrepstatus.php by Jagbir Singh (jags@jagbir.com)
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#########
</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;html&gt;&lt;head&gt;
&lt;title&gt; Online DB Server status &lt;/title&gt;
&lt;body&gt;
&lt;form name=&quot;ShowStatus&quot; action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;POST&quot;&gt;
&lt;br/&gt;
&lt;table border=1 align=center&gt;
&lt;tr align=center bgcolor=gray&gt;&lt;td colspan=2&gt;&lt;b&gt; Online DB Server Status &lt;/b&gt;&lt;/td&gt; &lt;/tr&gt;
&nbsp;
&lt;!--- TODO: replace your server name in the select list below !&gt;
&nbsp;
&lt;tr &gt;&lt;td align=centre&gt; Select Server: &lt;select name=&quot;server&quot;&gt;
&lt;option value=&quot;s1&quot; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;s1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;selected&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &gt; Server 1 
&lt;option value=&quot;s2&quot; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;s2&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;selected&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &gt; Server 2 
&lt;option value=&quot;s3&quot; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;s3&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;selected&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &gt; Server 3
&lt;option value=&quot;s4&quot; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;s4&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;selected&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &gt; Server 4 
&lt;/select&gt; &lt;/td&gt; 
 &lt;td align=centre&gt; &lt;input type=submit name='show' value='Show Status'&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/form&gt;
&lt;/table&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span> 
<span style="color: #000088;">$serverUp</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">## if any of your server not configured, set this variable to 0 below
</span><span style="color: #000088;">$serverString</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;First Server&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">## server name
</span><span style="color: #000088;">$serverIP</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;w.x.y.z&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">## default IP, anyhow will be changed later
</span><span style="color: #000088;">$dbuser</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;demouser&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$dbpassword</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;demopass&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$imgShow</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;img src='led-green.gif' /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'POST'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;s1&quot;</span><span style="color: #339933;">:</span>
		 <span style="color: #000088;">$serverString</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Server 1&quot;</span><span style="color: #339933;">;</span> 
		 <span style="color: #000088;">$serverIP</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;IP1&quot;</span><span style="color: #339933;">;</span>
		 <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;s2&quot;</span><span style="color: #339933;">:</span>
		 <span style="color: #000088;">$serverString</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Server 2&quot;</span><span style="color: #339933;">;</span> 
		 <span style="color: #000088;">$serverIP</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;IP2&quot;</span><span style="color: #339933;">;</span>
		 <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;s3&quot;</span><span style="color: #339933;">:</span>
		 <span style="color: #000088;">$serverString</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Server 3&quot;</span><span style="color: #339933;">;</span> 
		 <span style="color: #000088;">$serverIP</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;IP3&quot;</span><span style="color: #339933;">;</span>
		 <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;s4&quot;</span><span style="color: #339933;">:</span>
		 <span style="color: #000088;">$serverString</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Server 4&quot;</span><span style="color: #339933;">;</span> 
		 <span style="color: #000088;">$serverIP</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;IP4&quot;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$serverUp</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		 <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;br/&gt;
	&lt;table border=1 align=center width=50%&gt;
	&lt;tr align=center bgcolor=gray&gt;&lt;td colspan=4&gt;&lt;b&gt; Status of <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$serverString</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; : &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$serverIP</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/b&gt;&lt;/td&gt; &lt;/tr&gt;
	&lt;tr &gt; &lt;th bgcolor=lightgray&gt; Status &lt;/th&gt; &lt;th bgcolor=lightgray &gt; Replication &lt;/th&gt; &lt;th bgcolor=lightgray&gt; Delay &lt;/th&gt; &lt;th bgcolor=lightgray&gt; Error &lt;/th&gt; &lt;/tr&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$serverUp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;tr&gt; &lt;td align=center colspan=4&gt; This server is not configured yet! &lt;/td&gt; &lt;/tr&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$contactAdmin</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;a href='mailto:dbadmin@yourmail.com?subject=Replication issue in <span style="color: #006699; font-weight: bold;">$serverString</span>'&gt; Contact Admin &lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>	
		<span style="color: #000088;">$RepStatus</span> <span style="color: #339933;">=</span> `<span style="color: #990000;">mysql</span> <span style="color: #339933;">-</span>h <span style="color: #000088;">$serverIP</span> <span style="color: #339933;">-</span>u <span style="color: #000088;">$dbuser</span> <span style="color: #339933;">-</span>p<span style="color: #000088;">$dbpassword</span> <span style="color: #339933;">-</span>e <span style="color: #0000ff;">&quot;show slave status\G;&quot;</span> <span style="color: #339933;">|</span> egrep <span style="color: #0000ff;">&quot;Slave_IO_Running: | Slave_SQL_Running: | Seconds_Behind_Master:&quot;</span> <span style="color: #339933;">|</span> cut <span style="color: #339933;">-</span>d<span style="color: #0000ff;">':'</span> <span style="color: #339933;">-</span>f2`<span style="color: #339933;">;</span> <span style="color: #000088;">$RepStatus</span><span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$RepStatus</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
		<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$RepRun</span><span style="color: #339933;">,</span> <span style="color: #000088;">$SqlRun</span><span style="color: #339933;">,</span> <span style="color: #000088;">$RepDelay</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$RepStatus</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$RepRun</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$RepRun</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$SqlRun</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SqlRun</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #000088;">$RepDelay</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$RepDelay</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//		echo &quot;&lt;br/&gt; Reprun=$RepRun, IO Run =$SqlRun, Replication delay =$RepDelay&quot;;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$RepRun</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Yes&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$RepRun</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;OK&quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$contactAdmin</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$RepRun</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Replication (IO) Not Running!&quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$imgShow</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;img src='led-red.gif' /&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SqlRun</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;Yes&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$SqlRun</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;None&quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$contactAdmin</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$SqlRun</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SQL thread stopped! &quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$imgShow</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;img src='led-red.gif' /&gt;&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$RepDelay</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$RepDelay</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;None&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$RepDelay</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; seconds.&quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$contactAdmin</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>   
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;tr&gt; &lt;td align=center&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$imgShow</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt; &lt;td align=center&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$RepRun</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;/td&gt; &lt;td align=center&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$RepDelay</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  &lt;/td&gt; &lt;td align=center&gt; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$SqlRun</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  &lt;/td&gt; &lt;/tr&gt;
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$contactAdmin</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;tr&gt; &lt;td align=center colspan=4&gt; <span style="color: #006699; font-weight: bold;">$contactAdmin</span> &lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/table&gt; 
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;/html&gt;
&lt;/body&gt;</pre></div></div>

<p>In my case, there are 4 servers. First is master and all other slaves so what I assumed here is that all servers have same user/pass to access information. Don&#8217;t forget to change user/pass/ip etc. before trying to run this script in browser. Let me know through comments if you any suggestion/enhancement/issue regarding this.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/quick-web-based-php-script-to-check-replication-status-of-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install and configure PhpMyAdmin to manage multiple MySQL Servers</title>
		<link>http://linuxadminzone.com/install-and-configure-phpmyadmin-to-manage-multiple-mysql-servers/</link>
		<comments>http://linuxadminzone.com/install-and-configure-phpmyadmin-to-manage-multiple-mysql-servers/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 08:59:18 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=318</guid>
		<description><![CDATA[If you have read and implemented my previous article: how to run multiple MySQL services on a single box, you may like to manage such multiple installation of MySQL or multiple separate MySQL hosts by using a single PhpMyAdmin installation. This is easy enough to do quickly. I assume you have Apache (httpd) and PHP [...]]]></description>
			<content:encoded><![CDATA[<p>If you have read and implemented my previous article: <a href="http://linuxadminzone.com/setting-up-mutiple-mysql-database-servers-on-a-single-linux-machine/">how to run multiple MySQL services on a single box</a>, you may like to manage such multiple installation of MySQL or multiple separate MySQL hosts by using a single PhpMyAdmin installation. This is easy enough to do quickly. </p>
<p>I assume you have Apache (httpd) and PHP installed where you want to setup PhpMyAdmin. Let&#8217;s proceed to install PhpMyAdmin:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>html
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>downloads.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>phpmyadmin<span style="color: #000000; font-weight: bold;">/</span>phpMyAdmin<span style="color: #000000; font-weight: bold;">/</span>2.11.11.3<span style="color: #000000; font-weight: bold;">/</span>phpMyAdmin-2.11.11.3-english.tar.gz?<span style="color: #007800;">use_mirror</span>=nchc
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf phpMyAdmin-2.11.11.3-english.tar.gz 
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> phpMyAdmin-2.11.11.3-english phpmyadmin
$ <span style="color: #7a0874; font-weight: bold;">cd</span> phpmyadmin</pre></div></div>

<p>You can of course, download and install PhpMyAdmin automatically using Yum, but here I&#8217;ve installed it manually. Now make a config file for it and update that:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> config.sample.inc.php config.inc.php
$ <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">!</span>$</pre></div></div>

<p>in the configuration file, set blowfish_secret to some random value and update config to connect two MySQL servers running on localhost or separately in different hosts. You can add any number of Servers in this config file. For 2 hosts, at the end of editing your config file should be like below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'blowfish_secret'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'W3lC0m3'</span>; <span style="color: #000000; font-weight: bold;">/*</span> YOU MUST FILL IN THIS FOR COOKIE AUTH<span style="color: #000000; font-weight: bold;">!</span> <span style="color: #000000; font-weight: bold;">*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">/*</span>
 <span style="color: #000000; font-weight: bold;">*</span> Servers <span style="color: #000000;">1</span> configuration, running on default port <span style="color: #000000;">3306</span>
 <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #007800;">$i</span> = <span style="color: #000000;">0</span>;
&nbsp;
<span style="color: #007800;">$i</span>++;
<span style="color: #000000; font-weight: bold;">/*</span> Authentication <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'auth_type'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'cookie'</span>;
<span style="color: #000000; font-weight: bold;">/*</span> Server parameters <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'host'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'localhost'</span>;
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'connect_type'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'tcp'</span>;
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'compress'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #c20cb9; font-weight: bold;">false</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">/*</span>
 <span style="color: #000000; font-weight: bold;">*</span> Servers <span style="color: #000000;">2</span> configuration, running on port <span style="color: #000000;">5141</span>
 <span style="color: #000000; font-weight: bold;">*/</span>
&nbsp;
<span style="color: #007800;">$i</span>++;
<span style="color: #000000; font-weight: bold;">/*</span> Authentication <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'auth_type'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'cookie'</span>;
<span style="color: #000000; font-weight: bold;">/*</span> Server parameters <span style="color: #000000; font-weight: bold;">*/</span>
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'host'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'localhost'</span>;
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'port'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'5141'</span>;
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'socket'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'/tmp/mysql_sandbox5141.sock'</span>;
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'connect_type'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #ff0000;">'socket'</span>;
<span style="color: #007800;">$cfg</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'Servers'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">$i</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'compress'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #c20cb9; font-weight: bold;">false</span>;</pre></div></div>

<p>save file and exit from vim. </p>
<p>Now open your browser and access PhpMyAdmin: http://yourserverip/phpmyadmin You will see that in host list there are two servers, select anyone and enter MySQL username/password. Now using PhpMyAdmin you can manage both servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/install-and-configure-phpmyadmin-to-manage-multiple-mysql-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

