How to Build HA/LB LAMP Cluster

June 5, 2009
How to Build HA/Load-Balanced LAMP Cluster

In this article i will tell my experience with building a High-Availability Load Balanced Linux+Apache+PHP+MySQL Cluster using 2 web servers + 2 DB servers.

first of all i would like to say ” Many Thanks Sun Microsystems for the great work and projects you are always donating to FOSS world and my Best wishs”, I used the great virtualization platform VirtualBox or Sun XVM to do the lab for this project.

I advice every one who want to test Clustering or HPC to use VirtualBox get it here it’s very easy to use and its perfomance is the best.

Cluster Description:
This cluster will contain 4 nodes as follows:
- 2 x Apache servers configured as Active/Active load-balanced cluster.
- 2 x MySQL servers configured as Master/Slave with Replication and also as Active/Active Load-Balanced Cluster !!! ;) .

The Distro. used in this project is CentOS and the real project contained a SAN storage with 2TB Disk space divided as 1TB for backup, 400GB for each MySQL Server and 200 GB shared Document Root between Apache web servers and formated as GFS2.

here i would like to say “Many Thanks to the Great Red Hat company, without your great support to FOSS and specially to GNU/Linux there will never be this great HA/Clustering platform.

It’s almost easy to do this project using Conga and/or system-config-cluster utilities, i used these tools to configure the cluster storage only as there’s no need to configure fail-over’d services because the whole cluster will be load-balanced.

the most problematic part is the Piranha and LVS configuration part, till now i can’t configure load-balancing using piranha nor /etc/sysconfig/ha/lvs.conf.

the easiest way for me was configuring every thing from the command line using ipvsadm and iptables then make changes permanent by saving them to /etc/rc.local .

to do this cluster using virtual machines, i did make 2 CentOS virtual machines !!, yes only 2 my laptop can’t run fine with more than 3 VMs ;) .
one will be publicly accessible from WAN which acting as Load-Balancer + router + web server + DB server.
the other will be web server + DB server.

the configuration goes like the following:
- configure Apache on the 2 nodes ( i did configure it on the 2nd node to use an exported NFS DocRoot form node1).
- configure MySQL Replication on the Master (node1) and the slave (node2).
- configure ip_forwarding on 2 nodes.
- configure firewall masquerading and NAT on the first node
- set node1 as the default gateway to node2
- set the virtual IP on node 1 using an alias/virtual network interface or using iproute2
- use ipvsadm to set the virtual server and real servers and load balancing algorithm

you will have to this for Apache and MySQL so you’ll have to have 2 virtual services assigned to one virtual server.

and it’s done ;) now you can use a PC on the WAN of node1 to check the cluster.

I know you’re saying WTF is this shit where’s the configuration and commands :) , it’ll be here soon.

To Be Continued and detailed….

Powered by ScribeFire.


عودة الى التدوين التقني

June 5, 2009
السلام عليكم،
فى البدايه اود التنويه الى انني بإذن الله سوف اقوم بكتابة مقاله على الاقل أسبوعياً تصف إحدى الخبرات التي اكتسبها فى حياتي العمليه مع لينوكس و البرمجيات الحره.
كما اود التنويه الى أن معظم مقالاتي ستكون فى الغالب باللغه الانجليزيه لما لها من طابع تقني متقدم بعض الشيئ ولما تحتويه من مصطلحات و عبارات لا يمكن استساغتها من قبل المتخصصين الا بلغتها الاصليه.
لذا إذا كان لديك عزيزي القارئ اي اعتراض يمكنك ترجمة المقاله وارسالها لي او اضافتها فى تعليق او وضعها فى موقعك الخاص بإسمك إذا شئت و من دون ان تذكر المرجع فليس الهدف من هذه المقالات شهره او هدف شخصي و للجميع الحريه فى التعامل مع محتوى هذا الموقع كما يشاء.
أيضاً اود الإعلان عن افتتاح مجموعة جوجل (البرمجيات الحرة فى الشرق الأوسط و شمال أفريقيا) و التي تضم المهتمين بهذا المجال فى هذه المنطقه و أدعوا جميع المهتمين الإشتراك فيها من خلال هذا الرابط.
تم بحمد الله

Powered by ScribeFire.