The following 10 open source tools are valuable resources for anyone using MySQL, from a stand-alone instance to a multiple-node environment. The list has been compiled with variety in mind. You will find tools to help back up MySQL data, increase performance, guard against data drift, and log pertinent troubleshooting data when problems arise.
There are several reasons why you should consider these tools instead of creating your own in-house tools. First, thanks to their wide use, they're mature and field-tested. Second, because they are free and open source, they benefit from the knowledge and experience of the continually expanding MySQL community. Finally, these tools are actively developed, and many are professionally supported (either for free or commercially), so they continue to improve and adapt with the evolving MySQL industry.
Keep in mind that there are many more tools worthy of your attention. I have chosen to emphasize free and open source, and to err on the side of usefulness and usability. Also note that all are Unix command-line programs but one, in large part because MySQL is more widely deployed and developed on Unix systems.
Now, let's meet the first of the 10 essential MySQL tools.
Essential MySQL tool No. 1: mk-query-digest
mk-query-digest can help you find the queries that take the longest time to execute as compared to other queries. Optimizing these slow queries will make MySQL run faster by reducing the greatest delays. The real art of query optimization is more nuanced, but the basic goal is the same: find slow queries, optimize them, and increase query response times.
The tool is easy to use; executing mk-query-digest slow-query.log will print the slowest queries in slow-query.log. The tool includes support for "query reviews," for reporting queries you have not yet seen or approved, making frequent log analyses quick and efficient.
Download: http://maatkit.org/get/mk-query-digest
Essential MySQL tool No. 2: mydumper
Essential MySQL tool No. 3: xtrabackup and xtrabackup-manager
More info: http://www.percona.com/docs/wiki/percona-xtrabackup:start| https://launchpad.net/percona-xtrabackup Download: http://code.google.com/p/xtrabackup-manager/
Essential MySQL tool No. 4: tcprstat
Download: (source)https://launchpad.net/tcprstat | (binary) http://www.percona.com/docs/wiki/tcprstat:start
Essential MySQL tool No. 5: mk-table-checksum
mk-table-checksum works with both stand-alone servers and servers in a replication hierarchy, where the tool's greatest value is easily seen. Verifying table data between a master and a slave must account for replication consistency. Because changes to the master are replicating to slaves with some amount of time delay ("lag"), simply reading data from the servers is an unreliable way to verify consistency, given that the data is constantly changing and incomplete until fully replicated. Locking tables and waiting for all data to replicate would allow consistent reads, but to do so would mean effectively halting the servers. mk-table-checksum allows you to perform nonblocking, consistent checksums of master and slave data. (For technical details on how this is accomplished, see thetool's documentation.)
Apart from replication consistency, there are other problems with verifying data. Table size is one of them. The MySQL command CHECKSUM TABLE is sufficient for small tables, but large tables require "chunking" to avoid long locks or overloading CPU or memory resources with checksum calculations.
Chunking solves a second problem: the need for regular data-consistency checks. While data drift can be a one-time occurrence, often it is recurring. mk-table-checksum is designed to continuously check tables, vetting certain chunks one run and other chunks the next run until eventually the whole table has been checked. The ongoing nature of this process helps ensure that recurring drift is corrected.
Download: http://maatkit.org/get/mk-table-checksum
Essential MySQL tool No. 6: stalk and collect
Firstly, stalk runs collect in configurable intervals, keeping you from logging too much redundant data, which can obfuscate postproblem analysis. Secondly, collect gathers not only the standard information that MySQL can report about itself but a lot more data that you might not have thought to include: lsof, strace, tcpdump, and so on. Thus, if you end up having to consult with a professional who specializes in fixing MySQL problems, you will have all the data that they need.
stalk and collect are configurable, so they can be used for almost any problem. The one requirement is a definable condition to establish a trigger for stalk. If multiple conditions signal the problem, then you may also need to consult with a professional for a more extensive review of your MySQL environment because problems can appear in MySQL even though the underlying cause is elsewhere.
stalk and collect can be used proactively, too. For example, if you know that there should never be more than 50 active MySQL connections at a time, then you could proactively monitor this stalk, making these tools helpful both for problems that you know and problems that you have not yet seen.
Download: http://aspersa.googlecode.com/svn/trunk/stalk | http://aspersa.googlecode.com/svn/trunk/collect
Essential MySQL tool No. 7: mycheckpoint
More info: http://code.openark.org/forge/mycheckpoint
Essential MySQL tool No. 8: shard-query
SELECT DayOfWeek, COUNT(*) AS cFROM ontime_factJOIN dim_date USING(date_id)WHERE YearBETWEEN 2000 AND 2008GROUP BY DayOfWeekORDER BY c DESC;
Maintainer: Justin Swanhart
More info: http://code.google.com/p/shard-query/
Essential MySQL tool No. 9: mk-archiver
More info: http://maatkit.org/ | http://code.google.com/p/maatkit/
Essential MySQL tool No. 10: oak-security-audit
-- Looking for anonymous user accounts-- ------------------------------------- Passed---- Looking for accounts accessible from any host-- ----------------------------------------------- Found 1 accounts accessible from any host. Recommended actions:RENAME USER 'msandbox'@'%' TO 'msandbox'@'<specific host>';