Distributed Replicated Block Device (DRBD) is a free, open-source software that allows two servers to share storage in real-time mode over a network. It can be used to build highly available (HA) clusters or redundant storage solutions.
However, installing DRBD can vary depending on the operating system you are using, and in this tutorial, we’ll walk you through the steps to install DRBD on the latest nixOS using the official DRBD site.
Before installing DRBD on nixOS, you need the following:
First, you will need to download and install DRBD packages from the official DRBD site. You can do this by following the steps below:
$ sudo su
# curl -sSL https://www.linbit.com/downloads/drbd/repo/rpm/drbd.repo | tee /etc/yum.repos.d/drbd.repo
# rpm --import https://www.linbit.com/downloads/drbd/linbit-167F52CB.asc
# yum install -y epel-release
# yum install -y kmod-drbd82 drbd82 drbd82-utils net-tools
These commands will add the DRBD repository to your server and install the DRBD packages.
Once DRBD is installed, you will need to modify some configuration files to complete the setup. Follow the steps below:
# vi /etc/drbd.conf
global {
usage-count no;
}
common {
syncer {
verify-alg sha1;
rate 5M;
}
}
resource r0 {
device /dev/drbd0;
meta-disk internal;
on node1 {
address 192.168.1.1:7789;
disk /dev/sdb;
}
on node2 {
address 192.168.1.2:7789;
disk /dev/sdb;
}
}
The configuration file above specifies the following:
r0
./dev/sdb
.5M
.Make sure to replace the IP addresses in the configuration file with the ones that correspond to your servers.
Now that you have configured DRBD, you will need to initialize it.
# systemctl start drbd
# drbdadm create-md r0
# drbdadm up r0
# drbdadm status r0
If everything is working correctly, you should see a status message indicating that DRBD is running.
At this point, DRBD is ready to use. However, you should test the functionality to ensure that it works correctly.
# echo "Hello World" > /mnt/drbd/file.txt
# cat /mnt/drbd/file.txt
# drbdadm primary r0 --force
# cat /mnt/drbd/file.txt
If the file exists on both nodes, then DRBD is set up correctly and is working correctly.
Now you have DRBD installed and configured on the latest nixOS, you can use it to build highly available clusters or redundant storage solutions. Before using DRBD in production, make sure to test it thoroughly to ensure that it works correctly.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!