Raspberry Pi DRBD Cluster – all you need is two Raspberry Pi and two USB memory sticks

drbd_logo.jpg   DRBD (Distributed Replicated Block Device) is a data replication software for Linux. It presents as a block-device to the user. DRBD is similiar to a RAID 1 except that it runs over a network between two Servers for data replication at least GBit Ethernet should be used

DRBD_01DRBD_02

# apt-get -y install drbd8-utils
# echo drbd >>/etc/modules
# modprobe drbd
# vi /etc/drbd.conf
global { usage-count yes; }
resource r0 { protocol C;
syncer { rate 10M; }
net { allow-two-primaries; }
startup { become-primary-on both; }
on JSHODRBD01 {
device /dev/drbd0;
disk /dev/sda;
address 192.168.1.91:7791;
meta-disk  internal;
}
on JSHODRBD02 {
device /dev/drbd0;
disk /dev/sda;
address 192.168.1.92:7791;
meta-disk internal;
}
}
# /etc/init.d/drbd restart
# drbdadm down r0
# drbdadm create-md r0
# ### only on the primary node
# drbdsetup /dev/drbd0 primary –overwrite-data-of-peer
# /etc/init.d/drbd status
# cat /proc/drbd
# ### mount the primary node
# mkfs.ext4 /dev/drbd0
# mkdir /u0_drbd0
# mount /dev/drbd0 /u0_drbd0
# ### change the primary node
# umount /u0_drbd0
# drbdadm −− secondary r0
# ### make the secondary node to the primary node
# drbdadm −− primary r0
# mkdir /u0_drbd0
# mount /dev/drbd0 /u0_drbd0
# ### how to fix DRBD recovery from split brain
# ### Step 1: Start drbd manually on both nodes
# ### Step 2: Define one node as secondary and discard data on this
# drbdadm secondary all
# drbdadm disconnect all
# drbdadm −− −−discard-my-data connect all
 
# ### Step 3: Define another node as primary and connect
# drbdadm primary all
# drbdadm disconnect all
# drbdadm connect all

Leave a Reply

You must be logged in to post a comment.