10 Essential MySQL Tools for Admins

The MySQL community is a hotbed of free, open source tools to enhance the performance and health of your MySQL systems

1 2 Page 2
Page 2 of 2

Thankfully, those who specialize in knowing when MySQL is not working, and in fixing the problems, have written a duo of tools called stalk and collect. The first tool waits for certain conditions to become true before running an instance of the second tool. That seems trivial, but these tools are made efficient by certain details addressed.

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/collectMaintainer: Baron SchwartzMore info: http://aspersa.googlecode.com/svn/html/index.html | http://code.google.com/p/aspersa/

Essential MySQL tool No. 7: mycheckpointYou don't always want to wait for something to go wrong before addressing a problem, and dashboards provide an essential way for you to monitor your MySQL environment for potential problems before they arise.

There are many free and commercial monitoring applications for MySQL, some MySQL-specific and others generic with MySQL plug-ins or templates. mycheckpoint is notable because it is free, open source, MySQL-specific, and full-featured.

Like many monitoring solutions, mycheckpoint is Web-based. Here's an example chart:

mycheckpoint can be configured to monitor both MySQL and server metrics, like InnoDB buffer pool flushes, temporary tables created, operating system load, memory usage, and more. If you don't like charts, mycheckpoint can also generate human-readable reports.

As with stalk, alert conditions can be defined with email notifications, but no secondary tool like collect will be run to log additional troubleshooting data. Another useful feature is mycheckpoint's ability to monitor MySQL variables to detect changes that can lead to problems, or signal that someone has modified MySQL when they shouldn't have.

Monitoring MySQL isn't just for data centers or large deployments. Even if you have a single MySQL server, monitoring is essential; as with your vehicle, there's a lot to know about the system while it's running to help you foresee or avoid malfunctions. mycheckpoint is one solution among many worth trying.

Download: http://code.google.com/p/mycheckpoint/downloads/listMaintainer: Shlomi NoachMore info: http://code.openark.org/forge/mycheckpoint

Essential MySQL tool No. 8: shard-queryQueries against partitioned or sharded data sets can be accelerated dramatically using shard-query, which parallelizes certain queries behind the scenes. Queries that use the following constructs can benefit from shard-query's parallel execution:

Aggregate functions SUM, COUNT, MIN, and MAX can be used with those constructs, too. For example, this query can be executed in parallel by shard-query:

Benchmarks show that parallelizing that query reduces its response time by roughly 85 percent, from 21 seconds to 3.

shard-query is not a stand-alone tool; it requires other programs like Gearman, and it's relatively complex to set up. But if your data is partitioned and your queries use any of the constructs listed above, then the benefits are worth the effort.

Download: (svn checkout) http://code.google.com/p/shard-query/source/checkoutMaintainer: Justin SwanhartMore info: http://code.google.com/p/shard-query/

Essential MySQL tool No. 9: mk-archiverAs tables become larger, queries against them can become slower. Many factors influence response times, but if you have optimized everything else and the only remaining suspect is a very large table, then archiving rows from that table can restore fast query-response times.

Unless the table is unimportant, you should not brazenly delete rows. Archiving requires finesse to ensure that data is not lost, that the table isn't excessively locked, and that the archiving process does not overload MySQL or the sever. The goal is an archiving process that is reliable and unnoticeable except for the beneficial effect of reducing query times. mk-archiver achieves all this.

mk-archiver has two fundamental requirements, the first of which is that archivable rows must be identifiable. For example, if the table has a date column and you know that only the last N years of data are needed, then rows with dates older than N years ago can be archived. Moreover, a unique index must exist to help mk-archiver identify archivable rows without scanning the entire table. Scanning a large table is costly, so an index and specific SELECT statements are used to avoid table scans.

In practice, mk-archiver automatically handles the technical details. All you have to do is tell it what table to archive, how to identify archivable rows, and where to archive those rows. These rows can be purged, copied to another table, or written to a dump file for future restoration if needed. Once you're comfortable with the tool, there are many options to fine-tune the archiving process. Also, mk-archiver is pluggable, so it can be used to solve complex archiving needs without patching the code.

Download: http://maatkit.org/get/mk-archiverMaintainers: Daniel Nichter and Baron SchwartzMore info: http://maatkit.org/ | http://code.google.com/p/maatkit/

Essential MySQL tool No. 10: oak-security-auditWhen was the last time you audited the security of your MySQL servers? You're not alone if "never" is the answer. There are many companies that provide security audits, but unless nothing ever changes after those audits, then the security of your MySQL environment should be checked regularly.

External threats are one obvious reason to enforce MySQL security, but internal threats like current or former employees are often more dangerous because they are (or were) trusted. Security is also important for enforcing privacy (medical/HIPAA regulations), preventing accidental access (for example, logging into the production server instead of the development server), or enabling third-party programs to interact with your systems.

For those looking to increase the security of their deployments, oak-security-audit is a worthwhile, free, open source tool that performs basic MySQL security audits. It doesn't require any setup; just run it against your MySQL servers, and it prints a report with risks and recommendations about accounts, account privileges, passwords, and some general best practices, like disabling network access. Here's a snippet of a report:

oak-security-audit focuses just on MySQL security, so it's not a replacement for a full system security audit by a human, but it's a great first line of defense that is easy to use. You could run it weekly with cron and have the reports emailed to you.

Download: http://openarkkit.googlecode.com/svn/trunk/openarkkit/src/oak/oak-security-audit.pyMaintainer: Shlomi NoachMore info: http://openarkkit.googlecode.com/svn/trunk/openarkkit/doc/html/oak-security-audit.html

This article, "10 essential MySQL tools for admins," originally appeared at InfoWorld.com. Follow the latest news in programming and open source at InfoWorld.com. For the latest business technology news, follow InfoWorld.com on Twitter.

Read more about data management in InfoWorld's Data Management Channel.

This story, "10 Essential MySQL Tools for Admins" was originally published by InfoWorld.

Copyright © 2011 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2
Survey says! Share your insights in our 19th annual State of the CIO study