Linux – Setting up DRBD with only one node

drbdlinux

I need to migrate an existing storage server running Debian 6, with many TB of data, to a HA setup. I can't simply shut down this server for any prolonged time (HA is required after all).

I plan to migrate this server to a DRBD cluster. I can't buy two new servers for this cluster; I need to reuse the existing server as a member of the cluster for cost reasons. Remember, I can't shut down anything for more than a few minutes at a time.

I have a new server ready, running Debian 8 to be the "master". I'd need to set up a "split brain" cluster using this "master" server; copy all data from the existing old server to the cluster; switch the existing services to the cluster; reconfigure the old server with Debian 8, then add it to the cluster as a "slave", resynchronize data, and at last have a redundant setup.

I've set up the cluster on the new machine, however, how to proceed? I
can't even start the drbd service as the other "node" doesn't even
exist yet…

I'm starting up from a previous drbd configuration that worked fine… with two available nodes.

Any help appreciated.

Best Answer

You can bring DRBD up without a peer and without starting the DRBD service:

# modprobe drbd
# drbdadm create-md <res>
# drbdadm up <res> 
# drbdadm primary <res> --force
-- now you can use /dev/drbdX --

You could use DRBD to replicate from the existing server to the new server by installing DRBD on the existing storage.

If you're data is currently sitting on LVM you can unmount the logical volume, grow the logical volume (don't grow the filesystem) to make room for DRBD's metadata at the end of the device, set the disk option in the DRBD configuration to the logical volume, create the DRBD's metadata, and then force it to become Primary (with or without a peer). The rule of thumb for how much room DRBD needs for metadata is 32MB per 1TB of data. It would look something like this (assuming a 1TB LV):

# umount /dev/vg_name/lv_name
# lvextend -L +32M /dev/vg_name/lv_name
# drbdadm create-md <res>
-- will warn you if it finds existing data at the end of the device --
# drbdadm up <res> 
# drbdadm primary <res> --force

If you're not using LVM, you'd need to either shrink the filesystem to make room for DRBD's metadata, or use external metadata (described in the user's guide: https://www.drbd.org/en/doc/users-guide-84/ch-internals#s-metadata).

Once you bring DRBD up on the new server, it should start syncing your data. Just make sure the new server's backing disk is equal or larger in size.

Related Topic