mylbhelper


What

While it can act solely as a monitoring daemon - the primary use for this software I suppose is to help dumb load balancers do their job.

Relatively few load balancers out there do MySQL natively, so if you use what's at hand and end up with a device that doesn't, you have to set up a generic TCP cluster with little or no chance of determining the health of a server unless it crashes completely (stops listening on the port you've specified). Here's where mylbhelper comes in handy.
It sits as a forked daemon, continuously probing MySQL with a configurable prefedined query. If mylbhelper at any point detects a problem, it launches a predefined script. It then continues to monitor MySQL, and runs another script when the query return successfully. You can of course write your own scripts and make them do whatever you wish; simply alert you, take the server out of a pool, change the machine's IP etc.

It helps you in situations where max_clients is reached, tables have become corrupt, filesystem permissions are broken, a tired developer accidentally dropped that mission critical table, etc. Basically anything that can result in a query failing but doesn't stop MySQL from responding to network traffic. You can use the scripts to firewall the port you've set the cluster to work on - which will have even the dumbest of load balancers cease sending traffic to it. This is what the default scripts do.

In the event of change of status, mylbhelper also writes a message to syslog. It writes to daemon.crit when it has detected a problem, and daemon.notice when it comes back up. In order to prevent flapping, if the current state is down, it takes two successful runs for mylbhelper to consider MySQL healthy again.

Get

mylbhelper-0.8.tar.bz2
mylbhelper-0.8.tar.gz

How

Usual procedure, run './configure' followed by 'make' to build the binary followed by 'make install'. Make sure you have the mysql_config binary in your $PATH, or specify its location with supplying the --with-mysql_config=PATH option to configure. You can also do this to link the mylbhelper binary against a specific version of MySQL.

You will also need to edit extras/mylbhelper.conf.sample to your liking and rename it to /etc/mylbhelper.conf or start mylbhelper with the -c flag followed by the path to the file you wish to use. For mylbhelper to be of any use to you what so ever, you'll need to write two scripts or modify the supplied ones in extras/ and put them in the path you've specified in the config file. These scripts are - as the names imply - executed when mylbhelper detects a problem with the MySQL server, and when it considers it healthy again following an outage. Note that the scripts are executed in a blocking manner!

There's also a standard (start, stop, restart, status) init script in extras/mylbhelper.init which you may want to use.

Contact

Feedback, suggestions, bug reports etc. are welcomed at erik[at]ibiblio.org

Thanks

Gareth Llewllyn gareth[at]networksaremadeofstring.co.uk: Bug hunting, testing
DediPower Managed Hosting OSLABS: Project hosting


Copyright 2008 Erik Ljungstrom