a basic HA daemon - how it works
i posted about the HA daemon earlier and wrote one now. this is how it works and what it does ... it is pretty basic but it does the job and if i have some time i'll grow it to a nice one.
the basic architecture
#cat checks.conf [local] check_db_host1 chech_db_host2
this defines a scope (local) and checks that should be run in this scope. currently it supports only local checks, remote checks could be implemented via ssh or via a daemon running those hosts.
#cat actions.conf [slave_to_master] stopservice1 unplumb plumb %MASTER% startservice1
this defines state changes. if the daemon sees a change for the host it monitors and the status has been "slave" before and now is "master" then these commands run in a fork. there are variables in the config file to indicate arguments like %MASTER% and %SLAVE% that get expanded to the according hostnames during runtime.
the daemon is based on the Net::Server framework that is the best framework for perl based daemons i ever worked with and that has proven to be reliable in high traffic environments during the last years already. i decided to maintain a internal basic hash table in a file based database to synchronize forks, this could move to a shared memory based solution but performance is not so much an issue in this setup so i decided that a file is good enough.
the checks are simple perl scripts that get called from a fork of the main daemon via "qx{}" and report the new status back to the daemon via a UNIX socket in for of a serialized hash.
the action scripts are simple perl scripts that, unlike the checks, are processed serial in the order defined in the config file. these shell scripts start/stop other daemons (un)/plumb network interfaces and so on.
the main goal is reached, a self contained daemon that can be copied to any location and run with near to no setup. all that has to be done is defining simple checks and configuring the state changes ... pretty straight forward.
0 TrackBacks
Listed below are links to blogs that reference this entry: a basic HA daemon - how it works.
TrackBack URL for this entry: http://who.wants.in/mt/mt-tb.cgi/19
Leave a comment