Revision [3741]
Last edited on 2010-07-01 20:30:18 by KenFongAdditions:
ping_group hb-ping-test 10.0.0.1 10.0.0.254
Deletions:
Revision [2819]
Edited on 2009-07-17 09:58:46 by WikiAdminAdditions:
Update: One may instruct heartbeat to failover / failback using the commands **/usr/lib64/heartbeat/hb_standby** and **/usr/lib64/heartbeat/hb_takeover** commands. But heartbeat does not actually check mysql's status.
Revision [2817]
Edited on 2009-07-17 09:47:34 by WikiAdminAdditions:
# Use multiple interfaces here, one of the should be the
# interface dedicated for heartbeat. This gives you redundancy
# I do not prefer serial connection, but that could be a more
# accurate connection to prevent split brain situation.
bcast eth1
# interface dedicated for heartbeat. This gives you redundancy
# I do not prefer serial connection, but that could be a more
# accurate connection to prevent split brain situation.
bcast eth1
Deletions:
Revision [2816]
Edited on 2009-07-17 09:41:04 by WikiAdminAdditions:
Copy the mysql init script from /etc/init.d to /etc/ha.d/resources.d. Edit it such that it uses /var/lib/mysql/my.cnf to look for configurations. The reason is obvious, when mysql fails over to the standby host, you want it to always use the same defaults file. This can be done by adding the option **--defaults-file=/var/lib/mysql/my.cnf** to my_print_defaults:
Deletions:
Revision [2815]
Edited on 2009-07-17 09:40:04 by WikiAdminAdditions:
Copy the mysql init script from /etc/init.d to /etc/ha.d/resources.d. Edit it such that it uses /var/lib/mysql/my.cnf to look for configurations. This can be done by adding the option **--defaults-file=/var/lib/mysql/my.cnf** to my_print_defaults:
get_mysql_option(){
result=`/usr/bin/my_print_defaults --defaults-file=/var/lib/mysql/my.cnf "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
}
Move /etc/my.cnf to /var/lib/mysql/ or whereever DRBD will be mounted on
get_mysql_option(){
result=`/usr/bin/my_print_defaults --defaults-file=/var/lib/mysql/my.cnf "$1" | sed -n "s/^--$2=//p" | tail -n 1`
if [ -z "$result" ]; then
# not found, use default
result="$3"
fi
}
Move /etc/my.cnf to /var/lib/mysql/ or whereever DRBD will be mounted on
Deletions:
Revision [2814]
Edited on 2009-07-17 09:31:16 by WikiAdminAdditions:
Copy the mysql init script from /etc/init.d to /etc/ha.d/resources.d
Revision [2094]
Edited on 2008-11-27 22:29:00 by WikiAdminAdditions:
Filesystem::/dev/drbd0::/var/lib/mysql::ext3[::MOUNT_OPTIONS] \
Deletions:
Revision [1992]
Edited on 2008-10-09 01:34:11 by WikiAdminAdditions:
debugfile /var/log/ha.debug
logfile /var/log/ha.log
logfile /var/log/ha.log
Deletions:
logfile /var/log/ha-log
Revision [1991]
Edited on 2008-10-08 22:28:04 by WikiAdminAdditions:
Filesystem::/dev/drbd0::/var/lib/mysql::ext3::mount_options \
Deletions:
Revision [1810]
Edited on 2008-07-15 01:13:58 by WikiAdminAdditions:
Ref: http://www.linuxjournal.com/article/9074
Revision [1809]
Edited on 2008-07-15 00:33:08 by WikiAdminAdditions:
Use the same authkeys on both nodes
%%(text;authkeys)
auth 1
1 md5 some_random_secret
%%(text;authkeys)
auth 1
1 md5 some_random_secret
Revision [1808]
Edited on 2008-07-15 00:30:43 by WikiAdminAdditions:
For RHEL, I use the heartbeat rpm from centos.
==Create authkeys==
==Create ha.cf==
Filesystem::/dev/drbd0::/var/lib/mysql::ext3 \
IPaddr::10.0.0.50 \
mysql
==Create authkeys==
==Create ha.cf==
Filesystem::/dev/drbd0::/var/lib/mysql::ext3 \
IPaddr::10.0.0.50 \
mysql
Deletions:
IPaddr::10.0.0.50 \
mysql
Revision [1104]
Edited on 2007-10-26 16:44:59 by WikiAdminAdditions:
prod02.domain.com drbddisk::mydata \
Deletions:
Revision [955]
Edited on 2007-09-10 19:50:38 by WikiAdminAdditions:
{{parent page="MySQL"}}
Deletions:
Revision [954]
Edited on 2007-09-09 21:37:53 by WikiAdminAdditions:
Check /proc/drbd to ensure the sync process has started. Wait for the sync to complete.
Revision [953]
Edited on 2007-09-09 21:35:32 by WikiAdminAdditions:
# On secondary host, invalidate my data partition. Restart DRBD and synchronization will begin automatically.
drbdadm invalidate mydata
drbdadm invalidate mydata
Deletions:
Revision [952]
Edited on 2007-09-09 21:18:32 by WikiAdminDeletions:
Mon: http://www.netexpertise.eu/en/Mysql/Failover.html
Revision [951]
Edited on 2007-09-09 21:17:44 by WikiAdminAdditions:
3. Now to a DRBD synchronization from standby to primary
drbdadm primary mydata -o
service drbd restart
4. Now that the primary has an updated DRBD partition, and is ready to be failed-back. Change DRBD to Secondary/Secondaryby running **drbdadm secondary mydata** on both hosts.
5. Start heartbeat service on primary. Check /var/log/ha-log to make sure all local resources are brought up
6. Start heartbeat service on standby
drbdadm primary mydata -o
service drbd restart
4. Now that the primary has an updated DRBD partition, and is ready to be failed-back. Change DRBD to Secondary/Secondaryby running **drbdadm secondary mydata** on both hosts.
5. Start heartbeat service on primary. Check /var/log/ha-log to make sure all local resources are brought up
6. Start heartbeat service on standby
Deletions:
Revision [950]
Edited on 2007-09-09 21:14:21 by WikiAdminAdditions:
==Failover and failback==
One should have a script on primary DB to monitor mysql's availability. You may use the following as an example:
%%(mysql_mon.sh;bash)
#!/bin/bash
DBRESULT=`echo "select count(1) from mysql.user;" | mysql -s --connect_timeout=1 -uroot -pxxxx`
if [ ${DBRESULT} -lt 1];
then
logger -t MYSQL_MON "MySQL unavailable. Stopping heartbeat service."
service heartbeat stop
fi
Once heartbeat is stopped on the primary, it will do its work and activate the standby database.
Fail-back is preferred as a manual procedure. It is important that the heartbeat service is not configured to startup automatically on both servers. In case of a server reboot or fail-back scenario, it best to start / restart services interactively. Steps for fail-back:
1. shutdown heartbeat on both servers
2. check /proc/drbd make sure standby server is currently the primary DRBD, and primary server is secondary DRBD. If you're connected the standby machine, the status should be Primary/Secondary.
3. Now to a DRBD synchronization
One should have a script on primary DB to monitor mysql's availability. You may use the following as an example:
%%(mysql_mon.sh;bash)
#!/bin/bash
DBRESULT=`echo "select count(1) from mysql.user;" | mysql -s --connect_timeout=1 -uroot -pxxxx`
if [ ${DBRESULT} -lt 1];
then
logger -t MYSQL_MON "MySQL unavailable. Stopping heartbeat service."
service heartbeat stop
fi
Once heartbeat is stopped on the primary, it will do its work and activate the standby database.
Fail-back is preferred as a manual procedure. It is important that the heartbeat service is not configured to startup automatically on both servers. In case of a server reboot or fail-back scenario, it best to start / restart services interactively. Steps for fail-back:
1. shutdown heartbeat on both servers
2. check /proc/drbd make sure standby server is currently the primary DRBD, and primary server is secondary DRBD. If you're connected the standby machine, the status should be Primary/Secondary.
3. Now to a DRBD synchronization