From owner-freebsd-cluster@FreeBSD.ORG Tue Nov 11 04:21:14 2008 Return-Path: Delivered-To: freebsd-cluster@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF7941065670 for ; Tue, 11 Nov 2008 04:21:14 +0000 (UTC) (envelope-from anhptnn@gmail.com) Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.178]) by mx1.freebsd.org (Postfix) with ESMTP id 4D6DE8FC12 for ; Tue, 11 Nov 2008 04:21:14 +0000 (UTC) (envelope-from anhptnn@gmail.com) Received: by ik-out-1112.google.com with SMTP id c21so2169597ika.3 for ; Mon, 10 Nov 2008 20:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=RkRghVVEY2jAPMx0qjqhT5MgfIvzUw16h37gIO6MlwA=; b=rbfCRAMV01oH085aEwHxMN2r7KS5QiYQfsMskJLhP8osWTqxbOPG6N28otlDmDvvdR nZCl8q19JdLGCIxJsitMXOkgVJmKt5mDxryGYnaATZB4rOsbWLsHFRuR6PF8U/qFuaTB F+zlmhxWiXrM4GLE7v+61ZJfHXxFDxY8Bl2js= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=PAFd289XvMBC4q8zWKbwA75h8DnH5IHQUMfeXRgliRE05NpHUCG8XpYqTtngCw8gn+ 8NzvxJJyKfDydeKX/FWgEsUCC2DAK+2xUSbdaaZCMFrM9pZ0FbTACfiEBykPMBDSDs+/ kEsMWiAjPVrVF7IofmYlv114gToINA6LzhNyg= Received: by 10.210.22.8 with SMTP id 8mr8560040ebv.46.1226377272818; Mon, 10 Nov 2008 20:21:12 -0800 (PST) Received: by 10.210.92.17 with HTTP; Mon, 10 Nov 2008 20:21:12 -0800 (PST) Message-ID: Date: Tue, 11 Nov 2008 11:21:12 +0700 From: "Anh Pham Tuan" To: freebsd-cluster@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Full picture for "Load Balacing MySQL, Apache" X-BeenThere: freebsd-cluster@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Clustering FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2008 04:21:14 -0000 Hello, Does anybody give me a solution for this: | Load Balancer (IPVS, MySQL cluster management) | / \ / \ Apache Apache MySQL MySQL Howto install IPVS, MySQL cluster management? How to configure 2 nodes including of Apache+MySQL? Thanks in advance. From owner-freebsd-cluster@FreeBSD.ORG Tue Nov 11 13:18:56 2008 Return-Path: Delivered-To: freebsd-cluster@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1ADEA106564A for ; Tue, 11 Nov 2008 13:18:56 +0000 (UTC) (envelope-from mandrei05@gmail.com) Received: from rn-out-0910.google.com (rn-out-0910.google.com [64.233.170.189]) by mx1.freebsd.org (Postfix) with ESMTP id ADF868FC1A for ; Tue, 11 Nov 2008 13:18:55 +0000 (UTC) (envelope-from mandrei05@gmail.com) Received: by rn-out-0910.google.com with SMTP id j71so2154480rne.12 for ; Tue, 11 Nov 2008 05:18:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=lgCVgpBpClsjyXR7WeBd7LXOR3tOY5pKDjDsTNoWmFc=; b=BWPUcxhRMRA3RtLyaE4LvAxOzVn9DvrkctCmC6ElS4i/30U5cdmho7RuUT9/eqdqS6 +jvkGBVFoXixIXpwUqOU9DTyeZWs6f2JjL/xW3FHMiZ1vMrMRLqllMwCOvpxzLfjZUN9 oKbJW7lfHt0IiHZ/yisJlhW7pNs6bPDgeyNQk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=xBfa50wj0RWgzooSoSrSzWgdMN/3e25svS7SSD7Qy93wHFKfFhzDqsswRE6UOAY9mM R9AFlnQvLGpbiRwGsTYmdlG2m6jo+dXuSy0HRLLU2VKzg3bX57Fq2Lv3n4FTYNIHegEU eSBZdF+DDjHsBf1wpCNV1wV80pug/EEc3x1mA= Received: by 10.150.203.8 with SMTP id a8mr1431868ybg.84.1226408152452; Tue, 11 Nov 2008 04:55:52 -0800 (PST) Received: by 10.150.215.10 with HTTP; Tue, 11 Nov 2008 04:55:52 -0800 (PST) Message-ID: Date: Tue, 11 Nov 2008 13:55:52 +0100 From: "Andrei Manescu" To: freebsd-cluster@freebsd.org In-Reply-To: <20081111120014.E885010656D4@hub.freebsd.org> MIME-Version: 1.0 References: <20081111120014.E885010656D4@hub.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: freebsd-cluster Digest, Vol 113, Issue 1 X-BeenThere: freebsd-cluster@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Clustering FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2008 13:18:56 -0000 Hello, I tried these solutions separately in test environments, but they should work together: A) For load balancing you can use CARP + 2 VHID. Each node being master for 1 vhid. This way, when one node fails, the other one will take both "service" ip (vhid). 1 example here: http://blas.phemo.us/articles/2007/04/04/setting-up-and-configuring-carp-interfaces-on-freebsd(but I would recommend you to read the manuals + 3-4 other links). B) As for Mysql, you can use the dual master configuration. Be very carefull here. This procedure is based on mysql internal binary logs to replicate each entry from one node to the other. You will need to play with * auto_increment_offset* option from MySQL (otherwise auto_incremented columns will be screwed up). You have a lot to read, but it's worth it. Here are some links for mysql dual master replication: http://forums.mysql.com/read.php?26,100718,100718 http://mediakey.dk/~cc/howto-do-mysql-replication-dual-master-multi-master/ http://www.lefred.be/?q=node/45 I know that this is not a very efficient method for load-balancing but at least it offers redundancy & a little load balancing. C) Unless I miss something, you configure your PHP scripts to point to localhost/service IP (VHID)/nodes fixed ip address for mysql connection. D) PHP & other web programming languages use sessions (depends on the websites that you'll be hosting) that are stored usually on /tmp of the server, so be carefull to have this in mind because some clients can loose their sessions if they're redirected to the second node, unless you do something about it (like rsync/nfs/csync/etc). E) You can youse a 3rd machine running PF as firewall that will do NAT for the nodes + port redirection + load balancing: Here is the example - http://www.openbsd.org/faq/pf/pools.html F) If your website(s) will use upload forms you will need to keep the Directory_roots of Apache from both nodes in sync or you can use shared storage (but I guess that's not your case). G) This solution does not offer automatic automatic failover mechanisms in case of service-failure. I mean that if mysql/apache processes will go down or crash on one node (some bug or they are stopped), but the node stays up, from cluster point of view everything will be ok. The master/firewall (point E) will still forward part of the incoming packets to this failed node. You need to use the nc-netcat command (get exit status) to check ports 80,3306 (or those that your apache/mysql will listen to) from both nodes and take action if one node is detected UP but apache is down (like change the port-forwarding rule or connect one of the node and transfer the CARP vhid from the node with apache not running). Example of how to run netcat to check if apache and mysql are running (Apache - Yes, mysql - No): # nc -w 1 localhost 80 >/dev/null 2>&1; echo $? 0 # nc -w 1 localhost 3306 >/dev/null 2>&1; echo $? 1 H) You could also use daemon-tools to monitor and restart apache+mysql processes in case they crash (of course, the start/stop procedure for both will be different from standard one). P.S.: I never used this complete configuration to say if it'll work, but this is how I would do it. P.S.2: If you are used to commercial clustering solutions, probably this will seem a little strange, as there are no scripts/commands to show the status of the cluster nodes/services, but you can make some scripts t If anyone has anything to add or to correct, please do it, as this would be important to me, also. Good luck. 2008/11/11 > Send freebsd-cluster mailing list submissions to > freebsd-cluster@freebsd.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.freebsd.org/mailman/listinfo/freebsd-cluster > or, via email, send a message with subject or body 'help' to > freebsd-cluster-request@freebsd.org > > You can reach the person managing the list at > freebsd-cluster-owner@freebsd.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of freebsd-cluster digest..." > > > Today's Topics: > > 1. Full picture for "Load Balacing MySQL, Apache" (Anh Pham Tuan) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 11 Nov 2008 11:21:12 +0700 > From: "Anh Pham Tuan" > Subject: Full picture for "Load Balacing MySQL, Apache" > To: freebsd-cluster@freebsd.org > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > Hello, > Does anybody give me a solution for this: > | > Load Balancer (IPVS, MySQL cluster management) > | > / \ > / \ > Apache Apache > MySQL MySQL > Howto install IPVS, MySQL cluster management? > How to configure 2 nodes including of Apache+MySQL? > Thanks in advance. > > > ------------------------------ > > _______________________________________________ > freebsd-cluster@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-cluster > To unsubscribe, send any mail to "freebsd-cluster-unsubscribe@freebsd.org" > > > End of freebsd-cluster Digest, Vol 113, Issue 1 > *********************************************** >