I could use LVS, ldirectord, and heartbeat to implement load balancing, but I find there is another more easy way which is Redhat’s piranha. You need not configure four configuration files, instead of only one which can be configured by web-based tool.
My lab environment was similar to my last post.
LVS Router 1: eth0: 192.168.26.201
LVS Router 2: eth0: 192.168.26.202
Real Server 1: eth0: 192.168.26.211
Real Server 2: eth0: 192.168.26.212
Install piranha and ipvsadm packages on the LVS Routers
# yum install ipvsadm
# yum install piranha
Configuring Services on the LVS Routers
# chkconfig pulse on
# chkconfig piranha-gui on
# chkconfig httpd on
Setting a Password for the Piranha Configuration Tool
Turning on Packet Forwarding on the LVS Routers
# echo 1 > /proc/sys/net/ipv4/ip_forward
Starting the Piranha Configuration Tool Service
Modify the mode SELinux in permissive mode. If you didn’t do it, it would show the error massage as below when you started the piranha-gui service.
Starting piranha-gui: (13)Permission denied: make_sock: could not bind to address [::]:3636
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:3636
No listening sockets available, shutting down
Unable to open logs
# setenforce 0
# service httpd start
# service piranha-gui start
Configuring the LVS Routers with Piranha Configuration Tool
Open http://192.168.26.201:3636 in a Web browser to access the Piranha Configuration Tool. Click on the Login button and enter piranha for the Username and the administrative password you created in the Password field.
Click on the GLOBAL SETTINGS panel, and input the primary server public IP, and then click the ACCEPT button.
Click on the REDUNDANCY panel, and input the redundant server public IP, and then click the ACCEPT button.
Click on the VIRTUAL SERVERS panel, add a server, edit it, and activate it.
Clicking on the REAL SERVER subsection link at the top of the panel displays the EDIT REAL SERVER subsection. Click the ADD button to add new servers, edit them and activate them.
Copy the lvs.cf file to another LVS router.
# scp /etc/sysconfig/ha/lvs.cf firstname.lastname@example.org:/etc/sysconfig/ha/lvs.cf
Start the pulse services on the LVS Routers
# service pulse restart
The test way used my last post. You can also use the Apache HTTP server benchmarking tool (ab) to simulate users’ visit.
Linux Virtual Server Administration