Archive for June 9th, 2009
9
						Jun
DRBD - BONDING - HA
/usr/src/linux/Documentation/networking
gcc -Wall -O -I/usr/src/linux/include ifenslave.c -o ifenslave
cp ifenslave /sbin/ifenslave
vi rc.bond
#!/bin/sh
#
        case "$1" in
          'start')
            echo "start bond0"
            #modprobe bonding mode=balance-alb miimon=100
            modprobe bonding mode=balance-rr miimon=100
            modprobe tg3
            ifconfig bond0 up
            ifenslave bond0 eth0
            ifenslave bond0 eth1
            #TODO need to be changed
            ifconfig bond0 hw ether 00:16:3e:aa:aa:aa
          ;;
          'stop')
            ifconfig bond0 down
            rmmod bonding
            rmmod tg3
          ;;
          *)
            echo "Usage: $0 {start|stop}"
          ;;
        esac
vi rc.M
before "“#Initialize the networking hardware”"
# If script rc.bond is executeable then start it if [ -x /etc/rc.d/rc.bond ]; then . /etc/rc.d/rc.bond start fi
vi rc.inet1.conf
And add these lines to it before the default gateway gets assigned:IFNAME[4]="bond0" IPADDR[4]="XXX.XX.XX.XX" NETMASK[4]="255.255.255.0" USE_DHCP[4]="" DHCP_HOSTNAME[4]=""cat /proc/net/bonding/bond0
DRBDKERNEL 2.6
,modprobe cndownload http://oss.linbit.com/drbd/make; make install/etc/drbd.conf
global { usage-count yes; } common { syncer { rate 10M; } } resource r0 { protocol C; handlers { pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f"; pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f"; local-io-error "/usr/lib/drbd/notify-local-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f"; outdate-peer "/usr/lib/heartbeat/drbd-peer-outdater -t 5"; } startup { wfc-timeout 5; degr-wfc-timeout 120; # 2 minutes. outdated-wfc-timeout 2; # 2 seconds. } disk { on-io-error detach; } net { max-buffers 8192; cram-hmac-alg "sha1"; shared-secret "hieuvpn"; after-sb-0pri discard-least-changes; after-sb-1pri discard-secondary; after-sb-2pri violently-as0p; rr-conflict disconnect; } syncer { rate 10M; al-extents 257; } on drdb-one { device /dev/drbd0; disk /dev/hda3; address 10.10.50.26:7788; meta-disk internal; } on drdb-two { device /dev/drbd0; disk /dev/hda3; address 10.10.50.27:7788; meta-disk internal; } }
resource r1 { protocol C; handlers { pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f"; pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f"; local-io-error "/usr/lib/drbd/notify-local-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f"; outdate-peer "/usr/lib/heartbeat/drbd-peer-outdater -t 5"; } startup { wfc-timeout 5; degr-wfc-timeout 120; # 2 minutes. outdated-wfc-timeout 2; # 2 seconds. } disk { on-io-error detach; } net { max-buffers 8192; cram-hmac-alg "sha1"; shared-secret "hieuvpn"; after-sb-0pri discard-least-changes; after-sb-1pri discard-secondary; after-sb-2pri violently-as0p; rr-conflict disconnect; } syncer { rate 10M; al-extents 257; } on drdb-one { device /dev/drbd1; disk /dev/hdb; address 10.10.50.26:7790; meta-disk internal; } on drdb-two { device /dev/drbd1; disk /dev/hdb; address 10.10.50.27:7790; meta-disk internal; } } Before starting the primary node, you should create the metadata for the devices:root-shell> drbdadm create-md allroot-shell> /etc/init.d/drbd startroot-shell> drbdadm -- --overwrite-data-of-peer primary allroot-shell> mkfs.ext3 /dev/drbd0root-shell> mount /dev/drbd0 /mnt/drbdTo set up a secondary node:Copy the/etc/drbd.conffile from your primary node to your secondary node.root-shell> drbdadm create-md allroot-shell> /etc/init.d/drbd start
cat /proc/drbdroot-shell> drbdadm primary allroot-shell> drbdadm secondary allroot-shell> drbdadm disconnect allroot-shell> drbdadm connect allif split brain - run this on failed nodedrbdadm -- --discard-my-data connectall(forcing by drbdadm invalidate all )and do connect on order sideHA
download http://www.slackware.com/~alien/slackbuilds/libnet/pkg/11.0/libnet-1.1.2.1-i486-1.tgzdownload http://hg.linux-ha.org/lha-2.1/archive/STABLE-2.1.4.tar.bz2tar -jxvf heartbeat.tar.bz2./ConfigureMe configuremake; make install
vi ha.cf
logfacility local0 keepalive 500ms deadtime 10 warntime 5 initdead 30 mcast bond0 225.0.0.1 694 2 0 auto_failback off node drdb-one node drdb-two ping 10.10.50.254 10.10.50.50 respawn hacluster /usr/lib/heartbeat/ipfail apiauth ipfail gid=haclient uid=hacluster deadping 5
vi haresources drdb-two drbddisk Filesystem::/dev/drbd0::/raid1::ext3 mysql 10.10.50.28
vi resource.d/mysql.resource
#!/bin/bash
#
# This script is inteded to be used as resource script by heartbeat
#
# Mar 2006 by Monty Taylor
#
###
. /etc/ha.d/shellfuncs
case "$1" in
    start)
        res=`/etc/init.d/mysql start`
        ret=$?
        ha_log $res
        exit $ret
        ;;
    stop)
        res=`/etc/init.d/mysql stop`
        ret=$?
        ha_log $res
        exit $ret
        ;;
    status)
        if [ `ps -ef | grep '[m]ysqld'` ] ; then
           echo "running"
        else
           echo "stopped"
        fi
        ;;
    *)
        echo "Usage: mysql {start|stop|status}"
        exit 1
        ;;
esac
exit 0