1、涉及机器
192.168.60.11 node1.ha.com
192.168.60.12 node2.ha.com
2、新增硬盘用于DRBD
ls /sys/class/scsi_host/
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
3、安装配置DRBD
wget ftp://rpmfind.net/linux/atrpms/el6-x86_64/atrpms/stable/drbd-8.4.3-33.el6.x86_64.rpm
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
4、初始化资源并启动服务、查看状态(所有节点都要执行)
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
5、在主节点上创建文件系统并挂载
mke2fs -t ext4 /dev/drbd0
mount /dev/drbd0 /mnt
cd /mnt/
cp /etc/fstab /mnt/
6、主备切换
需要先将主的切换到备的,才能将原来备的切换到主的
主的切换到备的
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
转载于:https://blog.51cto.com/kaiyuandiantang/2343232