DRBD 8 : Configure2016/01/27 |
Configure DRBD after installing.
This example is based on the environment like follows. +----------------------+ | +----------------------+ | [ DRBD Server#1 ] |10.0.0.51 | 10.0.0.52| [ DRBD Server#2 ] | | node01.srv.world +----------+----------+ node02.srv.world | | | | | +----------------------+ +----------------------+
It's necessarry the server you'd like to install DRBD has free block-device.
This example shows to configure to use a device [/dev/vg_r0/lv_r0].
|
|
[1] | Configure like follows on all Nodes. |
[root@node01 ~]#
vi /etc/drbd.d/global_common.conf # add follows in the disk section (detach disk if IO errors happen) disk {
on-io-error detach;
[root@node01 ~]#
vi /etc/drbd.d/r0.res # create new resource r0 { # DRBD device device /dev/drbd0; # block device disk /dev/vg_r0/lv_r0; meta-disk internal; on node01.srv.world { # IP-address:port address 10.0.0.51:7788; } on node02.srv.world { address 10.0.0.52:7788; } } # load module [root@node01 ~]# modprobe drbd [root@node01 ~]# drbd 405309 0 libcrc32c 12644 2 xfs,drbd # create DRBD resource [root@node01 ~]# drbdadm create-md r0 --== Thank you for participating in the global usage survey ==-- The server's response is: you are the 2056th user to install this version md_offset 85895147520 al_offset 85895114752 bm_offset 85892493312 Found some data ==> This might destroy existing data! <== Do you want to proceed? [need to type 'yes' to confirm] yes initializing activity log initializing bitmap (2560 KB) to all zero Writing meta data... New drbd meta data block successfully created. success[root@node01 ~]# systemctl start drbd [root@node01 ~]# systemctl enable drbd |
[2] | After configuring on all Nodes, Sync data on a Node. |
# current status is "Secondary/Secondary" [root@node01 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by root@node01.srv.world, 2018-07-12 19:28:32 0: cs:Connected ro:Secondary/Secondary ds:Diskless/Inconsistent C r----- ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:0 # UP DRBD resource [root@node01 ~]# drbdadm up r0
# get primary role and sync data [root@node01 ~]# drbdadm -- --overwrite-data-of-peer primary r0
# sync starts [root@node01 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by root@node01.srv.world, 2018-07-12 19:28:32 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r----- ns:1047352 nr:0 dw:0 dr:1049480 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:82832036 [>....................] sync'ed: 1.3% (80888/81912)M finish: 0:56:34 speed: 24,392 (15,868) K/sec # after syncing, the status turns like follows [root@node01 ~]# cat /proc/drbd version: 8.4.11-1 (api:1/proto:86-101) GIT-hash: 66145a308421e9c124ec391a7848ac20203bb03c build by root@node01.srv.world, 2018-07-12 19:28:32 0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r----- ns:83879388 nr:0 dw:0 dr:83881516 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0 |
[3] | It's OK to configure DRBD, create file system on DRBD device and mount it to use. |
[root@node01 ~]# mkfs.xfs /dev/drbd0 [root@node01 ~]# mkdir /drbd_disk [root@node01 ~]# mount /dev/drbd0 /drbd_disk [root@node01 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cl-root xfs 26G 1.7G 25G 7% / devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 2.0G 8.5M 2.0G 1% /run tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/vda1 xfs 1014M 238M 777M 24% /boot tmpfs tmpfs 396M 0 396M 0% /run/user/0 /dev/drbd0 xfs 80G 33M 80G 1% /drbd_disk # create a test file [root@node01 ~]# echo 'test file' > /drbd_disk/test.txt [root@node01 ~]# ll /drbd_disk total 4 -rw-r--r--. 1 root root 10 Jul 12 19:52 test.txt |
[4] | To mount DRBD device on the secondary Host, do it like follows. |
########### on primary Node ########### # unmount and get secondary role [root@node01 ~]# umount /drbd_disk [root@node01 ~]# drbdadm secondary r0
########### on secondary Node ########### # get primary role and mount [root@node02 ~]# drbdadm primary r0 [root@node02 ~]# mount /dev/drbd0 /drbd_disk [root@node02 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/cl-root xfs 26G 1.6G 25G 6% / devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 2.0G 8.5M 2.0G 1% /run tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/vda1 xfs 1014M 238M 777M 24% /boot tmpfs tmpfs 396M 0 396M 0% /run/user/0 /dev/drbd0 xfs 80G 33M 80G 1% /drbd_disk[root@node02 ~]# ll /drbd_disk total 4 -rw-r--r--. 1 root root 10 Jul 12 19:52 test.txt |
Sponsored Link |
|