disconnect
No automatic resynchronisation, simply disconnect.
discard-younger-primary
Auto sync from the node that was primary before the split- brain situation occurred.
discard-older-primary
Auto sync from the node that became primary as second during the split-brain situation.
discard-zero-changes
In case one node did not write anything since the split brain became evident, sync from the node that wrote something to the node that did
not write anything. In case none wrote anything this policy uses a random decission to perform a "resync" of 0 blocks. In case both have
written something this policy disconnects the nodes.
discard-least-changes
Auto sync from the node that touched more blocks during the split brain situation.
discard-node-NODENAME
Auto sync to the named node.
-B, --after-sb-1pri asb-1p-policy
possible policies are:
disconnect
No automatic resynchronisation, simply disconnect.
consensus
Discard the version of the secondary if the outcome of the after-sb-0pri algorithm would also destroy the current secondary’s data. Other-
wise disconnect.
discard-secondary
Discard the secondary’s version.
call-pri-lost-after-sb
Always honour the outcome of the after-sb-0pri
algorithm. In case it decides the current secondary has the right data, call the pri-lost-after-sb on the current primary.
violently-as0p
Always honour the outcome of the after-sb-0pri
algorithm. In case it decides the current secondary has the right data, accept a possible instantaneous change of the primary’s data.
-C, --after-sb-2pri asb-2p-policy
possible policies are:
disconnect
No automatic resynchronisation, simply disconnect.
call-pri-lost-after-sb
Always honour the outcome of the after-sb-0pri
algorithm. In case it decides the current secondary has the right data, call the pri-lost-after-sb on the current primary.
violently-as0p
Always honour the outcome of the after-sb-0pri
algorithm. In case it decides the current secondary has the right data, accept a possible instantaneous change of the primary’s data.
我理解的意思就是 split brain, after - sb (不知道你會(huì)不會(huì)和我的理解一樣……)
這里我解決的辦法是用一個(gè)腳本來(lái)檢測(cè) split brain ,并自動(dòng)判斷同步。
shell.1 發(fā)到啟動(dòng)組里面
#!/bin/sh
PATH=$PATH:/sbin:/usr/sbin:/usr/local/bin
[ -f /proc/drbd ] || exit 1
if ( grep 'Secondary/Unknown' /proc/drbd );then
drbdadm disconnect all
drbdadm -- --discard-my-data connect all
(sleep 1;echo 'drbd';sleep 2;echo 'drbd';sleep 3)|telnet 192.16.1.22
fi
shell.2 由heartbeat執(zhí)行。
#! /bin/bash
#
# chkconfig: 345 15 88
# description: Linux High availability services .
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
# if the ip configuration utility isn't around we can't function.
[ -x /sbin/ip ] || exit 1;[ -f /proc/drbd ] || exit 1
DRBDSTATE=$(drbdadm state all)
while $(grep -E "SyncSource.*Inconsistent" /proc/drbd >/dev/null 2<&
do
sleep 10
done
start () {
sleep 5
ip addr add 192.16.1.20/24 brd 192.16.3.255 dev bond0
/etc/init.d/portmap start
drbdadm primary all
mount -t ext3 -o rw /dev/drbd0 /mnt/disk0
mount -t ext3 -o rw /dev/drbd1 /mnt/disk1
/etc/init.d/nfs start
/etc/init.d/nfslock start
exportfs -avr
return $RETVAL
}
stop () {
ip addr del 192.16.1.20/24 brd 192.16.1.255 dev bond0
/etc/init.d/nfs stop
/etc/init.d/nfslock stop
umount /mnt/disk0
umount /mnt/disk1
drbdadm secondary all
/etc/init.d/portmap stop
if ( grep 'Secondary/Unknown' /proc/drbd );then
exec /etc/rc.d/my-shell.sh;fi
return $RETVAL
}
# See how we were called.
case "$1" in
start|stop)
$1
;;
restart|reload)
/etc/init.d/$0 stop
/etc/init.d/$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
添加用戶 drbd
passwd
drbd:105:105RBD:/home/drbd:/sbin/drbdsh
drbdsh文件
#!/bin/sh
# Variables and Function definition
PATH=$PATH:/sbin:/usr/sbin:/usr/local/bin
#Program Main
[ -f /proc/drbd ] || exit 1
TEMP=$(drbdadm state all)
D_STATE=(${TEMP//\// })
if ( echo ${D_STATE[@]}|grep Primary >/dev/null 2<&- ) && \
( echo ${D_STATE[@]}|grep Unknown >/dev/null 2<&- );then
drbdadm connect all
else exit 1
fi
exit 0
啟動(dòng) telnet
在 hosts.deny 里添加 in.telnet :ALL :ALL EXCEPT 192.16.1.22
這樣就可以保證每次啟動(dòng)后數(shù)據(jù)的同步了。
下面是我的部分配置文件:
drbd.conf
global { usage-count yes; }
common { syncer { rate 10M; } }
resource r0 {
protocol C;
handlers { pri-on-incon-degr "halt -f"; }
disk { on-io-error detach; }
net {
cram-hmac-alg sha1;
shared-secret "800hr_disk_0";
}
on test01 {
device /dev/drbd0;
disk /dev/sda6;
address 192.16.1.21:7789;
meta-disk internal;
}
on test02 {
device /dev/drbd0;
disk /dev/sda6;
address 192.16.1.22:7789;
meta-disk internal;
}
}
Found ext3 filesystem which uses 2048256 kB
current configuration leaves usable 2048156 kB
Device size would be truncated, which
would corrupt data and result in
'access beyond end of device' errors.
You need to either
* use external meta data (recommended)
* shrink that filesystem first
* zero out the device (destroy the filesystem)
Operation refused.