You are on page 1of 13

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.

4 Kezhong's Weblog

Page 1 of 13

Kezhong's Weblog
The future belongs to Linux! It isn't necessary to do the thing that Windows can do but Linux can't! About
Posted by: kezhong | March 28, 2010

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4


I could use LVS, ldirectord, and heartbeat to implement load balancing, but I find there is another more easy way which is Redhats 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 VIP: 192.168.26.200 gateway: 192.168.26.1 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 # piranha-passwd 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 didnt 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

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 2 of 13

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.

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 3 of 13

Copy the lvs.cf file to another LVS router. # scp /etc/sysconfig/ha/lvs.cf root@192.168.26.202:/etc/sysconfig/ha/lvs.cf Start the pulse services on the LVS Routers # service pulse restart Test The test way used my last post. You can also use the Apache HTTP server benchmarking tool (ab) to simulate users visit. References Linux Virtual Server Administration
ADVERTISEMENT

Share this: Like this:

StumbleUpon

Digg

Reddit

Like Be the first to like this post.

Posted in Uncategorized Setup Linux loadbalancer with LVS, ldirectord and heartbeat Install RAR Archiver on Fedora 12

Responses
1. Thanks for these posts. Enjoyed reading them on the cdot planet.

By: t0mmyw on March 29, 2010 at 3:47 pm Reply

2.

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 4 of 13

What about arp requests etc? I tried the piranha mode but even if I am using the RR algorithm all request are forwarded to server2 (and not randomly to server1). When I then stop apache on server2 it does not fallback to server1. Have you tried it and Ive read that you have to use aprtables or such otherwise things dont work.

By: Michiel on April 27, 2010 at 7:32 am Reply

have you checked the log info?

By: Anonymous on April 27, 2010 at 10:26 am Reply

3. I am trying to get mine to work. Question: Do I create the eth0:1 for VIP using the Piranha gui or using the /etc/sysconfig/network-scripts/ifcfg-eth0:1 file? Then, what about routing from the real servers to the LVS?

By: Willie on June 14, 2010 at 5:07 am Reply

4. Willie you can create the ifcfg-eth0:1 files on both servers. And do not for get to change the name on the interface or your netowrk will fobar. Also you do not need the mac address in the eth0:1 file it uses the parent eth0 mac

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 5 of 13

By: straighshot on June 19, 2010 at 5:52 pm Reply 5. [...] Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 [...]

By: Red Hat Cluster Piranha Linux Virtual Server - on August 31, 2010 at 12:09 am Reply

6. Hello, do you use 4 machines? 2 for lvs and other 2 for the server?

By: David on September 2, 2010 at 6:06 pm Reply

7. Thank you very much. The blog helps me a lot. I really appreciate that.

By: dilmah on October 15, 2010 at 5:55 am Reply

8. BTW, could you help me about MySQL HA issues (Replication, Mysql Cluster NDB Cluster, MySQL proxy) combined with Linux loadbalancer with Piranha and LVS? Thank you very much, again.

By: dilmah on October 15, 2010 at 6:02 am

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 6 of 13

Reply

9. hye..i folow this tuto..but why when i run command ipvsadm,the real server not appear in routing table? please help me..!

By: nana on November 12, 2010 at 1:22 pm Reply

10. p/s : real server not appear at ipvsadm routing table when i configure for mysql load balancing cluster..

By: nana on November 12, 2010 at 1:30 pm Reply

11. Nice job .. defo way more easier than ldirector and heartbeat

By: Simone on February 28, 2011 at 5:59 pm Reply

12. Can i use it to load balance DNS port 53 UDP?

By: Medo on May 30, 2011

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 7 of 13

at 7:17 am Reply

13. nice tutor.. i follow ur tutor but when i tried to launch the web site http://192.168.26.200/ through the web browser at another machine i cant access the web server.. im using CentOS for piranha and using windows for the web server.. and the only changes that i make that that not follow ur tutor is subnetmask for vip to 255.255.255.0 really need ur help..tq..

By: saiful on June 10, 2011 at 7:54 pm Reply

try to append the following lines to the /etc/sysctl.conf file, and execute sysctl -p. net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.eth0.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.eth0.arp_announce = 2

By: kezhong on June 10, 2011 at 8:47 pm Reply

im truly grateful for ur assistant.. i already add the following line that ur mention above on both LVS.. but still give the same result. because tomorrow will be sunday my university lab will be close. under those circumstance i can only implement this load balancer using VMWare.

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 8 of 13

maybe using simulation cause it doesnt . the gateway 192.168.26.1 gateway is the router ip right? off topic: did u know how to implement HA load balancer using keepalived on fedora? im asking u because im also try implement load balancing using fedora but got problem same like now cant access VIP from others machine.. :(

By: saiful on June 11, 2011 at 8:11 am

did you check your firewall? when you did lab, you could stop iptables. as for HA, you can see my past post Setup Linux loadbalancer with LVS, ldirectord and heartbeat

By: kezhong on June 11, 2011 at 9:32 am

i already disable firewall on both real server.. and set SELinux in permissive mode at the installation proses.. okey, at the lab tomorrow i will stop iptable and give feed back to u again.. the command is /etc/init.d/iptables stop, right?? tq cause helping me..

By: saiful on June 12, 2011 at 8:48 am

i already test at the real environment.. and already stop the iptables.. but like before still cant get web page went browse virtual ip.. question :-

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog

Page 9 of 13

1- suppose if I follow all ur guide above i can view web page if browse using virtual ip right? 2- is there any configuration that i need to do that u dont list at above? im so sory if i ask u to much, but i really need this load balancer working, because my final year project title about web server load balancer..

By: saiful on June 14, 2011 at 10:31 am

i just didnt list /etc/sysctl.conf file

By: kezhong on June 14, 2011 at 7:46 pm

owh ok.. i dont know why it not working on me.. so frustrated..

By: saiful on June 15, 2011 at 7:53 am

14. hellow kezhong. i follow all your configuration. at the real server did i need to configure anything? because i find this note if i set Direct Routing : http://www.centos.org/docs/5/html/Virtual_Server_Administration/s2-lvs-direct-iptablesVSA.html Direct Routing and IPTables or Direct Routing and arptables_jf must be set on real server.

By: terminology on June 16, 2011

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog Page 10 of 13

at 4:49 am Reply

15. [...] graphical interactivity with the configuration. Kezhong has a very good installation guide on his blog, which we are using to install this portion of the [...]

By: Wordpress in a Commercial Environment Lord Brockett's Blog on August 25, 2011 at 6:01 pm Reply

Leave a Reply

Email
(Not published)

Name

Website

Notify me of follow-up comments via email. Notify me of new posts via email.

Post Comment

Categories
Uncategorized

Blog Stats

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog Page 11 of 13

128,356 hits

Top Posts
Install phpMyAdmin on CentOS 5.6 Change Timezone on CentOS 5.4 Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Linux EXT2/EXT3 Superblock Recovery Install Adobe Flash Player on Fedora 14 (x86_64)

Calendar
March 2010 M T W T F S S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Feb Apr

kezhong
Installing Skype on Fedora 15(X86_64) Using SSH Tunnelling(Port Forwarding) Reading CHM files on Fedora 15 Using MSN with pidgin on Fedora 15 Finding CPU temperature on Fedora 14 Install and Update CentOS on RocketRAID 2720 Controller as Hardware Raid Install Cisco Packet Tracer 5.3.1 on Fedora 15(X86_64) Installing Cacti on Fedora 14 Solving GPT problem during the linux installation on CentOS5.6 Make yum to trigger a script after yum update on Fedora 15

Blogroll
Chris Tyler's Blog Gary Kwong's Blog John Selmys' Blog Milton Paiva's Blog Mohak Vyas' Blog Nestor Chan's Blog Patricia Constantino's Blog Varinder Singh's Blog

Websites
Fedora HowtoForge IBM Developerworks Linux Library

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog Page 12 of 13

Linux Home Networking Linux Home Page LPI Manuals LWN.net nixCraft Red Hat Deployment Guide TLDP YoLinux

Planet CDOT
Processing.js Blog: Meet the Processing.js team Peter McIntyre: How to use Apple developer documentation Peter McIntyre: iOS development toolset introduction for Seneca ICT students Peter McIntyre: Introduction to Cocoa for Seneca ICT students Peter McIntyre: Introduction to Objective-C for Seneca ICT students Ashkan Sotoudeh: Setting up a Basic Encryption on openSUSE 11.4 (Using LUKS) Andor Salga (asalga): House of Cards WebGL Demo Source Varinder Singh: SSH Login to GNU/Linux Machine from Windows Machine using Winscp

workopolis
SENIOR UNIX SYSTEMS ADMINISTRATOR - TORONTO SENIOR UNIX SYSTEMS ADMINISTRATOR - TORONTO Unix/AIX Administrator (Part Time) Senior UNIX Administrator Corporate Website Operations Support Admin Analyst (UNIX) Unix System Administrator Unix Administrator II UNIX/AIX Technical Administrator

Red Hat Magazine


Now showing: opensource.com Where have we been? Video: Open source government Call for submissions: Innovation Awards and RHCE of the Year Red Hat and Intel: Smart processors, virtualization boost efficiency and performance Writing simple python setup commands Video: Spotlight on My Fedora Happy Document Freedom Day

nixCraft
FAQ Updates: Sep/05/2011 Debian / Ubuntu Linux: Configure Network Bonding [ Teaming / Aggregating NIC ] Linux Desktop Fun: Summon Swarms Of Penguins To Waddle About The Desktop FAQ Updates: July/12/2011 Download CentOS 6 CD / DVD ISO VMWare Image Clone Problem: eth0 Renamed As eth1 FAQ Updates June/26/2011 Debian Linux Version 6.0.2 Released

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

Setup Linux loadbalancer with Piranha and LVS on CentOS 5.4 Kezhong's Weblog Page 13 of 13

Blog at WordPress.com. | Theme: Ocean Mist by Ed Merritt.

mhtml:file://D:\back_up\papers\LoadBalance Server\Setup Linux loadbalancer with Pira... 6/9/2554

You might also like