freebsd-cluster Digest, Vol 113, Issue 1

Andrei Manescu mandrei05 at gmail.com
Tue Nov 11 05:18:56 PST 2008


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 <freebsd-cluster-request at freebsd.org>

> Send freebsd-cluster mailing list submissions to
>        freebsd-cluster at 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 at freebsd.org
>
> You can reach the person managing the list at
>        freebsd-cluster-owner at 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" <anhptnn at gmail.com>
> Subject: Full picture for "Load Balacing MySQL, Apache"
> To: freebsd-cluster at freebsd.org
> Message-ID:
>        <e46552500811102021w5f007af4h4a6a56762c5486aa at mail.gmail.com>
> 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 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-cluster
> To unsubscribe, send any mail to "freebsd-cluster-unsubscribe at freebsd.org"
>
>
> End of freebsd-cluster Digest, Vol 113, Issue 1
> ***********************************************
>


More information about the freebsd-cluster mailing list