http://docs.linbit.com/docs/users-guide-9.0/#ch-pacemakernode
安装说明:
- RHEL 7.4 (crhel71,crhel72)
- drbd 9.0.9-1
- 2台相同配置服务器,硬盘数量、大小相同
- 设定两节点间 ssh 免密登陆
- 使用/etc/hosts 或者DNS,让两个节点能互相解析
- 设定 YUM repo, 指向到清华大学开源镜像服务器( https://mirrors.tuna.tsinghua.edu.cn/elrepo/elrepo/el7/x86_64 )
- 上述条件知足后,一条命令就完成安装
# yum -y install drbd90-utils kmod-drbd90服务器
下面主要讲解具体设定:ssh
1. /etc/drbd.conf文件无需该动ide
2. /etc/drbd.d/global_common.conf,在common配置部分的net选项中添加protocol C;,表示使用协议C的方式进行数据复制
# sed -i "55a\ protocol C;" /etc/drbd.d/global_common.conf测试
# cat /etc/drbd.d/global_common.conf
...
common {
net {protocol C;}
}ui
3.该文件用于定义drbd镜像资源
# cat <<EOF> /etc/drbd.d/r0.res
resource r0 {
protocol C;
disk /dev/sdb;
device /dev/drbd0;
meta-disk internal;this
syncer {
verify-alg sha1;
}
net {
allow-two-primaries;
}资源
on crhel71 {
address 10.247.15.78:7789;
}
on crhel72 {
address 10.247.15.76:7789;
}get
disk {
resync-rate 100M;
c-min-rate 10;
c-max-rate 400M;
}
}
EOF同步
4. 对节点的drbd操做, 在两个节点上都执行:
Now that we have the configuration in place, it’s time to initialize our data:
At this point, we’re ready to start DRBD on both nodes and bring the r0 resource up. After bringing the resource up, let’s check the status:
[root@crhel71 ~]# drbdadm up r0
initializing activity log
initializing bitmap (672 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
[root@crhel71 ~]# drbdadm status
r0 role:Secondary
disk:Inconsistent
crhel72 role:Secondary
peer-disk:Inconsistent
[root@crhel72 ~]# drbdadm up r0
[root@crhel72 ~]# drbdadm status
r0 role:Secondary
disk:Inconsistent
crhel71 role:Secondary
peer-disk:Inconsistent
5. 选定primary node, 并同步数据
>>在全部节点中, 选定1台做为primary node,执行下面命令,数据同步开始进行;让子弹飞一会,进度使用下面命令查询
[root@crhel71 ~]# drbdadm primary --force r0
[root@crhel71 ~]# drbdadm status
r0 role:Primary
disk:UpToDate
crhel72 role:Secondary
replication:SyncSource peer-disk:Inconsistent done:15.21
[root@crhel72 ~]# drbdadm status
r0 role:Secondary
disk:Inconsistent
crhel71 role:Primary
replication:SyncTarget peer-disk:UpToDate done:20.35
>>几分钟后,在各节点上查询状态,看到已经同步完成:
[root@crhel71 ~]# drbdadm status
r0 role:Primary
disk:UpToDate
crhel72 role:Secondary
peer-disk:UpToDate
[root@crhel72 ~]# drbdadm status
r0 role:Secondary
disk:UpToDate
crhel71 role:Primary
peer-disk:UpToDate
6. 创建文件系统(do this on primary node)
[root@crhel71 ~]# mkfs.xfs /dev/drbd0
7. 测试drbd镜像
[root@crhel71 ~]# mount /dev/drbd0 /mnt/
[root@crhel71 ~]# touch /mnt/file{1..5}
[root@crhel71 ~]# drbd-overview
...
0:r0/0 Connected(2*) Primar/Second UpToDa/UpToDa /mnt xfs 21G 33M 21G 1%
[root@crhel71 ~]# umount /mnt
[root@crhel71 ~]# drbdadm secondary r0
[root@crhel72 ~]# drbdadm primary r0 [root@crhel72 ~]# mount /dev/drbd0 /mnt/ [root@crhel72 mnt]# ls file1 file2 file3 file4 file5