Install Pen to configure Load Balance server. Pen is a light weight simple load balancer. This example shows to configure on the environment like follows.
(1) gw.horoppa.net [10.0.0.50] - Pen Server
(2) www01.horoppa.net [10.0.0.51] - Web Server#1
(3) www02.horoppa.net [10.0.0.52] - Web Server#2
[1] Install and Configure Pen
[root@gw ~]# vi /etc/pen.conf # create new # log file LOGFILE=/var/log/pen.log # output file of status WEBFILE=/var/www/pen/webstats.html # control port CONTROL=127.0.0.1:10080 # max connections MAX_CONNECTIONS=500 # listen port PORT=80 # number of backend servers BACKEND=2 # IP address of a backend SERVER1=10.0.0.51:80 # IP address of a backend SERVER2=10.0.0.52:80 [root@gw ~]# vi /etc/rc.d/init.d/pend # create init script # this is an example #!/bin/bash [root@gw ~]# vi /etc/logrotate.d/pen # this is an example /var/log/pen.log { chmod 755 /etc/rc.d/init.d/pend [root@gw ~]# /etc/rc.d/init.d/pend start Starting Pend: [ OK ] [root@gw ~]# chkconfig --add pend [root@gw ~]# chkconfig pend on |
[2] | Access to the URL you set and make sure backend server answers normally like follows. |
[3] | Shutdown other httpd manually and make sure another httpd answers normally like follows. |
[4] | Configure the tool that it's possible to watch Pen's status. |
[root@gw ~]# cp /usr/share/doc/pen-*/penstats /var/www/pen [root@gw ~]# vi /var/www/pen/penstats # line 4: change PIDFILE= /var/run/pen.pid # line 5: change WEBFILE= /var/www/pen/webstats.html [root@gw ~]# vi /etc/httpd/conf.d/pen.conf # change Alias /pen/ /var/www/pen/<Directory /var/www/pen/> DirectoryIndex penctl.cgi Options ExecCGI order deny,allow deny from all allow from 127.0.0.1 10.0.0.0/24 # IP address you permit </Directory> /etc/rc.d/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [root@gw ~]# chmod 755 /var/www/pen/penstats [root@gw ~]# /var/www/pen/penstats > /dev/null # run [root@gw ~]# crontab -e # update by 5 minutes */5 * * * * /var/www/pen/penstats > /dev/null |
[5] | Access to "http://(pen's hostname or IP address):(httpd listen port)/pen/webstats.html" and make sure following site is shown normally. |
0 comments:
Post a Comment