All aspects of DRBD are controlled in its configuration file,
/etc/drbd.conf
. Normally, this configuration file is just a skeleton
with the following contents:
include "/etc/drbd.d/global_common.conf"; include "/etc/drbd.d/*.res";
By convention, /etc/drbd.d/global_common.conf
contains the
global
and common
sections of the DRBD configuration, whereas the .res
files contain
one resource
section each.
It is also possible to use drbd.conf
as a flat configuration file
without any include
statements at all. Such a configuration,
however, quickly becomes cluttered and hard to manage, which is why
the multiple-file approach is the preferred one.
Regardless of which approach you employ, you should always make sure
that drbd.conf
, and any other files it includes, are exactly
identical on all participating cluster nodes.
The DRBD source tarball contains an example configuration file in the
scripts
subdirectory. Binary installation packages will either
install this example configuration directly in /etc
, or in a
package-specific documentation directory such as
/usr/share/doc/packages/drbd
.
This section describes only those few aspects of the configuration
file which are absolutely necessary to understand in order to get DRBD
up and running. The configuration file’s syntax and contents are
documented in great detail in drbd.conf(5)
.
For the purposes of this guide, we assume a minimal setup in line with the examples given in the previous sections:
Simple DRBD configuration (/etc/drbd.d/global_common.conf
).
global { usage-count yes; } common { net { protocol C; } }
Simple DRBD resource configuration (/etc/drbd.d/r0.res
).
resource r0 { on alice { device /dev/drbd1; disk /dev/sda7; address 10.1.1.31:7789; meta-disk internal; } on bob { device /dev/drbd1; disk /dev/sda7; address 10.1.1.32:7789; meta-disk internal; } }
This example configures DRBD in the following fashion:
usage-count
).
alice and bob
.
r0
which uses /dev/sda7
as
the lower-level device, and is configured with
internal meta data.
The configuration above implicitly creates one volume in the
resource, numbered zero (0
). For multiple volumes in one resource,
modify the syntax as follows:
Multi-volume DRBD resource configuration (/etc/drbd.d/r0.res
).
resource r0 { volume 0 { device /dev/drbd1; disk /dev/sda7; meta-disk internal; } volume 1 { device /dev/drbd2; disk /dev/sda8; meta-disk internal; } on alice { address 10.1.1.31:7789; } on bob { address 10.1.1.32:7789; } }
![]() | Note |
---|---|
Volumes may also be added to existing resources on the fly. For an example see Section 10.5, “Adding a new DRBD volume to an existing Volume Group”. |
This section is allowed only once in the configuration. It is normally
in the /etc/drbd.d/global_common.conf
file. In a single-file
configuration, it should go to the very top of the configuration
file. Of the few options available in this section, only one is of
relevance to most users:
usage-count
. The DRBD project keeps statistics about the usage of various DRBD
versions. This is done by contacting an HTTP server every time a new
DRBD version is installed on a system. This can be disabled by setting
usage-count no;
. The default is usage-count ask;
which will
prompt you every time you upgrade DRBD.
DRBD’s usage statistics are, of course, publicly available: see http://usage.drbd.org.
This section provides a shorthand method to define configuration
settings inherited by every resource. It is normally found in
/etc/drbd.d/global_common.conf
. You may define any option you can
also define on a per-resource basis.
Including a common
section is not strictly required, but strongly
recommended if you are using more than one resource. Otherwise, the
configuration quickly becomes convoluted by repeatedly-used options.
In the example above, we included net { protocol C; }
in the
common
section, so every resource configured (including r0
)
inherits this option unless it has another protocol
option
configured explicitly. For other synchronization protocols available,
see Section 2.3, “Replication modes”.
A per-resource configuration file is usually named
/etc/drbd.d/<resource>.res
. Any DRBD resource you define must be
named by specifying resource name in the configuration. You may use
any arbitrary identifier, however the name must not contain characters
other than those found in the US-ASCII character set, and must also
not include whitespace.
Every resource configuration must also have two on <host>
sub-sections
(one for every cluster node). All other configuration settings are
either inherited from the common
section (if it exists), or derived
from DRBD’s default settings.
In addition, options with equal values on both hosts
can be specified directly in the resource
section. Thus, we can
further condense our example configuration as follows:
resource r0 { device /dev/drbd1; disk /dev/sda7; meta-disk internal; on alice { address 10.1.1.31:7789; } on bob { address 10.1.1.32:7789; } }