2. 安装:
3. 配置:
# 使用C语法,include其它模块配置
vim /etc/drbd.conf
include "drbd.d/global_common.conf";
include "drbd.d/*.res";
# global和common模块设置全局、公用参数
# common模块可以设置许多子模块,主要有net和syncer
vim /etc/drbd.d/global_common.conf
global {
# 是否参加DRBD使用者统计
usage-count yes;
# minor-count dialog-refresh disable-ip-verification
}
common {
# C协议表示收到远程主机的写入确认之后才返回
protocol C;
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 "FooFunFactory";
}
syncer {
# rate after al-extents use-rle cpu-mask verify-alg csums-alg
# 设置主从节点同步时的最大网络速率,单位是字节
rate 1M;
}
}
# 一个DRBD设备(即:/dev/drbdX)称为一个"资源"(resource)
# resource模块中设置了主从节点中的相关信息
vim /etc/drbd.d/r0.res
# please have a a look at the example configuration file in
# /usr/share/doc/drbd83/drbd.conf
resource r0 {
# 每个主机以on开头,后面是主机名,{}中是其相关设置
on staging-012.test.com {
# /dev/drbd1使用的磁盘分区是/dev/ram0
device /dev/drbd1;
disk /dev/ram0;
# DRBD的监听端口,与远程节点通信
address 10.64.197.121:7788;
meta-disk internal;
}
on staging-013.test.com {
device /dev/drbd1;
disk /dev/ram0;
address 10.64.197.122:7788;
meta-disk internal;
}
}
最后,将配置文件拷贝到主从节点上各一份。
4. 启动:
5. 使用:
6. 主从节点切换: