<?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>MySQL Fanboy &#187; HOW TO</title>
	<atom:link href="/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlfanboy.com</link>
	<description>Almost crazy about Opensource / Free  information.</description>
	<lastBuildDate>Tue, 26 Nov 2013 22:51:28 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>Percona Tease Kit</title>
		<link>http://www.mysqlfanboy.com/2012/04/percona-tease-kit/</link>
		<comments>http://www.mysqlfanboy.com/2012/04/percona-tease-kit/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 20:17:40 +0000</pubDate>
		<dc:creator><![CDATA[mark]]></dc:creator>
				<category><![CDATA[Commentary]]></category>
		<category><![CDATA[HOW TO]]></category>

		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=827</guid>
		<description><![CDATA[Percona you know I love you.  You have the largest brains working with MySQL. Your toolkit (formerly Maatkit and Aspersa) is a real gift to the MySQL community. But stop teasing us with webinars about what it can do and show us how to use it. The Percona ToolKit needs a cookbook. The documentation is [&#8230;]]]></description>
				<content:encoded><![CDATA[<div><strong></strong><strong>Percona you know I love you.  You have the largest brains working with MySQL. Your toolkit (formerly Maatkit and Aspersa) is a real gift to the MySQL community. But stop teasing us with webinars about what it can do and show us how to use it.</p>
<p>The Percona ToolKit needs a cookbook. The documentation is reference only, very thin and total void of useful examples. You’re beginning to frustrate the masses.</p>
<p>Here is what’s happening.  My MySQL server crashes or stalls ever few months.  I searched the Goog and find PT-Stalk :</p>
<p>“watches for a trigger condition to become true, and then collects data to help in diagnosing problems. It is designed to run as a daemon with root privileges, so that you can diagnose intermittent problems that you cannot observe directly. You can also use it to execute a custom command, or to gather the data on demand without waiting for the trigger to happen.”</p>
<p>I attend your webinar.  I even attend the Percona Live conference in San Francisco to talke with the developer in person and still I get little more then:</p>
<p></strong></p>
<p dir="ltr">pt-stalk [OPTIONS] [-- MYSQL OPTIONS]</p>
</div>
<div><strong id="internal-source-marker_0.3143007152248174"><br />
??!!</p>
<p>Anyone else feel the same?</p>
<p>I’m going to take a deep dive into the Percona ToolKit code and try to bring you some working examples (Cut and Paste).  I’m going to start with PT-STALK because it fills a need.  I’ll pick the next in the line of useful tools that need more documentation.</p>
<p>If you would like be to document a Percona tool you need, leave me a comment.</strong></div>
<div></div>
<div><img class="alignnone" src="http://mark.grennan.com/images/MarkGrennanSigniture.bmp" alt="" width="166" height="69" /></div>
<p><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.mysqlfanboy.com%2F2012%2F04%2Fpercona-tease-kit%2F&amp;count=none&amp;via=MySQLFanBoy&amp;related=MySQLFanBoy:Site+Twitter+account&amp;text=Percona Tease Kit - MySQL Fanboy" class="twitter-share-button">Tweet</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlfanboy.com/2012/04/percona-tease-kit/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The Full Monty &#8211; Version 2</title>
		<link>http://www.mysqlfanboy.com/2012/02/the-full-monty-version-2-3/</link>
		<comments>http://www.mysqlfanboy.com/2012/02/the-full-monty-version-2-3/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 21:13:43 +0000</pubDate>
		<dc:creator><![CDATA[mark]]></dc:creator>
				<category><![CDATA[Commentary]]></category>
		<category><![CDATA[DRDB]]></category>
		<category><![CDATA[HA]]></category>
		<category><![CDATA[Heartbeat]]></category>
		<category><![CDATA[HOW TO]]></category>

		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=794</guid>
		<description><![CDATA[Installing MySQL on CentOS 6.2 with PaceMaker, MHA and more When I work with High Availability software, I’m reminded of the maze in the original computer adventure game “You are Lost in a maze of twisty-turny passages all alike…”. If you search the web for HA programs you will find many well maintained projects all [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>Installing MySQL on CentOS 6.2 with PaceMaker, MHA and more</h2>
<p>When I work with High Availability software, I’m reminded of the maze in the original computer adventure game<em> “You are Lost in a maze of twisty-turny passages all alike…”</em>.</p>
<p>If you search the web for HA programs you will find many well maintained projects all related that refer each other. The goal of this document is to give you with a step by step guide to a production worthy MySQL system. It should provide at least <strong>99.999%</strong> access to your data and be able to scale read requests as you grow.</p>
<p>I have chosen these programs and utilities because they are free (as in beer) and each has enterprise support available. (When you make the money to pay for it.) If you start with this MySQL platform you will avoid many common problems. Just write your application to read and write data from different servers.</p>
<p>Here is what we’ll be using:</p>
<ul>
<li><a href="http://centos.org/ ">CentOS </a>(Redhat) 6.2</li>
<li>MySQL 5.5.xx (<a href="http://www.percona.com">Percona</a>) or the MySQL of your choice</li>
<li><a href="http://www.clusterlabs.org/">Pacemaker </a>- to monitor MySQL’s health</li>
<li><a href="http://code.google.com/p/mysql-master-ha/ ">MySQL HA </a>(MHA) &#8211; to fail over when something happens to the master</li>
<li><a href="http://www.drbd.org/mc/management-console/ ">DRDB </a>Cluster Management Console</li>
<li><a href="http://www.drbd.org/mc/management-console/ ">Percona Toolkit</a> &#8211; to make live easy</li>
<li><a href="http://code.openark.org/forge/openark-kit">OpenArk Kit</a> &#8211; a set of utilities for MySQL</li>
<li><a href="http://www.percona.com/docs/wiki/percona-xtrabackup">xtrabackup </a>for database backups</li>
<li><a href="/mytop">mytop </a>and innotop &#8211; for real time monitoring</li>
</ul>
<p>If you want to see all this work check out my Youtube Video at : <a href="http://tinyurl.com/7yqj5gz">http://tinyurl.com/7yqj5gz</a></p>
<p>I&#8217;ve worked hard to make these instructions cut and past. The <strong><span style="color: #008000;">GREEN</span></strong> stuff gets cut and pasted into the linux command line. The <strong><span style="color: #0000ff;">BLUE</span></strong> is copied into an application (vi, crm etc), but the <strong><span style="color: #ff0000;">RED</span></strong> needs to be edited to fit your environment (passwords, IP). I enjoyed the work. I hope you do to.</p>
<h3><span id="more-794"></span></h3>
<h3>Getting started</h3>
<p>Every good system starts with good hardware. Two things database servers hunger for are disk space and memory. You should supply yours with as much of each as you can afford. My rule of thumb is three times size of one copy of the data. A production system with a RAID-10 disk system is good and two network ports or more is recommended.</p>
<p>To test this installation I&#8217;m building on a VMware server. If you&#8217;d like to know more about my hardware read my &#8220;<a href="http://www.grennan.com/?p=135">Building a Home VMware server</a>&#8221; story.</p>
<h3></h3>
<h3>The Hardware</h3>
<p>The operating system I&#8217;m using is<a href="http://isoredirect.centos.org/centos/6.2/isos/x86_64/ "> CentOS 6.2 64 bit</a>. Don’t use the 32bit versions.</p>
<p>How you define disk space is important part. Choose the type, size and partitions carefully. You don’t want daily activity filling the root file system (/) and taking down the database. The common places this can happen are, the MySQL data directory, the /tmp directory and log space. Keep these in separate partitions. I&#8217;ve found the OS system logs in /var/log take care of them selves. MySQL logs should be keep in the MySQL /data directory.</p>
<p>I&#8217;m test hardware (VMware ESXi 4) has four SAS hard disks. For each MySQL server (db1 and db2) I create four (4) 15Gig virtual hard disks, one on each physical SAS disk. I split each virtual disk into four partitions. The /boot partition is RAID-1 and the / (root), /data and /tmp partitions are RAID-5. The sizes of these partitions depend you your needs but your /boot needs to be about 1G and the / needs to be at least 12G.</p>
<p>This table show my for virtual disk and how they are raid-ed and partitioned.</p>
<div>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top"></td>
<td valign="top">
<p align="center"><strong>Md0 &#8211; /boot</strong></p>
</td>
<td valign="top">
<p align="center"><strong>Md1 &#8211; /</strong></p>
</td>
<td valign="top">
<p align="center"><strong>Md2 – /tmp</strong></p>
</td>
<td valign="top">
<p align="center"><strong>Md3 &#8211; /data</strong></p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center"><strong>Disk 0 &#8211; 15G</strong></p>
</td>
<td valign="top">
<p align="center">256M</p>
</td>
<td valign="top">
<p align="center">4G</p>
</td>
<td valign="top">
<p align="center">512M</p>
</td>
<td valign="top">
<p align="center">11G</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center"><strong>Disk 1 &#8211; 15G</strong></p>
</td>
<td valign="top">
<p align="center">256M</p>
</td>
<td valign="top">
<p align="center">4G</p>
</td>
<td valign="top">
<p align="center">512M</p>
</td>
<td valign="top">
<p align="center">11G</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center"><strong>Disk 2 &#8211; 15G</strong></p>
</td>
<td valign="top">
<p align="center">256M</p>
</td>
<td valign="top">
<p align="center">4G</p>
</td>
<td valign="top">
<p align="center">512M</p>
</td>
<td valign="top">
<p align="center">11G</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center"><strong>Disk 3 &#8211; 15G</strong></p>
</td>
<td valign="top">
<p align="center">256M</p>
</td>
<td valign="top">
<p align="center">Checksum</p>
</td>
<td valign="top">
<p align="center">512M</p>
</td>
<td valign="top">
<p align="center">Checksum</p>
</td>
</tr>
<tr>
<td valign="top">
<p align="center"><strong>Total</strong></p>
</td>
<td valign="top">
<p align="center">1G</p>
</td>
<td valign="top">
<p align="center">12G</p>
</td>
<td valign="top">
<p align="center">2G</p>
</td>
<td valign="top">
<p align="center">33G</p>
</td>
</tr>
</tbody>
</table>
<p>I created a KickStart for this install to make is simpler.<a href=" http://www.mysqlfanboy.com/mysql.ks"> http://www.mysqlfanboy.com/mysql.ks </a></p>
<p>I left the /data parition out of the kickstart because of a bug.  I then build it my hand with this command.</p>
<p>mdadm -Cv /dev/md3 -l5 -n4 /dev/sda6 /dev/sdb6 /dev/sdc6 /dev/sdd6</p>
</div>
<h3></h3>
<h3>Install the OS</h3>
<p>Start with a <span style="text-decoration: underline;"><strong>minimum installation</strong></span> so you&#8217;ll have as few applications installed as possible. No desktop or server applications are needed.</p>
<p>After the install you should update the installed packages and include any packages you know you will be wanting or needed.</p>
<pre><strong><span style="color: #008000;"> yum -y update</span></strong>
<strong><span style="color: #008000;"> yum -y install openssh-clients rsync wget perl-DBI perl-TermReadKey</span></strong></pre>
<p>Remove any supplied MySQL.</p>
<p>Even with a minimum install there is a little clean up. I remove packages that are un-needed.  For better security you should remove  anything that connect to remote systems like bluetooth and printing.</p>
<pre><strong><span style="color: #008000;"> rpm -e mysql</span></strong>
<strong><span style="color: #008000;"> rpm -e mysql-libs --nodeps</span></strong></pre>
<h3></h3>
<h3>Security</h3>
<p>For the install process I turn off the firewall. In secure environments I recommend you leave it in place and deal with restrictions as they come up.</p>
<pre><strong><span style="color: #008000;"> service iptables stop</span></strong>
<strong><span style="color: #008000;"> chkconfig iptables off</span></strong>
<strong><span style="color: #008000;"> service ip6tables stop</span></strong>
<strong><span style="color: #008000;"> chkconfig ip6tables off</span></strong></pre>
<p>Because we are moving the MySQL data directory, you will need to disable SELinux or update it. To disable it, edit /etc/selinux/config and change the SELINUX line to SELINUX=disabled. Then, so you don’t have to reboot Linux for this to take effect, just write a 0 to the SELinux control file.</p>
<pre><strong><span style="color: #008000;"> vi /etc/selinux/config</span></strong></pre>
<p><span style="color: #0000ff;">SELINUX=disabled</span></p>
<pre><strong><span style="color: #008000;"> echo 0 &gt;/selinux/enforce</span></strong></pre>
<p>If you don’t want to disable To update SELinux for the new data directory you will need to have the the SELinux tools installed.</p>
<pre><span style="color: #008000;"><strong> yum -y install policycoreutils-python</strong></span>
<span style="color: #008000;"><strong> semanage fcontext -a -t mysqld_db_t "/data/mysql(/.*)?"</strong></span>
<span style="color: #008000;"><strong> restorecon -Rv /data/mysql</strong></span></pre>
<h3>Swap System</h3>
<p>Serving queries from memory is much better then feeding it from disk. MySQL works hard to store data in a way to improve disk assess.  Feeding data from swap-ed out memory seems like a bad thing.  You not only have to go extra system code and the data is not stored in a way optimized for data.</p>
<p>Turning swap off altogether is a bad idea.  Some system utilities and applications expect there to be some swap available.  Turning down how much swap is used is the way to go.</p>
<p>Edit system control file and turn &#8216;swappness&#8217; to zero.</p>
<pre><strong><span style="color: #008000;">vi /etc/sysctl.conf</span></strong></pre>
<p>and add the line</p>
<pre><strong><span style="color: #0000ff;">sys.swappiness=0</span></strong></pre>
<p>&nbsp;</p>
<h3>Syncing Time</h3>
<p>Time sync is very important to maintaining accurate data. You may want to edit the /etc/ntp.conf file to point to your primary NTP time server. CentOS and Redhat provide time servers for your use. I recommend using pool.ntp.org.</p>
<pre><span style="color: #008000;"><strong> yum -y install ntp</strong></span>
<span style="color: #008000;"><strong> chkconfig ntpd on</strong></span>
<span style="color: #008000;"><strong> ntpdate 0.pool.ntp.org</strong></span>
<span style="color: #008000;"><strong> service ntpd start</strong></span></pre>
<h3></h3>
<h3>Setup SSH</h3>
<p>Now is a good time to make sure DNS works on all servers and each knows their names.</p>
<p>MHA need ssh access to each server. You need to create ssh keys and copy to the mysql servers.</p>
<p>Skip this if you already have ssh keys installed.</p>
<pre><span style="color: #008000;"><strong> ssh-keygen -t dsa -f ~/.ssh/id_dsa -N ""</strong></span>
<span style="color: #008000;"><strong> cp ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys</strong></span>
<span style="color: #008000;"><strong> scp -r ~/.ssh <span style="color: #ff0000;">db2</span>:.</strong></span></pre>
<h3></h3>
<h3>Network configuration</h3>
<p>You can edit all the network setting with the network system configuration utility.</p>
<pre><span style="color: #008000;"><strong> system-config-network</strong></span></pre>
<p>Except you need to insure the hosts can ALWAY resolve each other.</p>
<pre><span style="color: #008000;"><strong> vi /etc/hosts</strong></span></pre>
<p><span style="color: #ff0000;">192.168.2.160 db.grennan.com db</span><br />
<span style="color: #ff0000;"> 192.168.2.161 db1.grennan.com db1</span><br />
<span style="color: #ff0000;"> 192.168.2.162 db2.grennan.com db2</span><br />
<span style="color: #ff0000;"> 192.168.2.163 db3.grennan.com db3</span></p>
<pre><strong><span style="color: #008000;"> scp /etc/hosts <span style="color: #ff0000;">db2</span>:/etc</span></strong></pre>
<p>Now is a good time to reboot each system and check the install.</p>
<pre><strong><span style="color: #008000;"> init 6</span></strong></pre>
<h3></h3>
<h3>MySQL Setup</h3>
<p>Install the MySQL of your choise. I’m installing Percona’s version 5.5.</p>
<pre><span style="color: #008000;"><strong> rpm -e mysql-libs-5.1.52 --nodeps</strong></span>
<span style="color: #008000;"><strong> rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm</strong></span>
<span style="color: #008000;"><strong> yum -y install Percona-Server-shared-compat</strong></span>
<span style="color: #008000;"><strong> yum -y install percona-toolkit</strong></span>
<span style="color: #008000;"><strong> yum -y install Percona-Server-server-55.x86_64</strong></span>
<span style="color: #008000;"><strong> yum -y install Percona-Server-client-55</strong></span></pre>
<p>The default location for MySQL data is /var/lib/mysql. MySQL benefits from being in it’s own partition. I’ll be putting the MySQL data in /data/mysql.</p>
<pre><strong><span style="color: #008000;"> service mysql stop</span></strong>
<strong><span style="color: #008000;"> mkdir /data</span></strong>
<strong><span style="color: #008000;"> mkdir /data/mysql</span></strong>
<strong><span style="color: #008000;"> cp -prv /var/lib/mysql/* /data/mysql</span></strong>
<strong><span style="color: #008000;"> mv /var/lib/mysql /var/lib/mysql-empty</span></strong>
<strong><span style="color: #008000;"> ln -s /data/mysql /var/lib/mysql</span></strong>
<strong><span style="color: #008000;"> chown -R mysql.mysql /data/mysql</span></strong></pre>
<h3></h3>
<h3>Configure MySQL</h3>
<p>You need to change the server-id number on each server. The minimum setting you will need are:</p>
<pre><strong><span style="color: #008000;"> vi /etc/my.cnf</span></strong></pre>
<p><strong><span style="color: #0000ff;">[mysqld]</span></strong><br />
<strong> <span style="color: #0000ff;"> log-bin=mysql-bin</span></strong><br />
<strong> <span style="color: #0000ff;"> server-id=1                         # Each system needs a unique id number</span></strong><br />
<strong> <span style="color: #0000ff;"> innodb_flush_log_at_trx_commit=2</span></strong><br />
<strong> <span style="color: #0000ff;"> sync_binlog=<span style="color: #ff0000;">1</span></span></strong><br />
<strong> <span style="color: #0000ff;"> # relay_log_purge=0 # uncomment on slaves</span></strong><br />
<strong> <span style="color: #0000ff;"> # read_only=1                 # uncomment on slaves</span></strong></p>
<p>Percona has a service to help you configure MySQL for your hardware.   <a href="http://tools.percona.com/">MySQL Configuration Wizard</a></p>
<p>Now we need to add a couple of user before we install the replicator. We also need to set a password for the root user. The root password is blank so just it return.</p>
<p>If you have skip-name-resolve set you will need to substitute the host names for IP addresses.</p>
<pre><strong><span style="color: #008000;"> service mysql start</span></strong>
<strong><span style="color: #008000;"> mysql -h localhost -u root -p</span></strong></pre>
<p>The next set of command are entered into the mysql client. You should have a ‘mysql &gt;’ prompt.</p>
<pre><strong><span style="color: #008000;"> DROP USER ``@`localhost`;</span></strong>
<strong><span style="color: #008000;"> DROP USER ``@`<span style="color: #ff0000;">db1.grennan.com</span>` ;</span></strong>
<strong><span style="color: #008000;"> GRANT ALL on *.* TO `root`@`<span style="color: #ff0000;">192.168.2.</span>%` IDENTIFIED by `<span style="color: #ff0000;">P@ssw0rd</span>` with GRANT option;</span></strong>
<strong><span style="color: #008000;"> GRANT ALL on *.* TO `root`@`localhost` IDENTIFIED by `<span style="color: #ff0000;">P@ssw0rd</span>` with GRANT option;</span></strong>
<strong><span style="color: #008000;"> CREATE USER `repl`@`<span style="color: #ff0000;">192.168.2.</span>%` IDENTIFIED BY `<span style="color: #ff0000;">RepP@ssw0rd</span>`;</span></strong>
<strong><span style="color: #008000;"> GRANT REPLICATION SLAVE ON *.* TO `repl`@`<span style="color: #ff0000;">192.168.2.</span>%`;</span></strong>
<strong><span style="color: #008000;"> grant all on *.* to `hauser`@`<span style="color: #ff0000;">db1.grennan.com</span>` identified by `<span style="color: #ff0000;">P@ssw0rd</span>`;</span></strong>
<strong><span style="color: #008000;"> grant all on *.* to `hauser`@`<span style="color: #ff0000;">db2.grennan.com</span>` identified by `<span style="color: #ff0000;">P@ssw0rd</span>`;</span></strong>
<strong><span style="color: #008000;"> flush privileges;</span></strong>
<strong><span style="color: #008000;"> quit ;</span></strong></pre>
<p>Now, stop MySQL on all servers and copy all the MySQL data files to the slaves.</p>
<p>From the master (db1) at a system prompt ‘#’ :</p>
<pre><strong><span style="color: #008000;"> service mysql stop</span></strong>
<strong><span style="color: #008000;"> ssh db2 `service mysql stop`</span></strong>
<strong><span style="color: #008000;"> rsync -rog --delete /data/mysql root@</span><span style="color: #ff0000;">db2<span style="color: #008000;">:/data</span></span></strong></pre>
<p>Rather than type the password for MySQL each type we connect. We can also setup a usr .my.cnf to prevent this. This should connect you to the master (RW) server from each host.</p>
<pre><strong><span style="color: #008000;"> vi ~/.my.cnf</span></strong></pre>
<p><strong><span style="color: #0000ff;">[Client]</span></strong><br />
<strong> <span style="color: #0000ff;"> user=root</span></strong><br />
<strong> <span style="color: #0000ff;"> password=<span style="color: #ff0000;">P@ssw0rd</span></span></strong><br />
<strong> <span style="color: #0000ff;"> host=localhost</span></strong><br />
<strong> <span style="color: #0000ff;"> socket=/data/mysql/mysql.sock</span></strong></p>
<pre><strong><span style="color: #008000;"> scp .my.cnf <span style="color: #ff0000;">db2</span>:.</span></strong></pre>
<h3></h3>
<h3>Start Replication</h3>
<p>On each system start MySQL and connect the two slaves to the master.</p>
<p>On the master we need to now the bin-file and the position. Note the numbers in <strong><span style="color: #800080;">purple</span></strong>.</p>
<pre><strong><span style="color: #008000;"> service mysql start</span></strong>
<strong><span style="color: #008000;"> mysql -e `reset master; reset slave;`</span></strong>
<strong><span style="color: #008000;"> mysql -e `show master status\G`</span></strong></pre>
<p><strong>*************************** 1. row ***************************</strong><br />
<strong> File: mysql-bin.<span style="color: #800080;">000001</span></strong><br />
<strong> Position: <span style="color: #800080;">107</span></strong><br />
<strong> Binlog_Do_DB:</strong><br />
<strong> Binlog_Ignore_DB:</strong><br />
<strong> 1 row in set (0.00 sec)</strong></p>
<p>On all slaves, use the master’s bin log position to setup replication. Start the slave and note that the IO and SQL are running. (<strong>Yes</strong>).<br />
service mysql start</p>
<pre> <strong><span style="color: #008000;">mysql</span></strong></pre>
<pre> <strong><span style="color: #008000;">stop slave;</span></strong>
<strong><span style="color: #008000;"> CHANGE MASTER TO MASTER_HOST='192.168.2.201', MASTER_USER='repl',</span></strong>
<strong><span style="color: #008000;"> MASTER_PASSWORD='RepP@ssw0rd', MASTER_LOG_FILE='mysql-bin.<span style="color: #800080;">000001</span>', MASTER_LOG_POS=<span style="color: #800080;">107</span> ;</span></strong>
<strong><span style="color: #008000;"> start slave ;</span></strong>
<strong><span style="color: #008000;"> show slave status\G</span></strong></pre>
<p><strong>Slave_IO_Running: Yes</strong><br />
<strong> Slave_SQL_Running: Yes</strong></p>
<h3></h3>
<h3>Installing MHA</h3>
<p>Every MySQL server needs to have a copy of the MHA Node and Manager installed. Download the latest version of MHA from the Google Code server.</p>
<p>http://code.google.com/p/mysql-master-ha/downloads/list</p>
<p>There are a number of required Perl modules. I chose to use the Fedora evaluation packages to resolve these.</p>
<ul>
<li>DBD::mysql</li>
<li>Config::Tiny</li>
<li>Log::Dispatch</li>
<li>Parallel::ForkManager</li>
<li>Time::HiRes</li>
</ul>
<p>Here is my install with the fedora packages.</p>
<pre><strong><span style="color: #008000;"> wget http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm</span></strong>
<strong><span style="color: #008000;"> rpm -i epel-release-6-5.noarch.rpm</span></strong>
<strong><span style="color: #008000;"> yum -y install perl-DBD-MySQL</span></strong>
<strong><span style="color: #008000;"> yum -y install perl-Config-Tiny</span></strong>
<strong><span style="color: #008000;"> yum -y install perl-Log-Dispatch</span></strong>
<strong><span style="color: #008000;"> yum -y install perl-Parallel-ForkManager</span></strong>
<strong><span style="color: #008000;"> yum -y install perl-Time-HiRes</span></strong>
<strong><span style="color: #008000;"> wget http://mysql-master-ha.googlecode.com/files/mha4mysql-node-0.53-0.el6.noarch.rpm</span></strong>
<strong><span style="color: #008000;"> rpm -i mha4mysql-node-0.53-0.el6.noarch.rpm</span></strong>
<strong><span style="color: #008000;"> wget http://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.53-0.el6.noarch.rpm</span></strong>
<strong><span style="color: #008000;"> rpm -i mha4mysql-manager-0.53-0.noarch.rpm</span></strong></pre>
<p>MHA only need one configuration file on each server. You can name this file anything you want. Change the setting and make sure the directories exist and are writable.</p>
<pre><strong><span style="color: #008000;"> vi /etc/MHA.cnf</span></strong></pre>
<p>Insert this configuration data into the MHA.cnf file.</p>
<p><strong><span style="color: #0000ff;">[server default]</span></strong><br />
<strong> <span style="color: #0000ff;"> user=root</span></strong><br />
<strong> <span style="color: #0000ff;"> password=<span style="color: #ff0000;">P@ssw0rd</span></span></strong><br />
<strong> <span style="color: #0000ff;"> manager_workdir=/var/log/masterha</span></strong><br />
<strong> <span style="color: #0000ff;"> manager_log=/var/log/masterha/MHA.log</span></strong><br />
<strong> <span style="color: #0000ff;"> remote_workdir=/var/log/masterha</span></strong></p>
<p><strong><span style="color: #0000ff;">[server1]</span></strong><br />
<strong> <span style="color: #0000ff;"> hostname=<span style="color: #ff0000;">db1</span></span></strong></p>
<p><strong><span style="color: #0000ff;">[server2]</span></strong><br />
<strong> <span style="color: #0000ff;"> hostname=<span style="color: #ff0000;">db2</span></span></strong></p>
<p>You should have already installed SSH keys (see above) and the ‘hauser’ installed in MySQL.</p>
<p>masterha_check_ssh is used to check if you have SSH working. Look for the OK after the connect test.</p>
<pre><strong><span style="color: #008000;"> masterha_check_ssh --conf=/etc/MHA.cnf</span></strong></pre>
<p><strong>Thu Dec 1 10:10:52 2011 &#8211; [info] Starting SSH connection tests..</strong><br />
<strong> Thu Dec 1 10:10:53 2011 &#8211; [debug]</strong><br />
<strong> Thu Dec 1 10:10:52 2011 &#8211; [debug] Connecting via SSH from root@db1(192.168.0.11) to root@db2(192.168.2.12)..</strong><br />
<strong> Thu Dec 1 10:10:53 2011 &#8211; [debug] ok.</strong></p>
<p>masterha_check_repl is used to check MySQL replicaton. This is chatty. Your are looking for the ‘MySQL Replication Health is OK’ at the end. You should pay attention to any warnings.</p>
<pre><strong><span style="color: #008000;"> masterha_check_repl --conf=/etc/MHA.cnf</span></strong></pre>
<p><strong>&#8212;</strong><br />
<strong> Thu Dec 1 10:07:22 2011 &#8211; [info] Checking slave configurations..</strong><br />
<strong> Thu Dec 1 10:07:22 2011 &#8211; [warning] read_only=1 is not set on slave db2(192.168.0.11:3306).</strong><br />
<strong> Thu Dec 1 10:07:22 2011 &#8211; [warning] relay_log_purge=0 is not set on slave db2(192.168.0.12:3306).</strong><br />
<strong> &#8212;</strong><br />
<strong> MySQL Replication Health is OK.</strong></p>
<p>&nbsp;</p>
<p>You now have MHA installed. If the configure it wrong MHA will give some errors that are not helpful and die. check the system logs (/var/log/messages) and your MHA settings and try again.</p>
<p>We’ll be using Pacemaker and a command like this to fail over to a slave when the master dies.</p>
<p>masterha_master_switch &#8211;master_state=dead &#8211;dead_master_host=db1 &#8211;conf=/etc/MHA.cnf</p>
<h3></h3>
<h3>Putting the H in High Availability (HA)</h3>
<p>There are may ways a system can fail and even with MySQL running. How do you know when your dead? How do you make the new is system ready to accept data? Are your servers even on the same network? I’ve chosen PaceMaker because it is the most complete and flexible.</p>
<h3>Install Pacemaker / CoroSync</h3>
<p>Neither RedHat or CentOS supply PaceMaker packeges. RedHat support their own propitiatory clustering suite. CentOS does supply heartbeat. Thankfully PaceMaker project provide it in EPEL repository for Redhat 5.</p>
<p>Note we are installing PaceMaker for RedHat 5 not 6.2. At the time of this writing a version for 6.2 was not available. This create some dependence problems we have to work around.</p>
<pre><strong><span style="color: #008000;"> wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo</span></strong>
<strong><span style="color: #008000;"> yum -y install libtool-ltdl</span></strong>
<strong><span style="color: #008000;"> ln -s /usr/lib64/libltdl.so.7.2.1 /usr/lib64/libltdl.so.3</span></strong>
<strong><span style="color: #008000;"> yum -y install net-snmp</span></strong>
<strong><span style="color: #008000;"> wget http://www.clusterlabs.org/rpm/epel-5/x86_64/cluster-glue-1.0.6-1.6.el5.x86_64.rpm</span></strong>
<strong><span style="color: #008000;"> wget http://www.clusterlabs.org/rpm/epel-5/x86_64/cluster-glue-libs-1.0.6-1.6.el5.x86_64.rpm</span></strong>
<strong><span style="color: #008000;"> rpm -i cluster-glue-1.0.6-1.6.el5.x86_64.rpm --nodeps</span></strong>
<strong><span style="color: #008000;"> rpm -i cluster-glue-libs-1.0.6-1.6.el5.x86_64.rpm --nodeps</span></strong>
<strong><span style="color: #008000;"> yum -y install pacemaker corosync heartbeat</span></strong></pre>
<p>Again, make sure all the name resolves are in place on both DB1 and DB2. Heartbeat and Pacemaker provide the group communications and process management respectivly. The nodes must be able to communicate with each other.</p>
<h3>Configure CoroSync</h3>
<p>On both DB1 and DB2.</p>
<pre><strong><span style="color: #008000;"> corosync-keygen</span></strong>
<strong><span style="color: #008000;"> chown root:root /etc/corosync/authkey</span></strong>
<strong><span style="color: #008000;"> chmod 400 /etc/corosync/authkey</span></strong></pre>
<pre><strong><span style="color: #008000;"> vi /etc/corosync/corosync.conf</span></strong></pre>
<p><strong><span style="color: #0000ff;">totem {</span></strong><br />
<strong> <span style="color: #0000ff;">    version: 2</span></strong><br />
<strong> <span style="color: #0000ff;">    token: 5000 # How long before declaring a token lost (ms)</span></strong><br />
<strong> <span style="color: #0000ff;">    token_retransmits_before_loss_const: 20 # How many token retransmits</span></strong><br />
<strong> <span style="color: #0000ff;">    # before forming a new configuration</span></strong><br />
<strong> <span style="color: #0000ff;">    join: 1000 # How long to wait for join messages in the membership protocol (ms)</span></strong><br />
<strong> <span style="color: #0000ff;">    consensus: 7500 # How long to wait for consensus to be achieved before</span></strong><br />
<strong> <span style="color: #0000ff;">    # starting a new round of membership configuration (ms)</span></strong><br />
<strong> <span style="color: #0000ff;">    vsftype: none # Turn off the virtual synchrony filter</span></strong><br />
<strong> <span style="color: #0000ff;">    max_messages: 20 # Number of messages that may be sent by</span></strong><br />
<strong> <span style="color: #0000ff;">    #one processor on receipt of the token</span></strong><br />
<strong> <span style="color: #0000ff;">    secauth: off # Disable encryption</span></strong><br />
<strong> <span style="color: #0000ff;">    threads: 0 # How many threads to use for encryption/decryption</span></strong><br />
<strong> <span style="color: #0000ff;">    clear_node_high_bit: yes # Limit generated nodeids to 31-bits (positive signed integers)</span></strong><br />
<strong> <span style="color: #0000ff;">    # Optionally assign a fixed node id (integer)</span></strong><br />
<strong> <span style="color: #0000ff;">    # nodeid: 1234</span></strong><br />
<strong> <span style="color: #0000ff;">    interface {</span></strong><br />
<strong> <span style="color: #0000ff;">        ringnumber: 0</span></strong><br />
<strong> <span style="color: #0000ff;">        # The following three values need to be set based on your environment</span></strong><br />
<strong> <span style="color: #0000ff;">        bindnetaddr: <span style="color: #ff0000;">192.168.2.201</span></span></strong><br />
<strong> <span style="color: #0000ff;">        mcastaddr: 239.255.42.0</span></strong><br />
<strong> <span style="color: #0000ff;">        mcastport: 5405</span></strong><br />
<strong> <span style="color: #0000ff;">        }</span></strong><br />
<strong> <span style="color: #0000ff;"> }</span></strong><br />
<strong> <span style="color: #0000ff;"> logging {</span></strong><br />
<strong> <span style="color: #0000ff;">    fileline: off</span></strong><br />
<strong> <span style="color: #0000ff;">    to_syslog: yes</span></strong><br />
<strong> <span style="color: #0000ff;">    to_stderr: no</span></strong><br />
<strong> <span style="color: #0000ff;">    syslog_facility: daemon</span></strong><br />
<strong> <span style="color: #0000ff;">    debug: on</span></strong><br />
<strong> <span style="color: #0000ff;">    timestamp: on</span></strong><br />
<strong> <span style="color: #0000ff;"> }</span></strong><br />
<strong> <span style="color: #0000ff;"> amf {</span></strong><br />
<strong> <span style="color: #0000ff;">    mode: disabled</span></strong><br />
<strong> <span style="color: #0000ff;"> }</span></strong></p>
<pre><strong><span style="color: #008000;"> vi /etc/corosync/service.d/pcmk</span></strong></pre>
<p><strong><span style="color: #0000ff;">service {</span></strong><br />
<strong> <span style="color: #0000ff;">    # Load the Pacemaker Cluster Resource Manager</span></strong><br />
<strong> <span style="color: #0000ff;">    name: pacemaker</span></strong><br />
<strong> <span style="color: #0000ff;">    ver: 0</span></strong><br />
<strong> <span style="color: #0000ff;"> }</span></strong></p>
<p>If you didn’t edit this on both servers copy it from second server.</p>
<pre><strong><span style="color: #008000;"> rsync -rop /etc/corosync db2:/etc</span></strong></pre>
<p>Now start corosync on both servers.</p>
<pre><strong><span style="color: #008000;"> chkconfig corosync on</span></strong>
<strong><span style="color: #008000;"> /etc/init.d/corosync start</span></strong></pre>
<p>Check CoroSync healty. Look for ‘no faluts’ and both members show up as members.</p>
<pre><strong><span style="color: #008000;"> corosync-cfgtool -s</span></strong></pre>
<p><strong>Printing ring status.</strong><br />
<strong> Local node ID -922572608</strong><br />
<strong> RING ID 0</strong><br />
<strong> id = 192.168.2.201</strong><br />
<strong> status = ring 0 active with no faults</strong></p>
<pre><strong><span style="color: #008000;"> corosync-objctl | grep members</span></strong></pre>
<p><strong>totem.join=1000 # How long to wait for join messages in the membership protocol (ms)</strong><br />
<strong> runtime.totem.pg.mrp.srp.members.-922572608.ip=r(0) ip(192.168.2.201)</strong><br />
<strong> runtime.totem.pg.mrp.srp.members.-922572608.join_count=1</strong><br />
<strong> runtime.totem.pg.mrp.srp.members.-922572608.status=joined</strong><br />
<strong> runtime.totem.pg.mrp.srp.members.-905795392.ip=r(0) ip(192.168.2.202)</strong><br />
<strong> runtime.totem.pg.mrp.srp.members.-905795392.join_count=1</strong><br />
<strong> runtime.totem.pg.mrp.srp.members.-905795392.status=joined</strong></p>
<h3></h3>
<h3>Patch for Pacemaker</h3>
<p>Yves Trudeau had created a newer version of the mysql resource agent for Pacemaker. He keeps it at:<br />
https://github.com/y-trudeau/. Just download it and copy it into the ocf resource heartbeat directory.</p>
<pre><strong><span style="color: #008000;"> wget https://raw.github.com/y-trudeau/resource-agents/master/heartbeat/mysql</span></strong>
<strong><span style="color: #008000;"> cp mysql /usr/lib/ocf/resource.d/heartbeat/mysql</span></strong></pre>
<h3></h3>
<h3>Configure Pacemaker</h3>
<p>Fencing is normally used and is enabled by default and should be! We’ll start my turning Shoot the other Node in the Head (stonith) off. TURN THIS BACK ON BEFORE YOU GO INTO PRODUCTION! You disable it with:</p>
<pre><strong><span style="color: #008000;"> crm configure property stonith-enabled="false"</span></strong></pre>
<p>If your cluster consists of just two nodes, switch the quorum feature off with:</p>
<pre><strong><span style="color: #008000;"> crm configure property no-quorum-policy=ignore</span></strong></pre>
<p>This is a bit of magic. I’ll explain after we’re done. Create file to configure crm and paste this document into it.</p>
<pre><strong><span style="color: #008000;"> crm configure node db2.grennan.com attributes IP="<span style="color: #ff0000;">192.168.2.202</span>"</span></strong></pre>
<pre><strong><span style="color: #008000;"> crm configure</span></strong></pre>
<p>Now your in the CRM configuration utility. Type in the blue part of this txt and edit the red parts to fit your configuration.</p>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">primitive failover-ip ocf:heartbeat:IPaddr \</span></strong>
<span style="color: #0000ff;"><strong> params ip="<span style="color: #ff0000;">192.168.2.200</span>" \</strong></span>
<span style="color: #0000ff;"><strong> operations $id="failover-ip-operations" \</strong></span>
<span style="color: #0000ff;"><strong> op monitor start-delay="0" interval="2"</strong></span></pre>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">primitive p_mysql ocf:heartbeat:mysql \</span></strong>
<span style="color: #0000ff;"><strong> params pid="/var/run/mysqld/mysqld.pid" socket="/data/mysql/mysql.sock" \</strong></span>
<span style="color: #0000ff;"><strong> test_passwd="<span style="color: #ff0000;">P@ssw0rd</span>" enable_creation="false" replication_user="root" \</strong></span>
<span style="color: #0000ff;"><strong> replication_passwd="<span style="color: #ff0000;">P@ssw0rd</span>" MHASupport="true" \</strong></span>
<span style="color: #0000ff;"><strong> operations $id="p_mysql-operations" \</strong></span>
<span style="color: #0000ff;"><strong> op monitor interval="20" timeout="30" depth="0" \</strong></span>
<span style="color: #0000ff;"><strong> op monitor interval="10" role="Master" timeout="30" depth="0" \</strong></span>
<span style="color: #0000ff;"><strong> op monitor interval="30" role="Slave" timeout="30" depth="0"</strong></span></pre>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">ms ms_mysql p_mysql </span></strong><span style="color: #0000ff;"><strong>meta clone-max="2" notify="true"</strong></span></pre>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">colocation col_ms_mysql_failover-ip inf: failover-ip ms_mysql:Master</span></strong></pre>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">order ord_ms_mysql_failover-ip inf: ms_mysql:promote failover-ip:start</span></strong></pre>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">commit</span></strong></pre>
<pre><strong>crm(live)configure# <span style="color: #0000ff;">quit</span></strong></pre>
<p>&nbsp;</p>
<h3>Monitor Pacemaker</h3>
<p>Back at the system prompt you can monitor the health of Pacemaker from the command line.</p>
<pre><strong><span style="color: #008000;"> crm_mon -Arf</span></strong></pre>
<p><strong>============</strong><br />
<strong> Last updated: Fri Feb 10 14:28:53 2012</strong><br />
<strong> Last change: Fri Feb 10 14:26:15 2012 via crm_attribute on db1.grennan.com</strong><br />
<strong> Stack: openais</strong><br />
<strong> Current DC: db1.grennan.com &#8211; partition with quorum</strong><br />
<strong> Version: 1.1.6-3.el6-a02c0f19a00c1eb2527ad38f146ebc0834814558</strong><br />
<strong> 2 Nodes configured, 2 expected votes</strong><br />
<strong> 3 Resources configured.</strong><br />
<strong> ============</strong></p>
<p><strong>Online: [ db1.grennan.com db2.grennan.com ]</strong></p>
<p><strong>Full list of resources:</strong></p>
<p><strong>failover-ip (ocf::heartbeat:IPaddr): Started db1.grennan.com</strong><br />
<strong> Master/Slave Set: ms_mysql [p_mysql]</strong><br />
<strong> Masters: [ db1.grennan.com ]</strong><br />
<strong> Slaves: [ db2.grennan.com ]</strong></p>
<p><strong>Node Attributes:</strong><br />
<strong> * Node db1.grennan.com:</strong><br />
<strong> + IP : 192.168.2.201</strong><br />
<strong> + master-p_mysql:0 : 3601</strong><br />
<strong> + readerOK : 1</strong><br />
<strong> + writerOK : 1</strong><br />
<strong> * Node db2.grennan.com:</strong><br />
<strong> + IP : 192.168.2.202</strong><br />
<strong> + master-p_mysql:1 : 1</strong><br />
<strong> + readerOK : 0</strong><br />
<strong> + writerOK : 0</strong></p>
<p><strong>Migration summary:</strong></p>
<p><strong>* Node db1.grennan.com:</strong><br />
<strong> * Node db2.grennan.com:</strong></p>
<h3></h3>
<h3><a href="/wp-content/uploads/2012/02/image001.png"><img class="alignright size-medium wp-image-806" title="image001" src="/wp-content/uploads/2012/02/image001-300x179.png" alt="" width="300" height="179" /></a>Install DRBD Management Console</h3>
<p>The DRBD Management Console is a Java application that eases the burden of managing your DRBD and Pacemaker/Corosync or Heartbeat based cluster systems.</p>
<p>Download this Jar file to your workstation.</p>
<p>When you run it you will need to add the server logins and cluster set. You don’t need to edit anything. Skip any installations or configurations.</p>
<p>http://sourceforge.net/projects/lcmc/files/LCMC-1.2.3.jar/download</p>
<p>[I'll post a video of configuring the Management Console here.]</p>
<p>&nbsp;</p>
<h3>But wait there is MORE</h3>
<h3>Percona Tool kit</h3>
<p>You install the Perconal Tool kit when you installed MySQL. :-) Percona Toolkit is a collection of advanced command-line tools used by Percona (<a href="http://www.percona.com/ ">http://www.percona.com/</a>) support staff to perform a variety of MySQL and system tasks that are too difficult or complex to perform manually. As a DBA you will find them very useful. Here is a small sample:</p>
<ul>
<li>pt-duplicate-key-checker &#8211; Find duplicate indexes and foreign keys on MySQL tables.</li>
<li>pt-heartbeat &#8211; Monitor MySQL replication delay.</li>
<li>pt-index-usage &#8211; Read queries from a log and analyze how they use indexes.</li>
<li>pt-query-advisor &#8211; Analyze queries and advise on possible problems.</li>
<li>pt-query-digest &#8211; Analyze query execution logs and generate a query report, filter, replay, or transform queries for MySQL, PostgreSQL, memcached, and more.</li>
<li>pt-query-profiler &#8211; Execute SQL statements and print statistics, or measure activity caused by other processes.</li>
<li>pt-show-grants &#8211; Print MySQL grants so you can effectively replicate, compare and version-control them.</li>
<li>pt-table-checksum &#8211; Perform an online replication consistency check, or checksum MySQL tables efficiently on one or many servers.</li>
<li>pt-table-sync &#8211; Synchronize MySQL table data efficiently.</li>
<li>pt-visual-explain &#8211; Format EXPLAIN output as a tree.</li>
</ul>
<h3>openark kit</h3>
<p><a href="http://code.openark.org/blog/shlomi-noach">Shlomi Noach</a> maintains another great set of utility.</p>
<ul>
<li>oak-apply-ri: apply referential integrity on two columns with parent-child relationship.</li>
<li>oak-block-account: block or release MySQL users accounts, disabling them or enabling them to login.</li>
<li>oak-chunk-update: perform long, non-blocking UPDATE/DELETE operation in auto managed small chunks.</li>
<li>oak-get-slave-lag: print slave replication lag and terminate with respective exit code.</li>
<li>oak-hook-general-log: hook up and filter general log entries based on entry type or execution plan criteria.</li>
<li>oak-kill-slow-queries: terminate long running queries.</li>
<li>oak-modify-charset: change the character set (and collation) of a textual column.</li>
<li>oak-online-alter-table: perform a non-blocking ALTER TABLE operation.</li>
<li>oak-prepare-shutdown: make for a fast and safe MySQL shutdown.</li>
<li>oak-purge-master-logs: purge master logs, depending on the state of replicating slaves.</li>
<li>oak-repeat-query: repeat query execution until some condition holds.</li>
<li>oak-security-audit: audit accounts, passwords, privileges and other security settings.</li>
<li>oak-show-limits: show AUTO_INCREMENT “free space”.</li>
<li>oak-show-replication-status: show how far behind are replicating slaves on a given master.</li>
</ul>
<p>You can find them here. <a href="http://code.openark.org/forge/openark-kit">http://code.openark.org/forge/openark-kit</a></p>
<h3>MyTOP</h3>
<p>Mytop is a console-based (non-gui) tool for monitoring the threads and overall performance of MySQL. The original development was done by Jeremy D. Zawodny &lt;Jeremy@Zawodny.com&gt; and is well know after being published in the book, High Performance MySQL. I’ve updated it with as a tool for monitoring MyISAM and replication.</p>
<p>I would be amiss if I didn&#8217;t say something about innotop. Some consider this a  successors to mytop. It is if you are using InnoDB. I still find mytop useful. More than half of my tables are MyISAM.</p>
<pre><strong><span style="color: #008000;"> wget http://www.mysqlfanboy.com/mytop/mytop-1.9.tar.gz</span></strong>
<strong><span style="color: #008000;"> tar zxf mytop-1.9.tar.gz</span></strong>
<strong><span style="color: #008000;"> cd mytop-1.9</span></strong>
<strong><span style="color: #008000;"> perl Makefile.PL</span></strong>
<strong><span style="color: #008000;"> make install</span></strong></pre>
<pre><strong><span style="color: #008000;"> wget https://innotop.googlecode.com/files/innotop-1.8.0.tar.gz</span></strong>
<strong><span style="color: #008000;"> cd innotop-1.8.0</span></strong>
<strong><span style="color: #008000;"> perl Makefile.PL</span></strong>
<strong><span style="color: #008000;"> make install</span></strong></pre>
<h3>Backup</h3>
<p>Percona XtraBackup is a hot backup utility that doesn’t lock your database during the backup!</p>
<p>It’s best to run this from one of your slaves. I often create a local copy and then rsync the files off the backup system to a remote (off site) server using a cron script.</p>
<pre><strong><span style="color: #008000;"> yum -y install xtrabackup</span></strong></pre>
<pre><strong><span style="color: #008000;"> innobackupex --user=root --password=`<span style="color: #ff0000;">P@ssw0rd</span>` /tmp/Backup</span></strong></pre>
<p>Here is an example script.</p>
<p>export HOST=`/bin/hostname -a`<br />
mkdir /root/Backup<br />
/usr/bin/innobackupex &#8211;user=root &#8211;password=`P@ssword` /root/Backup<br />
/usr/bin/xtrabackup &#8211;prepare &#8211;target-dir=/tmp/backup<br />
/bin/find /tmp/Backup/* -mtime +1 -exec rm {} -Rf \;</p>
<h3>Last word</h3>
<p>If you’ve made it this fare, now is a good time to restart everything and do some testing.</p>
<pre><strong><span style="color: #008000;"> init 6</span></strong></pre>
<p>&nbsp;</p>
<p><img class="Left" src="http://mark.grennan.com/images/MarkGrennanSigniture.bmp" alt="" width="166" height="69" /></p>
<p><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.mysqlfanboy.com%2F2012%2F02%2Fthe-full-monty-version-2-3%2F&amp;count=none&amp;via=MySQLFanBoy&amp;related=MySQLFanBoy:Site+Twitter+account&amp;text=The Full Monty - Version 2 - MySQL Fanboy" class="twitter-share-button">Tweet</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlfanboy.com/2012/02/the-full-monty-version-2-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>What can I DROP?</title>
		<link>http://www.mysqlfanboy.com/2011/09/what-can-i-drop/</link>
		<comments>http://www.mysqlfanboy.com/2011/09/what-can-i-drop/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 17:35:52 +0000</pubDate>
		<dc:creator><![CDATA[Mark Grennan]]></dc:creator>
				<category><![CDATA[HOW TO]]></category>

		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=675</guid>
		<description><![CDATA[So you have inherited a MySQL server and no one know what applications are use what databases.   Space is every tight and every night transactions logs almost fill your hard disk.  The server was once used as a replication server and it seems every database the company uses is duplicated here. You could do [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>So you have inherited a MySQL server and no one know what applications are use what databases.   Space is every tight and every night transactions logs almost fill your hard disk.  The server was once used as a replication server and it seems every database the company uses is duplicated here.</p>
<p>You could do a full dump, drop everything and wait for the requests to restore. (This might be OK on a test database.)</p>
<p>We could ask MySQL for all the databases that have tables that have been updated in the last 30 days.</p>
<pre>$ mysql information_schema -e  \
"select DISTINCT TABLE_SCHEMA as NAME from TABLES
  WHERE UPDATE_TIME IS NOT NULL and UPDATE_TIME &gt; NOW() - INTERVAL 30 DAY"  \
&gt; Databases</pre>
<p>But this only gives a list of databases that have changed.  What about tables that are only read from?</p>
<p>Bin-Logs don&#8217;t help because they too only have updates.  What we really need is a long snapshot of the general log. But, starting the general log will just fill your disk space even more.</p>
<p>As long as all queries are remote we can use tcpdump.</p>
<p>Filter all the MySQL connections for  &#8216;FROM tablenames&#8217;.</p>
<pre>$ tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings | \
 sed -n 's/\(.*\)\(from.*\)/\2/p' | awk '{print $2}' &gt; TableList
 $ cat TableList | sort | uniq &gt; ShortList</pre>
<p>Some of the queries may reference databases.tablename so we can filter out the database names and add them to your Database list.</p>
<pre>$ cat TableList | sed -n 's/\./ /p' | awk '{print $1}' | sort | uniq &gt;&gt; Databases</pre>
<p>Now for the queries that only use table names. We need to find the database each belongs to.  This isn&#8217;t completely accurate because the table name may be in more then one databases.</p>
<pre>$  for x in `cat TableList | sort | uniq` ;
 do
 mysql information_schema -e "select TABLE_SCHEMA from TABLES where TABLE_NAME='$x'\G"  \
 | grep TABLE | awk '{print $2}' ;
 done | sort | uniq &gt;&gt; Databases</pre>
<p>To create the final list of database that should not be dropped.</p>
<pre>$ sort Databases | uniq &gt; KEEPTHESE ; cat KEEPTHESE</pre>
<p>Now you can do the deed with some confidence your not removing anything being used.</p>
<p>&nbsp;</p>
<p><img class="alignleft" src="http://mark.grennan.com/images/MarkGrennanSigniture.bmp" alt="" width="166" height="69" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P.S.  Did I tell you, Never do anything you can&#8217;t reverse.   Make a BACKUP FIRST!</p>
<p><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.mysqlfanboy.com%2F2011%2F09%2Fwhat-can-i-drop%2F&amp;count=none&amp;via=MySQLFanBoy&amp;related=MySQLFanBoy:Site+Twitter+account&amp;text=What can I DROP? - MySQL Fanboy" class="twitter-share-button">Tweet</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlfanboy.com/2011/09/what-can-i-drop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PostGIS 1.5 in Postgresql 9.0 install on CentOS 5.6</title>
		<link>http://www.mysqlfanboy.com/2011/07/postgis-1-5-in-postgresql-9-0-install-on-centos-5-6/</link>
		<comments>http://www.mysqlfanboy.com/2011/07/postgis-1-5-in-postgresql-9-0-install-on-centos-5-6/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 19:33:25 +0000</pubDate>
		<dc:creator><![CDATA[Mark Grennan]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[HOW TO]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[Postgresql]]></category>

		<guid isPermaLink="false">http://www.mysqlfanboy.com/?p=621</guid>
		<description><![CDATA[I love short and consist install instructions. I know this is a MySQL blog but our good friend PostGreSQL has a great GIS library. This is what I learned upgrading our PostGIS system to GIS 1.5. Much thanks to Jeremy Tunnell for give this document it’s start. Start with CentOS 5.6 x86_64 basic install. Add [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I love short and consist install instructions. I know this is a MySQL blog but our good friend PostGreSQL has a great GIS library. This is what I learned upgrading our PostGIS system to GIS 1.5. Much thanks to Jeremy Tunnell for give this document it’s start.</p>
<p>Start with CentOS 5.6 x86_64 basic install.</p>
<p>Add the PostgreSQL Yum repository to your system.</p>
<pre> $ wget http://yum.pgrpms.org/reporpms/9.0/pgdg-centos-9.0-2.noarch.rpm
 $ rpm -i pgdg-centos-9.0-2.noarch.rpm</pre>
<p>Another location for these is DAG. I have to tried these so your results may very.</p>
<p>You will need to exclude the packages CentOS provide by added two lines to the BASE and UPDATE sections of /etc/yum.repos.d/CentOS-Base.repo. They are:</p>
<pre>exclude=postgresql*
exclude=geos*</pre>
<p>You you are ready to install the needed packages. This includes proj version 4 and geos version 3.</p>
<pre> $ yum install postgresql90-contrib.x86_64
 $ yum install postgis90.x86_64
 $ yum install postgresql90-server
 $ yum install proj
 $ yum install geos
 $ yum install php-pear
 $ yum install php-devel</pre>
<h3>GEOS</h3>
<p>There may be some dependencies you will have to work through. If you are using PDO and haven’t installed the pgsql PDO drivers, you can do it now:</p>
<pre> $ pecl install pdo_pgsql</pre>
<h3>PL/pgSQL</h3>
<p>You you are ready to initialize the database files and start postgresql.</p>
<pre> $ service postgresql-9.0 initdb
 $ service postgresql-9.0 start</pre>
<p>Now you can change to the postgres user and begin installing the functions for GIS. You have to start with defining the language.</p>
<pre> $ su – postgres
 $ psql
 # create language plpgsql ;
 # \q</pre>
<p>Now you can create your database and add the GIS functions calls to it.</p>
<pre> $ createdb geos
 $ psql -d geos -f /usr/pgsql-9.0/share/contrib/postgis-1.5/postgis.sql
 $ psql -d geos -f /usr/pgsql-9.0/share/contrib/postgis-1.5/spatial_ref_sys.sql</pre>
<p>You you can verify the install.</p>
<pre> $ psql geos
 # select postgis_full_version();
                                              postgis_full_version
——————————————————————————————————–
 POSTGIS=”1.5.2″ GEOS=”3.2.2-CAPI-1.6.2″ PROJ=”Rel. 4.7.1, 23 September 2009″ LIBXML=”2.6.26″ USE_STATS
(1 row)</pre>
<p>For more on using PostGIS check out Jeremy’s “PostGIS part 2”.</p>
<p><img src="http://mark.grennan.com/images/MarkGrennanSigniture.bmp" alt="" width="166" height="69" />.</p>
<p><a href="http://twitter.com/share?url=http%3A%2F%2Fwww.mysqlfanboy.com%2F2011%2F07%2Fpostgis-1-5-in-postgresql-9-0-install-on-centos-5-6%2F&amp;count=none&amp;via=MySQLFanBoy&amp;related=MySQLFanBoy:Site+Twitter+account&amp;text=PostGIS 1.5 in Postgresql 9.0 install on CentOS 5.6 - MySQL Fanboy" class="twitter-share-button">Tweet</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlfanboy.com/2011/07/postgis-1-5-in-postgresql-9-0-install-on-centos-5-6/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
