Reptile is an easy to use utility that will monitor your MySQL replication, so you can forget about it and focus on the good stuff. It provides a utility for generate replication reports, and can email if replication appears to be failing.
I’m not sure if anybody uses this. I PROBABLY WON’T fix a patch you submit. This, as it is, has been used successfully in production environments. It’s a good idea, but might not work for your particular case, and I make no guarantee that it will. I certainly hope it does. Drop me a line, and I’ll answer any questions you have. NCS 8/2010
A mysql replication setup.
Put a config file at /etc/reptile.yml, /etc/reptile/reptile.yml, ./reptile.yml, or specify one on the command line.
[nick@s34 ~]$ replication_status -h Usage: replication_status [path_to_config_file] -h, --help Displays this help info -s, --status Displays the slave status -d, --diff Checks the row count difference between master and slave -r, --report Sends a report email -b, --heartbeat Checks the heartbeat timestamp difference between master and slave [nick@s34 ~]$ replication_status -s * a_database slave is up and running * b_database slave is up and running * c_database slave is up and running
[nick@s34 ~]$ sudo crontab -l Password: MAILTO="user@example.com" # Use the '-e' arg to only spit out errors, which will be sent out by crontab */15 * * * * replication_status -e
Run this SQL to setup the DBs/perms for Reptile. Using different users, since each user requires significantly different permissions.
GRANT REPLICATION SLAVE, REPLICATION CLIENT, SUPER ON *.* TO 'repl'@"localhost" IDENTIFIED BY 'repl_user_pass'; GRANT REPLICATION SLAVE, REPLICATION CLIENT, SUPER ON *.* TO 'repl'@"MONITOR_HOST_IP" IDENTIFIED BY 'repl_user_pass'; GRANT SELECT, REPLICATION CLIENT ON *.* TO 'ro_user'@"localhost" IDENTIFIED BY 'ro_user_pass'; GRANT SELECT, REPLICATION CLIENT ON *.* TO 'ro_user'@"MONITOR_HOST_IP" IDENTIFIED BY 'ro_user_pass'; CREATE DATABASE replication_monitor; GRANT SELECT, INSERT, UPDATE, ALTER ON replication_monitor.* TO 'heartbeat_user'@"localhost" IDENTIFIED BY 'heartbeat_user_pass'; GRANT SELECT, INSERT, UPDATE, ALTER ON replication_monitor.* TO 'heartbeat_user'@"MONITOR_HOST_IP" IDENTIFIED BY 'heartbeat_user_pass'; CREATE TABLE replication_monitor.heartbeats ( unix_time INTEGER NOT NULL, db_time TIMESTAMP NOT NULL, INDEX time_idx(unix_time) )
sudo gem install reptile
(The MIT License)
Copyright © 2009 Nick Stielau
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.