DRBD setup

In this lab, we try to achieve network disk mirroring with DRBD software

Version – drbd-8.0.6 OS – CentOS 4.5

Build drbd RPMs from source tarball

cd /usr/src
tar zxvf drbd-8.0.6.tar.gz
cd drbd-8.0.6
make rpm

RPM installation
cd dist/RPMS/i386/
rpm -ivh drbd-8.0.6-3.i386.rpm
rpm -ivh drbd-debuginfo-8.0.6-3.i386.rpm
rpm -ivh drbd-km-2.6.9_55.EL-8.0.6-3.i386.rpm

Edit /etc/drbd.conf
resource "share1" {
protocol C;

startup {
wfc-timeout 0; ## Infinite!
degr-wfc-timeout 60; ## 2 minutes.
}
disk {
on-io-error detach;
}
net {

}
syncer {

}

on box1.lan {
device /dev/drbd0;
disk /dev/sdd1;
address 192.168.91.2:7789;
meta-disk /dev/sdf1[0];
#meta-disk internal;
}

on box2.lan {
device /dev/drbd0;
disk /dev/sdd1;
address 192.168.91.3:7789;
meta-disk /dev/sdf1[0];
#meta-disk internal;
}
}

resource "share2" {
protocol C;

startup {
wfc-timeout 0; ## Infinite!
degr-wfc-timeout 60; ## 2 minutes.
}
disk {
on-io-error detach;
}
net {

}
syncer {

}


on box1.lan {
device /dev/drbd1;
disk /dev/sde1;
address 192.168.91.2:7790;
meta-disk /dev/sdf1[1];
#meta-disk internal;
}

on box2.lan {
device /dev/drbd1;
disk /dev/sde1;
address 192.168.91.3:7790;
meta-disk /dev/sdf1[1];
#meta-disk internal;
}
}
Note: sdd1, sde1, sdf1 should un-mounted partitions.
Load DRBD module modprobe drbd
Configure DRBD drbdadm -d adjust share1 drbdadm -d adjust share2
drbdadm create-md share1
drbdadm create-md share2

drbdadm adjust share1
drbdadm adjust share2

service drbd restart
At Box1
drbdsetup /dev/drbd0 primary –-overwrite-data-of-peer share1
Check status
cat /proc/drbd
Make filesystem
mkfs -j /dev/drbd0
tune2fs -c -1 -i 0 /dev/drbd0
At Box2
drbdsetup /dev/drbd1 primary -–overwrite-data-of-peer share2
Check status
cat /proc/drbd
Make filesystem
mkfs -j /dev/drbd1
tune2fs -c -1 -i 0 /dev/drbd1
#Testing DRBD
At Box1
mkdir /share1 /share2
mount -o rw /dev/drbd0 /share1
Write test file
echo "This was written on Box1 resource Share1" > /share1/test-share1
At Box2
mkdir /share1 /share2
mount -o rw /dev/drbd1 /share2
Write test file
echo "This was written on Box2 resource Share2" > /share2/test-share2
Unmount share2 at Box2
umount /share2
drbdadm secondary share2
Mount share2 as Primary at Box1
drbdadm primary share2
mount -o rw /dev/drbd1 /share2

cat /share2/test-share2

Comments