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.
Maintainer: Baron Schwartz
You 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.
Maintainer: Shlomi Noach
More info: http://code.openark.org/forge/mycheckpoint Essential MySQL tool No. 8: shard-query
Queries 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:
- Subqueries in the FROM clause
- UNION and UNION ALL
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:
SELECT DayOfWeek, COUNT(*) AS c
FROM ontime_factJOIN dim_date USING(date_id)
WHERE YearBETWEEN 2000 AND 2008
GROUP BY DayOfWeekORDER BY c DESC;
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/checkout
Maintainer: Justin Swanhart
More info: http://code.google.com/p/shard-query/ Essential MySQL tool No. 9: mk-archiver
As 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.
Maintainers: Daniel Nichter and Baron Schwartz
When 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:
-- 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>';
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.
Maintainer: Shlomi Noach
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.