<?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>Hack Admin &#187; mysqlcheck</title>
	<atom:link href="http://www.hackadmin.com/tag/mysqlcheck/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hackadmin.com</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 21:31:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Beauty of mysqlcheck</title>
		<link>http://www.hackadmin.com/2009/06/22/the-beauty-of-mysqlcheck/</link>
		<comments>http://www.hackadmin.com/2009/06/22/the-beauty-of-mysqlcheck/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 23:45:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Repair]]></category>
		<category><![CDATA[checking all mysql tables in a database]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[mysqlcheck]]></category>
		<category><![CDATA[Replication]]></category>
		<category><![CDATA[slave]]></category>

		<guid isPermaLink="false">http://www.hackadmin.com/?p=37</guid>
		<description><![CDATA[I manage a ton of mysql databases, from single wordpress instances, to clusters, to systems that have a core data structure that selectively replicates out to as many as 50 systems.   Fortunately, or maybe not, they seldom have issues and after setup, other than disk space issues, I seldom have to touch them.
Recently, as I [...]]]></description>
			<content:encoded><![CDATA[<p>I manage a ton of mysql databases, from single wordpress instances, to clusters, to systems that have a core data structure that selectively replicates out to as many as 50 systems.   Fortunately, or maybe not, they seldom have issues and after setup, other than disk space issues, I seldom have to touch them.</p>
<p>Recently, as I was migrating a set of DBs from an aquired company onto new hardware in a new location, I ran across a DB that seemed to consistently become corrupt.  It was usually the larger tables and typically on the slave system.  At first, it was bad enough that I blamed the hardware.  So the box was replaced and things went well for a while.  Recently the head developer for this system came to me with corrupted tables.  He was seeing the output in his code and was feeding me the tables so that I could repair them.  We did them one by one and it became clear that I really needed to check the whole DB.</p>
<p><span id="more-37"></span>It would have been relatively simple to throw together a script to do this, but I was apparenlty feeling lazy and did a google search instead.  Low an behold, I ran across a utility that I have read about countless times in the past, and I&#8217;m sure at some point I had actually run.   mysqlcheck.  I believe this nice little script has been packaged with mysql since the late 3.x strains.</p>
<p>At any rate, I think I&#8217;m documenting it here so that I won&#8217;t forget 6 months from now when I need the same functionality again.</p>
<p>So, on the system in question, I had about 20 instances and only one of them needed to be checked.  This is a big deal as the check script, or the repair command, or the optimize command will lock up your tables when it does it&#8217;s work and there were 19 web/data instances running on this box that I didn&#8217;t want to bother.  The check script is smart enough to handle this situation with the &#8211;databases flag.  Simply add the names of the instances that you want the check after that flag and you&#8217;re off.</p>
<p>Obviously, you want to do your best to stop traffic to the instances you intend to repair.  Can you get away with not doing this?  Well sure, remember however that the check, repair and optimize functions will lock up the tables in question when they do their work.  What does this mean?  Well, it means that none of your inbound querys will be run, they will queue up behind the repair functions until those functions finish.  In a really bad scenario, it&#8217;s possible that each of your querys will be bound to an apache instance and your web server will start eating up memory and potentially crash the whole box.  Thus, it&#8217;s in your best interest to stop as much traffic as possible before you start.</p>
<p>In my case, the usage of mysqlcheck looked like this:</p>
<p>mysqlcheck -uroot -pxxxxx &#8211;auto-repair &#8211;optimize &#8211;databases broken_db</p>
<p>The output is fantastic, it tells you where it&#8217;s at and what is broken or ok.  If you don&#8217;t want to see the output, if you intend to run from cron or whatever, there is a &#8211;silent option as well.</p>
<p>At any rate, leave it to mysql to simplify your admin a bit.  Run the mysqlcheck without any options and you&#8217;ll see all the options.  Takes 5 minutes to read through them.</p>
<p>That&#8217;s it, happy mysql&#8217;ing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hackadmin.com/2009/06/22/the-beauty-of-mysqlcheck/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
