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