Monday, November 23, 2009

Install heartbeat on Ubuntu Mysql Cluster & HA Proxy

I already done (BUT NOT TESTED YET) my heartbeat installing heartbeat on ubuntu.

$ sudo apt-get install haproxy
$ sudo apt-get install heartbeat


HAproxy

The config file for HAProxy is in "/etc/haproxy.cfg"

here my sample of my haproxy.conf

global
log 127.0.0.1 daemon debug
stats socket /tmp/stats
maxconn 4096
pidfile /var/run/haproxy.pid
daemon

defaults
log global
mode tcp
option dontlognull retries 3 option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000

listen MySQL 172.16.100.240:3306
mode tcp
option httpchk
stats enable
stats uri /haproxy-stats
balance roundrobin

server mysql_master 172.16.100.241:3306
server mysql_slave 172.16.100.242:3306

Heartbeat

/etc/ha.d/ha.cf #main config file
/etc/ha.d/authkeys #authorization keys file

/etc/ha.d/haresource #share resources on nodes

example on my conf :

You must set on both machines

Primary machine Secondary machine
keepalive 2

warntime 10

deadtime 25

initdead 50

udpport 694

auto_failback on

bcast eth0

node niti.joey.net

node niti.aniket.net

debugfile /var/log/ha-debug

logfile /var/log/ha-log

keepalive 2

warntime 10

deadtime 25

initdead 50

udpport 694

auto_failback on

bcast eth1

node niti.joey.net

node niti.aniket.net

debugfile /var/log/ha-debug

logfile /var/log/ha-log


haresources conf

ubuntu-mysqlclusterA 172.168.1.241/24/eth0 # set in machine B

ubuntu-mysqlclusterB 172.168.1.242/24/eth0 # set in machine A

authkeys

Syntax:
auth
[]

example :

auth 1

1 md5 mypassword

Starting Heartbeat’s Services

Once, you are through with the above configurations in both of the machines, use the following to start the Heartbeat daemon.

$ /etc/init.d/heartbeat start

This command has to be run simultaneously on both the machines.

Following commands can also be used as required:

$ /etc/init.d/heartbeat stop

$ /etc/init.d/heartbeat restart


Reference for my project :

Thanks and credits to these blog and people :

http://theitaxis.wordpress.com/2009/11/14/heartbeat-a-step-by-step-configuration-guide-to-high-availability-linux-clusters/

http://raghupathy.wordpress.com/2008/05/01/high-availabilitycluster-with-load-balancing-by-using-heartbeat-and-haproxy/

http://oceanobservatories.org/spaces/display/CIDev/High+availability+Load+Balancer+-+HAProxy+and+heartbeat


No comments:

Post a Comment