SETTING UP DRBD

tested on Slackware64 14.2

BLOCK DEVICE ARCHITECTURE

three nodes, on which we are going to use 10G partitions.

dark1 -- dark2 -- dark3
sda2     sda2     sda2
sda3     sda3     sda3
sda4     sda4     sda4

and those will be setup as such,

dark1:sda2 + dark2:sda3 --> drbd1
dark2:sda2 + dark3:sda3 --> drbd2
dark3:sda2 + dark1:sda3 --> drbd3

BLOCK DEVICE SETUP

all nodes

cfdisk /dev/sda

then create sda2,3 e.g. 10G each.

slackpkg install parted #slackware64
partprobe
ls -l /dev/sda2
ls -l /dev/sda3
ls -l /dev/sda4

SYSPREP

fix locales for Perl not to complain when running /usr/sbin/drbd-overview.

cat >> /etc/profile.d/lang.sh <<-EOF
export LC_ALL=C
export LANGUAGE="en_US:en"
EOF
. /etc/profile.d/lang.sh

DRBD BUILD & INSTALL

on the build system

git clone https://github.com/LINBIT/drbd-9.0.git
cd drbd-9.0/
ls -l /lib/modules/`uname -r`/build
time make -j16 > make.log
cd ../

git clone --recursive https://github.com/LINBIT/drbd-utils
cd drbd-utils/
./autogen.sh 
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
time make -j16 > make.log
cd ../

deploy on other nodes

slackpkg install gc #slackware64
slackpkg install libffi #slackware64
cd /data/host/drbd-9.0
make install
ls -l /lib/modules/`uname -r`/updates/

cd /data/host/drbd-utils/
make install
ls -l /etc/rc.d/init.d/drbd 

and check,

find /lib/modules/4.19.0-rc7.slackxenreiser4+ | grep drbd

DRBD SETUP

all nodes

rm -rf /etc/drbd.d/
rm -f /etc/drbd.conf

dark3

cat > drbd.conf <<-EOF
global {
        usage-count yes;
        udev-always-use-vnr;
}

common {
        net {
                protocol C;
                fencing resource-only;
                allow-two-primaries yes;
        }
}

resource r1 {
        device    /dev/drbd1;
        meta-disk internal;

        on dark1 {
                disk      /dev/sda2;
                address   10.8.8.21:7701;
        }
        on dark2 {
                disk      /dev/sda3;
                address   10.8.8.22:7701;
        }
}

resource r2 {
        device    /dev/drbd2;
        meta-disk internal;

        on dark2 {
                disk      /dev/sda2;
                address   10.8.8.22:7702;
        }
        on dark3 {
                disk      /dev/sda3;
                address   10.8.8.23:7702;
        }
}

resource r3 {
        device    /dev/drbd3;
        meta-disk internal;

        on dark3 {
                disk      /dev/sda2;
                address   10.8.8.23:7703;
        }
        on dark1 {
                disk      /dev/sda3;
                address   10.8.8.21:7703;
        }
}
EOF

scp /etc/drbd.conf dark2:/etc/
scp /etc/drbd.conf dark1:/etc/

FIRST SHOT

all nodes

/bin/lsmod | grep drbd
/sbin/modprobe drbd
/sbin/modprobe drbd_transport_tcp

drbdadm create-md all
#drbdadm down all
drbdadm up all

dark1

ls -l /dev/drbd1
ls -l /dev/drbd3
drbdadm status
drbdadm primary --force r1
drbdadm primary r3

dark2

ls -l /dev/drbd1
ls -l /dev/drbd2
drbdadm status
drbdadm primary --force r2
drbdadm primary r1

dark3

ls -l /dev/drbd2
ls -l /dev/drbd3
drbdadm status
drbdadm primary --force r3
drbdadm primary r2

on some node e.g. dark1

see the difference in size,

fdisk -l /dev/sda2
fdisk -l /dev/drbd1

on a 10GB partition as sda2, it takes 364544 bytes difference.

OPERATIONS

MODULE VERSION,

cat /proc/drbd

TOOLS VERSION,

/usr/sbin/drbdadm | grep -A1 ^Version

STOP,

#/usr/sbin/drbdadm down r1
/usr/sbin/drbdadm down all

START,

#/usr/sbin/drbdadm up r1
/usr/sbin/drbdadm up all

dark1

drbdadm primary r1
drbdadm primary r3

dark2

drbdadm primary r2
drbdadm primary r1

dark3

drbdadm primary r3
drbdadm primary r2

STATUS,

/bin/lsmod | grep drbd

#/usr/sbin/drbdadm status r1
/usr/sbin/drbdadm status
#/usr/sbin/drbdsetup status

/usr/sbin/drbd-overview

look for on-going synchronizations,

cat /proc/drbd

show resource configuration,

#/usr/sbin/drbdsetup r1 show
/usr/sbin/drbdsetup all show

ENABLE AT STARTUP

cat >> /etc/rc.d/rc.local <<-EOF
/sbin/modprobe drbd
/sbin/modprobe drbd_transport_tcp
/bin/lsmod | grep drbd
/usr/sbin/drbdadm up all
/usr/sbin/drbdadm status
EOF
ln -s rc.d/rc.local /etc/rc.local

MONITORING

output something only if there is a problem to report,

mkdir -p /root/bin/
vi /root/bin/check.drbd.ksh

#!/bin/ksh
tmp=`/usr/sbin/drbdadm status | grep '^  disk:' | grep -v '^  disk:UpToDate$'`
[[ -n $tmp ]] && /usr/sbin/drbdadm status
unset tmp

chmod +x /root/bin/check.drbd.ksh

test,

/root/bin/check.drbd.ksh

and enable,

crontab -e

*/5 * * * * /root/bin/check.drbd.ksh

…assuming you got /etc/aliases alright.

TODO

does net {fencing resource-only;} does anything if I do not set handler { fence-peer somecommand; } ?

RESOURCES