DRBD(Distributed Replicated Block Device)
Operation | Commands |
---|---|
Start DRBD Service | systemctl start drbd |
Stop DRBD Service | systemctl stop drbd |
Check drbd | drbdadm state all |
Check drbd | drbdadm cstate all |
Check DRBD Resource status | drbdadm status r0 |
Stop DRBD Resource | drbdadm down r0 |
Start DRBD Resource | drbdadm up r0 |
Change primary on tis host | drbdadm primary r0 |
Change secondary on tis host | drbdadm Secondary r0 |
resource r0 { protocol C; disk /dev/sdb1; device /dev/drbd0; meta-disk internal; on server1 { address 192.168.1.11:7789; } on server2 { address 192.168.1.12:7789; } }
H1/H2 # lsblk or H1/H2 # fdisk -l
H1/H2 # fdisk /dev/sdb n p <- primary Enter <- Partition No.1 Enter <- Start Sector Enter <- Last Sector p w
H1/H2 # dd if=/dev/zero of=/dev/sdb1 bs=1M count=1
H1/H2 # drbdadm create-md r0
H1/H2 # systemctl start drbd H1/H2 # drbdadm status r0
H1 # drbdadm --overwrite-data-of-peer primary r0 H1 # drbdadm status r0 H2 # drbdadm status r0
mkfs -t xfs /dev/drbd0
H1 # cat /proc/drbd H2 # cat /proc/drbd H2 # drbdadm secondary r0 <--- change secondary H2 # drbdadm connect --discard-my-data r0 H1 # drbdconnect r0 H1 # cat /proc/drbd H2 # cat /proc/drbd
H1 # cat /proc/drbd H2 # cat /proc/drbd H2 # drbdadm disconnect all H2 # drbdadm -- --discard-my-data connect all H1 # drbdadm connect all <- resync H1 # cat /proc/drbd H2 # cat /proc/drbd
Resynchronize when DRBD status is StandAlone
H1 # cat /proc/drbd H2 # cat /proc/drbd H2 # drbdadm down all H2 # drbdadm attach all H2 # drbdadm invalidate all H2 # drbdadm up all H2 # drbdadm connect all H1 # drbdadm cstate all StandAlone H1 # drbdadm connect all <- resync H1 # drbdadm cstate all SyncSource H2 # drbdadm cstate all SyncTarget H1 # cat /proc/drbd H2 # cat /proc/drbd
H1 # mount /dev/drbd0 /mnt/drbd H1 # echo test > /mnt/drbd/test.txt H1 # umount /dev/drbd0 H1 # drbdadm secondary drbd0 H2 # drbdadm primary drbd0 H2 # mount /dev/drbd0 /mnt/drbd H2 # ls /mnt/drbd lost+found test.txt H2 # cat /mnt/drbd/test.txt test H2 # umount /dev/drbd0 H2 # drbdadm secondary drbd0
H1/H2 # lvextend -L +1G /dev/vg01/xxxx H1 # drbdadm resize r0 H1 # cat /proc/drbd ### After synchronization is complete H2 # cat /proc/drbd H2 # drbdadm resize r0 H1 # resize2fs /dev/drbd0