cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:storage:drbd



Middleware

DRBD CLI Commands Cheet Sheat & Configurations

About DRBD

DRBD(Distributed Replicated Block Device)


How to use DRBD

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


Configuration

/etc/drbd.d/r0.res
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;
        }
}
/etc/drbd.d/global_common.conf


How to create DRBD Disk

H1/H2 # lsblk
or
H1/H2 # fdisk -l

Create Partition and Initialize the beginning to 0

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


Initialize DRBD area

H1/H2 # drbdadm create-md r0


Enable resources

H1/H2 # systemctl start drbd
H1/H2 # drbdadm status r0


Initial synchronization

H1 # drbdadm --overwrite-data-of-peer primary r0

H1 # drbdadm status r0
H2 # drbdadm status r0


Creating a file system

mkfs -t xfs  /dev/drbd0




Operation

DRBD resync at high speed (r0)

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


DRBD resync at high speed (all)

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


DRBD Full resync

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


Switching between active and standby

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


Expand Disk

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 



Middleware




middleware/storage/drbd.txt · Last modified: 2020/06/01 by admin

Page Tools