cmdref.net - Cheat Sheet and Example

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

User Tools

Site Tools


Sidebar








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

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



Middleware




middleware/storage/drbd.txt · Last modified: 2020/03/13 by admin

Page Tools