How can I set up a master/slave configuration for my load balanced services?

We have written a script that will configure the Zeus Load Balancer sothat it will switch between a 'master' and 'slave' group of back-endson demand. The switch is controlled by an external program, so thatcustomers can provide their own scripts (e.g. to monitor a database,check a file server, and so on) to determine whether the master or theslave servers will be used.

To use this feature, you must first download the following file, and unpackit in the directory where you have installed your Zeus Load Balancer. If youare using two Load Balancers for fault tolerance, please ensure that youinstall the program on both Load Balancers.

Monitoring tool for Zeus Load Balancer

Installation instructions

To set up this monitoring tool, you will need to unpack the file as shownbelow. You will need to be root to do this. The following commands assumethat the Zeus Load Balancer is installed in /usr/local/zeus andthat you have downloaded the monitor.tgz file into the /tmpdirectory. Change these locations as appropriate.

cd /usr/local/zeusgzip -c -d /tmp/monitor.tgz |tar xvf -

This will have copied the new scripts into your Load Balancerinstallation. You now must configure the script by editing the filebalancer/monitor.cfg. The file contains the following settings:

MASTERS

This must be set to the list of back-end servers that are in the'masters' group - i.e. the servers that will be used by the Zeus LoadBalancer when everything is running normally with no failures. If thereis more than one machine specified, then the Zeus Load Balancer willspread the load across all master servers. Please note that if you areusing Zeus Web Servers, then you must include each web server's controlport in the list.

E.g. MASTERS = webserver1 webserver2 webserver3:9080

SLAVES

This configuration is similar to the 'MASTERS' setting, but itspecifies the slave back-ends, i.e. the machines that will not be in usenormally, but will be called into service in the event of a failure.

E.g. SLAVES = backupserver1:9080 backup2:9080

SCRIPT

The 'SCRIPT' line in the configuration specifies the name of theexternal program that will be used to determine if the master or slaveservers should be used.

The script program will be run by the service-monitor process on aregular basis. The script must simply output OK if everything iswell, or FAIL if there is a problem. If all is OK, then the LoadBalancer will be configured to use the master servers, and the slaves willbe taken out of operation. Otherwise, the master servers are taken out ofservice and the slaves brought in.

Multiple SCRIPT lines can be given, so that several monitoringprograms can be used. If any monitoring program returns FAIL thenthe Load Balancer will start using the slave servers.

E.g. SCRIPT = /usr/local/bin/check-db SERVER=database-server

TIMEPERIOD

The Zeus Load Balancer service-monitor will periodically run thescripts that have been configured above. This setting configures howoften the scripts are run. The timing is in seconds. A shorter time willmean that services will be monitored more frequently, but this willput a higher load on them.

E.g. TIMEPERIOD = 5

g the Load Balancer

After editing the monitor.cfg file, you should check that theLoad Balancer is also configured correctly. In the Admin Server GUI, ensurethat the Load Balancer shows all of the back-ends - masters andservers. If any are missing, be sure to add them in.

To configure a load-balanced service to make use of themaster/slave switching, set up the port configuration asnormal. Again, be sure to configure the service to use all ofthe back-ends. The service can also freely use any of the back-ends thataren't in the master or slave group of back-ends.

Finally, now that everything is set up, you must run theservice-monitor program to start everything off. To do this,run the command (as root):

./balancer/rc-service-monitor start

If you have installed the Zeus Load Balancer to start on boot, thenthe service-monitor program will also automatically start up on boot.

Troubleshooting

If there are any problems, you should first take a look in the errorlogs for the Load Balancer(s). This is found in balancer/log/errorsinside the Zeus installation. If the service monitor finds any problems, thenit will report them here.

While the service monitor is running, please note that the Admin ServerGUI will always show all of your back-end servers, masters and slaves,regardless of whether they are being used at that moment. You can click onindividual back-ends to see what traffic they are currently serving. Also,the 'diagnosis' tool for the balancer will also report that the Load Balancerhas a different list of back-end servers from the admin server. This iscorrect - the Load Balancer will have removed either the masters or theslaves from their configuration, so this is not a problem.

Content Manager [Administrator] 12 August 2005 Bookmark with del.icio.us Post this article to Digg Post this article to reddit Post this article to Facebook Tweet this article  

Recently...

Other Resources