How to Setup DRBD to Replicate Storage on Two CentOS 7 Servers

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

13 Responses

  1. Eric Evans says:

    I finally got drbd to work. The sync will take a while but hopefully when done I can add some data and test. I want this to be a fail over KVM hypervisor. I’m not sure if it will work with an existing partition. I don’t believe it will. It should be a “fresh install” project.

    Thanks again for the wonderful article.

  2. Eric Evans says:

    I finally got replication to work. I had to wipe both drives before it would replicate properly. I had a server i moved all the vm’s over to to enable the replication process.
    Now, to mount /var/lib/libvirt. I’ll keep you posted.

  3. Eric Evans says:

    I just noticed you have 2 step 4’s;

    Step 4: Adding a Resource and
    Step 4: Initializing and Enabling Resource.

    Which step 4 do I skip to?

    Let me know.

  4. Eric Evans says:

    No, it is not fixed. It wants to remove my existing partition in favor of the drbd partition. Basically overwrite it. It will be a weekend project to see if I can get it to work.

    Just to be clear, do not change the global config? I removed it and put the original back but it still did not work.

    I am open to suggestions.

  5. Eric Evans says:

    source 900 GB
    destination 898 GB

    Is this the problem? 2 GB difference?

  6. Eric Evans says:

    Here is my rep.res file:

    resource rep {
            device /dev/drbd0;
            disk /dev/sdb1;
                    meta-disk internal;
                    on { <--source
                    on  { <--destination

    Is this correct?

  7. Eric Evans says:

    I know I’m doing something wrong but cannot figure out what. I zeroed out the drive on the destination server, but when I run the command drbdadm create-md rep I get this message. I’m not sure what’s going on but it wounds like it wants to do something to my source drive. Help??!!

    Exclusive open failed. Do it anyways?

    [need to type ‘yes’ to confirm] yes

    md_offset 984894926848
    al_offset 984894894080
    bm_offset 984864833536

    Found LVM2 physical volume signature
    961810432 kB data area apparently used
    961782064 kB left usable by current configuration

    Device size would be truncated, which
    would corrupt data and result in
    ‘access beyond end of device’ errors.
    You need to either
    * use external meta data (recommended)
    * shrink that filesystem first
    * zero out the device (destroy the filesystem)
    Operation refused.

    Command ‘drbdmeta 0 v08 /dev/sdb1 internal create-md’ terminated with exit code 40

  8. Eric Evans says:

    This is a very informative article, like I have come to expect from Tecmint. I already have a function kvm host with vm’s that I use. I recently added a second host for replication. It looks like this will wipe the drives on both hosts.

    Is there a way to replicate vm’s without destroying the drives? I want to replicate the vm’s for redundancy but do not want to lose them. I replicate with the Hyoer-V servers I have using kerberos and would like to do the same with Centos 7 KVM hosts.

    Any help or guidance would be appreciated.

  9. Ricardo Millan says:

    Hi, Thanks for all your How-to and everything. I found a mistake in this page on the IP address.

    Node1: – tecmint.tecmint.lan
    Node2: – server1.tecmint.lan


Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.