DRBD : Install |
Install DRBD (Distributed Replicated Block Device) to configure Distributed Storage System. +----------------------+ | +----------------------+ | [ DRBD Server#1 ] |10.0.0.51 | 10.0.0.52| [ DRBD Server#2 ] | | node01.srv.world +----------+----------+ node02.srv.world | | | | | +----------------------+ +----------------------+ It needs that the server you'd like to install DRBD has free block-device. | |
| [1] | Install and Configure DRBD on all Nodes. |
root@node01:~# apt -y install drbd-utils root@node01:~# vi /etc/drbd.d/r0.res # create new : file name ⇒ (resource name).res resource r0 {
net {
# A : write completion is determined when data is written to the local disk and the local TCP transmission buffer
# B : write completion is determined when data is written to the local disk and remote buffer cache
# C : write completion is determined when data is written to both the local disk and the remote disk
protocol C;
cram-hmac-alg sha1;
# any secret key for authentication among nodes
shared-secret "MySharedSecret";
}
disk {
# possible to limit bandwidth for sync (example is 10MB/sec)
resync-rate 10M;
}
# on (hostname)
on node01.srv.world {
address 10.0.0.51:7788;
volume 0 {
# device name
device /dev/drbd0;
# specify disk to be used for devide above
disk /dev/sdb1;
# where to create metadata
# specify the block device name when using a different disk
meta-disk internal;
}
}
on node02.srv.world {
address 10.0.0.52:7788;
volume 0 {
device /dev/drbd0;
disk /dev/sdb1;
meta-disk internal;
}
}
}
# load module root@node01:~# modprobe drbd root@node01:~# drbd 487424 0 lru_cache 16384 1 drbd libcrc32c 12288 1 drbd # create DRBD resource root@node01:~# drbdadm create-md r0 initializing activity log initializing bitmap (2560 KB) to all zero Writing meta data... New drbd meta data block successfully created.root@node01:~# systemctl enable --now 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 (api:1/proto:86-101)
srcversion: 900745622289D38C0BAB129
0: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-----
ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:83882460
# UP DRBD resource root@node01:~# drbdadm up r0 # get primary role and sync data root@node01:~# drbdadm -- --overwrite-data-of-peer primary r0 # data sync starts root@node01:~# cat /proc/drbd version: 8.4.11 (api:1/proto:86-101)
srcversion: 900745622289D38C0BAB129
0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----
ns:4216536 nr:0 dw:0 dr:4216536 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:79665924
[>...................] sync'ed: 5.1% (77796/81916)M
finish: 0:35:43 speed: 37,152 (34,004) K/sec
# when the sync is complete, the status will be as follows root@node01:~# cat /proc/drbd version: 8.4.11 (api:1/proto:86-101)
srcversion: 900745622289D38C0BAB129
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:83882460 nr:0 dw:0 dr:83882460 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
|
| [3] | That's OK. After that, you can use it by creating a file system on the DRBD device and mounting it on the primary side. |
| root@node01:~# mkfs.ext4 /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 udev devtmpfs 1.9G 0 1.9G 0% /dev tmpfs tmpfs 392M 560K 392M 1% /run /dev/mapper/debian--vg-root ext4 27G 955M 25G 4% / tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 1.0M 0 1.0M 0% /run/credentials/systemd-journald.service tmpfs tmpfs 2.0G 0 2.0G 0% /tmp /dev/vda1 ext4 943M 74M 804M 9% /boot tmpfs tmpfs 1.0M 0 1.0M 0% /run/credentials/getty@tty1.service tmpfs tmpfs 1.0M 0 1.0M 0% /run/credentials/serial-getty@ttyS0.service tmpfs tmpfs 392M 4.0K 392M 1% /run/user/0 /dev/drbd0 ext4 79G 2.1M 75G 1% /drbd_disk # create a test file root@node01:~# echo 'test file' > /drbd_disk/test.txt root@node01:~# ll /drbd_disk total 20 drwx------ 2 root root 16384 Aug 20 12:25 lost+found -rw-r--r-- 1 root root 10 Aug 20 12:26 test.txt |
| [4] | To mount DRBD device on the secondary Host, do it like follows. |
# on primary host # unmount drbd device and set secondary root@node01:~# umount /drbd_disk root@node01:~# drbdadm secondary r0 # on secondary host # set primary and mount drbd device root@node02:~# drbdadm primary r0 root@node02:~# mount /dev/drbd0 /drbd_disk root@node02:~# df -hT Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 1.9G 0 1.9G 0% /dev tmpfs tmpfs 392M 560K 392M 1% /run /dev/mapper/debian--vg-root ext4 27G 955M 25G 4% / tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 1.0M 0 1.0M 0% /run/credentials/systemd-journald.service tmpfs tmpfs 2.0G 0 2.0G 0% /tmp /dev/vda1 ext4 943M 74M 804M 9% /boot tmpfs tmpfs 1.0M 0 1.0M 0% /run/credentials/getty@tty1.service tmpfs tmpfs 1.0M 0 1.0M 0% /run/credentials/serial-getty@ttyS0.service tmpfs tmpfs 392M 4.0K 392M 1% /run/user/0 /dev/drbd0 ext4 79G 2.1M 75G 1% /drbd_diskroot@node02:~# cat /drbd_disk/test.txt test file |
No comments:
Post a Comment