这篇文章其实是对《构建高可用Linux服务器(第二版)》中第五章中“生产下的高可用NFS文件服务器”一节的补充,其实像drbd和heartbeat这些软件都是可以通过yum来自动安装的,例如安装drbd的命令如下:
- yum -y install drbd83 kmod-drbd83
DRBD的配置文件/etc/drbd.conf如下所示:
- global {
- # minor-count dialog-refresh disable-ip-verification
- usage-count no; #统计drbd的使用
- }
- common {
- syncer { rate 100M; } #同步速率,视带宽而定
- }
- resource r0 { #创建一个资源,名字叫”r0”
- protocol C; #选择的是drbd的C 协议(数据同步协议,C为收到数据并写入后返回,确认成功)
- handlers { #默认drbd的库文件
- 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
- wfc-timeout 120;
- degr-wfc-timeout 120;
- }
- disk {
- # on-io-error fencing use-bmbv no-disk-barrier no-disk-flushes
- # no-disk-drain no-md-flushes max-bio-bvecs
- on-io-error detach;
- }
- 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
- max-buffers 2048;
- cram-hmac-alg "sha1";
- shared-secret "123456";
- #allow-two-primaries;
- }
- syncer {
- rate 100M;
- # rate after al-extents use-rle cpu-mask verify-alg csums-alg
- }
- on centos1.cn7788.com { #设定一个节点,分别以各自的主机名命名
- device /dev/drbd0; #设定资源设备/dev/drbd0 指向实际的物理分区 /dev/sdb1
- disk /dev/sdb;
- address 192.168.11.32:7788; #设定监听地址以及端口
- meta-disk internal;
- }
- on centos2.cn7788.com { #设定一个节点,分别以各自的主机名命名
- device /dev/drbd0; #设定资源设备/dev/drbd0 指向实际的物理分区 /dev/sdb1
- disk /dev/sdb;
- address 192.168.11.33:7788; #设定监听地址以及端口
- meta-disk internal;
- }
- }
- logfile /var/log/ha-log
- logfacility local0
- keepalive 2
- deadtime 5
- ucast eth0 192.168.11.32
- ucast eth1 10.0.0.2
- auto_failback off
- node centos1.cn7788.com centos2.cn7788.com
本文出自 “抚琴煮酒” 博客,请务必保留此出处http://andrewyu.blog.51cto.com/1604432/976135