wiki:MySQLMonk

MySQL Monk

MySQL Monk is an easy to use MySQL replication monitor, which can detect situations where your server replication is lagging beyond normal operation parameters (or is just not working).
When something goes wrong or turns okay after it has been wrong, you will receive a email notification.

See the How MySQL Monk works page if you want to learn how it works.

Download

MySQL Monk 0.90

Installation and configuration

The following instructions are for Linux servers.

Installation

extract MySQL Monk to your preferred directory. this will extract it into /usr/local/mysqlmonk :

tar xzf mysqlmonk-VERSION.tar.gz -C /usr/local

Create symlinks to /etc/init.d:

ln -s /usr/local/mysqlmonk/mysqlmonk /etc/init.d/mysqlmonk

Copy the sample configuration file conf/sample-monk.conf to conf/monk.conf, and edit it to suite your needs (more on this in the configuration section below). to start/stop/restart MySQLConf, use the symlink :

root@server:~# /etc/init.d/mysqlmonk
Usage: /etc/init.d/mysqlmonk { console | start | stop | restart | condrestart | status | dump }

Log files are normally stored in /var/log/mysql-monk.log, you can change it by editing conf/log4j.xml.

Configuration

For a quick start, copy the conf/sample-monk.conf file to monk.conf, and edit it.
The default sample files defines a master master configuration, where SERVER_1 is the master of SERVER_2 and vice versa. A single monk.conf can describe any replication configuration possible, simple configure your own servers.

you can always use host_port, but in most cases just the host will suffice.
A server configuration:

  • host : The mysql server host name
  • port : The mysql server port number, default is 3306, which should be good enough for most mysql servers.
  • db_name : The database name, this database have to be replicated for the replication monitoring to work. the table mysql_monk will be created in this database.
  • username : User name to use. this use should have privileges to create a table, and to select and update data.
  • password : The .. password.
  • master : An optional master field, if this server is the slave of another server, the other server id should appear here. A Server ID is the server host (if there is only a single MySQL server on that host), or host_port, if there are more than one.

The monitoring options section defines how often the servers are updated, how often they are checked and what is the permitted lag time (all in seconds).

The event handler section defines what to do when something bad or good happens. The Email handler will simply send an email to the specified recipients. it should be quite easy to add additional handlers (send an SMS? take a recovery action?) by implementing the EventHandler interface.

@swush 1.0

mysql_monk
{
	# Master master configuration:
	# the following block defines two server, each is the master of the other one (master-master)
	server
	{
		host : SERVER_1				# Server host name 
		port : 3306				# Server port, default is 3306
		db_name : replicated_db			# Database name, should be a replicated database. the mysql_monk table will be installed into this database
		username : user				# mysql user name
		password : pass				# mysql password
		
		master : SERVER_2			# Optional master server ID, host or host_port (in case the host is not unique).
	}
	
	server
	{
		host : SERVER_2
		port : 3306
		db_name : replicated_db
		username : user
		password : pass
		
		master : SERVER_1
	}
	
	
	# Monitoring options
	monitor
	{
		# update master timestamps every X seconds
		update_interval : 1
		
		# check slave lag every X seconds
		check_interval : 5
		
		# max alloed lag in seconds for slave replication before raising an alert
		max_allowed_lag : 10
	}
	
	# Event handlers.
	# Gets notified when lag begin, ends and when an error condition begin and end.
	handlers
	{
		# Email handler.
		# Implementing other handlers should be trivial.
		handler
		{
			# Handler class name, should implement net.firefang.mysqlmonk.EventHandler
			class : net.firefang.mysqlmonk.email.EmailHandler
			
			# from address in sent emails
			from : mysqlmonk@elvis.face.com
			
			# smtp host to send emails through, default is localhost
			smtp_host : localhost
			
			# change to true to debug smtp sending
			#smtd_debug : false
			
			# recepients array
			recepients
			{
				rcpt1@server.com
				rcpt2@server.com
				rcpt3@server.com
			}
		}
	}
}

License

MySQL Monk is released under the BSD License

Building from source

Checkout from http://svn.firefang.net/trunk/mysql_monk.
MySQL Monk can be built using EBuild (EBuild is an ant based generic build system for Java projects developed in Eclipse), Please follow the instructions there.

Once you have ebuild checked out and configured, just run ant to build MySQL Monk.

Last modified 8 years ago Last modified on Aug 12, 2009, 8:15:06 PM