DRBD
分布式复制块设备
drbd83.x86_64 8.3.15-2.el5.centos extras
kmod-drbd83.x86_64 8.3.15-3.el5.centos extras
yum -y install drbd83.x86_64 kmod-drbd83.x86_64
1.同步时间
2.主机名
3.ssh互信
yum -y install drbd83.x86_64 kmod-drbd83.x86_64
2台机器新增硬盘分区(重点是都不要格式化)
cp /usr/share/doc/drbd83-8.3.15/drbd.conf /etc/
vim /etc/drbd.conf
vim /etc/drbd.d/global_common.conf
cd /etc/drbd.d/
vim web.res
scp -r /etc/drbd.* node2:/etc/
drbdadm create-md mydrby
/etc/init.d/drbd start
cat /proc/drbd
drbd-overview
mkfs.ext3 /dev/drbd0
mkdir /mydata
mount /dev/drbd0 /mydata
umount /mydata/
drbdadm secondary mydrby
[root@node2 ~]# cat /etc/drbd.conf
# You can find an example in /usr/share/doc/drbd.../drbd.conf.example
include "drbd.d/global_common.conf";
include "drbd.d/*.res";
[root@node2 ~]# cat /etc/drbd.d/global_common.conf
global {
usage-count yes;
# minor-count dialog-refresh disable-ip-verification
}
common {
protocol C;
handlers {
# These are EXAMPLE handlers only.
# They may have severe implications,
# like hard resetting the node under certain circumstances.
# Be careful when chosing your poison.
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";
# fence-peer "/usr/lib/drbd/crm-fence-peer.sh";
# split-brain "/usr/lib/drbd/notify-split-brain.sh root";
# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";
# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";
# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
}
startup {
# wfc-timeout degr-wfc-timeout outdated-wfc-timeout wait-after-sb
}
disk {
on-io-error detach;
# no-disk-drain no-md-flushes max-bio-bvecs
}
net {
# sndbuf-size rcvbuf-size timeout connect-int ping-int ping-timeout max-buffers
# max-epoch-size ko-count allow-two-primaries cram-hmac-alg shared-secret
# after-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork
cram-hmac-alg "sha1";
shared-secret "abcdefg";
}
syncer {
rate 100M;
# rate after al-extents use-rle cpu-mask verify-alg csums-alg
}
}
[root@node2 ~]#
或者
[root@node2 ~]# egrep -v "^$|#" /etc/drbd.d/global_common.conf
global {
usage-count yes;
}
common {
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-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f";
}
startup {
}
disk {
on-io-error detach;
}
net {
cram-hmac-alg "sha1";
shared-secret "abcdefg";
}
syncer {
rate 100M;
}
}
[root@node2 ~]#
[root@node2 ~]# egrep -v "^$|#" /etc/drbd.d/web.res
resource mydrby{
device /dev/drbd0;
disk /dev/sdb5;
meta-disk internal;
on node1.test.com{
address 10.10.10.21:7789;
}
on node2.test.com{
address 10.10.10.22:7789;
}
}
本文出自 “醉寒江” 博客,请务必保留此出处http://cjlozbg.blog.51cto.com/3513565/1733590
原文:http://cjlozbg.blog.51cto.com/3513565/1733590