一、涉及機器node
192.168.60.11 node1.ha.comlinux
192.168.60.12 node2.ha.comweb
二、新增硬盤用於DRBDide
ls /sys/class/scsi_host/spa
echo "- - -" > /sys/class/scsi_host/host0/scan.net
echo "- - -" > /sys/class/scsi_host/host1/scan資源
echo "- - -" > /sys/class/scsi_host/host2/scanget
三、安裝配置DRBDit
wget ftp://rpmfind.net/linux/atrpms/el6-x86_64/atrpms/stable/drbd-8.4.3-33.el6.x86_64.rpmio
wget ftp://rpmfind.net/linux/atrpms/el6-x86_64/atrpms/stable/drbd-kmdl-2.6.32-431.el6-8.4.3-33.el6.x86_64.rpm
rpm -ivh drbd-8.4.3-33.el6.x86_64.rpm drbd-kmdl-2.6.32-431.el6-8.4.3-33.el6.x86_64.rpm
grep -v ^# /etc/drbd.d/global_common.conf | grep -v .*#
global {
usage-count no;
}
common {
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-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";
}
startup {
}
options {
}
disk {
on-io-error detach;
}
net {
protocol C;
cram-hmac-alg "sha1";
shared-secret "drbdsecret";
}
syncer {
rate 1000M;
}
}
cat /etc/drbd.d/web.res
resource web {
on node1.ha.com {
device /dev/drbd0;
disk /dev/sdb;
address 192.168.60.11:7789;
meta-disk internal;
}
on node2.ha.com {
device /dev/drbd0;
disk /dev/sdb;
address 192.168.60.12:7789;
meta-disk internal;
}
}
cd /etc/drbd.d/
scp global_common.conf web.res root@node2.ha.com:/etc/drbd.d
四、初始化資源並啓動服務、查看狀態(全部節點都要執行)
drbdadm create-md web
/etc/init.d/drbd start
drbd-overview(cat /proc/drbd)
drbdadm primary --force web
drbd-overview
0:web/0 SyncSource Primary/Secondary UpToDate/Inconsistent C r---n-
[>....................] sync'ed: 4.6% (4888/5116)M
五、在主節點上建立文件系統並掛載
mke2fs -t ext4 /dev/drbd0
mount /dev/drbd0 /mnt
cd /mnt/
cp /etc/fstab /mnt/
六、主備切換
須要先將主的切換到備的,才能將原來備的切換到主的
主的切換到備的
umount /mnt
drbdadm secondary web
drbd-overview
備的切換到主的
drbdadm primary web
drbd-overview
mount /dev/drbd0 /mnt/
ls /mnt
umount /mnt
drbdadm secondary web
chkconfig drbd off
service drbd stop