User manual

What's possible with DRBD?

DRBD is designed to build HA (high availability) clusters using a standby machine. It is not a design goal to build any kind of load balancing clusters. If you have more than one application, you can, however, configure the two machines to act as standby for each other.


Clients  <--------------+---------------------------+
                        |                           | 
              +--------------------+      +--------------------+
              | httpd (on drbd0)   |      | sendmail (on drbd1)|  
              | standby for sendmail      | standby for httpd  |
              +--------------------+      +--------------------+
                     node1                        node2

IMPORTANT: Node1 has mounted the filesystem on drbd0. Node2 may not mount drbd0! On node2 DRBD is not refusing read accesses to drbd0, but if you try to mount the filesystem on drbd0 read-only, you will notice strange bahvior.This is because normal filesystems do not expect that two of their instances are accessing one storage device at the same time. This is true for ext2, ext3, reiserFS, JFS ... .

What is DRBD doing when the connection to the mirrored device is lost?

DRBD will continue to offer its service (which is to read and write blocks). Since it is not possible to send the written blocks to the mirror, the modified blocks are marked as modified in a bitmap (how big is this bitmap). If the connection is reestablished, the marked blocks are copied to the standby node. This resynchronisation happens in the background and does not interrupt the operation on the active node.

How is Heartbeat related?

During the design phase integration with heartbeat was considered, but the use of heartbeat is not obligatory. You can use the DRBD-module and the drbdsetup utility without heartbeat.

There are two scripts coming with DRBD:
drbd This script loads the drbd module and will tell the module about the IP addresses of the machines involved. This is intended to run on system startup. It gets the configuration from /etc/sysconfig/drbd/drbd*.
If you are using this script in conjunction with heartbeat, make sure that this script runs before heartbeat's script in the system startup sequence.
datadisk This script should be run by heartbeat. It will switch one (or all) DRBD device(s) into primary mode, run fsck on them and mount them.
Thus, the haresources files of heartbeat should contain lines like these:
node1 192.168.85.3 datadisk::drbd0 httpd
node2 192.168.85.4 datadisk::drbd1 sendmail

DRBD and caching filesystems

An important question is: How much data is lost when the active (primary device) node failes?

Linux's caches are allowed to cache written data in memory before it is written back to stable storage. You have the following options:
none You have to use DRBD's B or C protocol, you may not use A. You have to instruct the filesystem to do all writes immediately. You can do this with ext2 by adding sync to your mount options. If you know that your application uses fsync(2) or fdatasync(2) you can omit the mount flag.
a few
seconds
You may use DRBD's A, B and C protocols. You can use update(8) to contol Linux's caching policies, use parameter 5 and 6 to set the timespan of data-writes which might be lost in case of a crash.

The price you pay for the first option is lower write performance. It is a trade-off, you have to decide.

How much memory is used by DRBD?

DRBD needs 32KB RAM for 1 GB of storage space. This memory is needed for a bitmap. If DRBD's network connection is interrupted, it needs this bitmap to mark the modified blocks. It is possible to reduce DRBD's memory usage by changing the amount of storage data associated with one bit of the bitmap. This value is defined in the sourcecode of the module, the default value being 4KB.

How to set up a filesystem on top of a DRBD device

If you want to create a new (and empty) filesystem, connect the drbd devices, bring one of them into primary state, and create the fs on the primary device. That's it.

If you want to turn an already existing filesystem into a mirrored one:

  1. Unmount the fs.
  2. Set up a drbd device on top of the partition on which the fs is.
  3. Switch this drbd device into primary mode.
  4. Set up a drbd device on your mirror machine, with a partition that is at least as big as the partition with the fs.
  5. Ensure that the drbd devices are connected.
  6. Start a complete resynchronisation by issuing drbdsetup /dev/xx REPL
back next
Philipp Reisner
Last modified: Wed Aug 23 21:53:17 CEST 2000