Configuration

The scripts (drbd and datadisk) use files from /etc/sysconfig/drbd/ to configure your machines. You need one file for each drbd device. The files need to be present on every node of the cluster, and they may (and should) be the same on all cluster nodes.

Thus, if you need two devices (one for apache and one for sendmail), you will need two such configuration files. The configuration files must be named drbd0, drbd1, drbd2 ... . Let's have a look at the contents of these files:

MASTER_NODE=
SLAVE_NODE=
You must give the names of your cluster nodes as reported by running 'hostname -s'. Actually, it does not matter which node you enter as MASTER_NODE and which one as SLAVE_NODE, but let's enter the home-node of a service as the MASTER_NODE of its device. By home-node of a service I mean the node that is the first entry in heartbeat's haresources file.
We have for example drbd0 for apache, and therefore we have
MASTER_NODE=node1:7788
SLAVE_NODE=node2:7788
Drbd1 is used for sendmail. We define the nodes as
MASTER_NODE=node2:7789
SLAVE_NODE=node1:7789

MASTER_IF=
SLAVE_IF=
If your machines are equiped with one NIC per machine, skip this paragraph. Now let's assume our machines are equiped with two NICs.

Clients  <--------------+---------------------------+
                        |                           | 
              +------ node1 -------+      +------ node2 -------+
              |                    |      |                    |  
              |                    |      |                    |
              +-----10.1.1.3-------+      +------10.1.1.4------+
                        |                           |
                        +---------------------------+     
If you want to have the DRBD traffic on the private net, you need to add these two lines to the two config files:
drbd0 MASTER_IF=10.1.1.3:7788
SLAVE_IF=10.1.1.4:7788
drbd1 MASTER_IF=10.1.1.4:7789
SLAVE_IF=10.1.1.3:7789
If you do not have a private net for drbd traffic, do not set these two variables.
NOTE Each drbd device pair needs a port, we are using 7788 for drbd0, and 7789 for drbd1. 7788 is the default, thus we could omit ":7788". The best approach is to add the port number to the config file anyway, so that you will never forget that each drbd device pair needs a port, that may not be used by another drbd device pair.

OPTIONS=
Please have a look at the drbdsetup page for a list of the available options. For our example configuration I assume a good 100MBit network, I want to use up to 5MByte/s for resynchronisation. If the harddisk of a node fails, I want that node to die. By the way, if you use the -p option, you also need to enable the reboot after panic feature of the kernel. You can do this with cat 1 > /proc/sys/kernel/panic
drbd0 OPRIONS="-r 5000 -p"
drbd1 OPRTIONS="-r 5000 -p"

SIZE=
First, you have to decide if you prefer your service to be available under any circumstances, or if you prefer that your service never shows out-of-date data to your clients.
There are two examples:
Never show out-of-date data:
There is a database running on your HA cluster, and there are money-accounts in that database. A user is committing some transaction, say he is paying his telephone bill. This user will be very disappointed, if suddenly his transaction is reverted (out-of-date data) and his telelphone is shut down.
This happened, because before the user did his transaction the standby node (SLAVE_NODE) was going down. Afterwards, the MASTER_NODE failed, and some unexperienced admin decided it would be a good idea to bring up the SLAVE_NODE. The node started offering the service without ever seeing the other node.
Never show out-of-date data means that the SLAVE_NODE will come up, but will not offer the service. This prevents the unexperienced from doing serious harm, but there is still need for an expert, who has to move the disk of the MASTER_NODE to the SLAVE_NODE or start a complete resynchronisation on the MASTER_NODE.
If you want this, do not specify the SIZE variable!
Keep the service running:
If you are running a ftp or web server, it is probably more important for you to have a running service. It is not that important to have the latest versions of some files available.
If you want this behaviour, you have to specify the SIZE. You need to find out the exact sizes of the partitions you are using for the drbd device pair. You can do this with fdisk's "p" command. Use the smaller one of the two values for the SIZE variable. (The unit for the SIZE variable is KB. Fdisk may show a "+" after the value, simply ignore it.)
For example:
drbd0 SIZE=4711123
drbd1 #SIZE=

PROTOCOL=
See DRBD and caching filesystems. For the database example mentioned above I would choose protocol C. (If you are using protocol C, you should also consider hdparm -W0 /dev/xx)
Example:
drbd0 PROTOCOL=A
drbd1 PROTOCOL=B

MASTER_DEVICE=
SLAVE_DEVICE=

The only reasonable values are /dev/nbX, where X is the same digit as the digit in the name of the config file. (If you need to make your setup unmaintanable, ...)
Example:
drbd0 MASTER_DEVICE=/dev/nb0
SLAVE_DEVICE=/dev/nb0
drbd1 MASTER_DEVICE=/dev/nb1
SLAVE_DEVICE=/dev/nb1

MASTER_PARTITION=
SLAVE_PARTITION=

This is where drbd will store your data. By the way, DRBD is not doing any weird things to your data, thus if you need to access your data without loading the DRBD module, you will find them on these devices in exactly the same way as they are on the drbd device.
Example:
drbd0 MASTER_PARTITION=/dev/hda5
SLAVE_PARTITION=/dev/hda5
drbd1 MASTER_PARTITION=/dev/hda6
SLAVE_PARTITION=/dev/hda6

MASTER_FSCK=
SLAVE_FSCK=

If your filesystem needs to be checked after an unclean shutdown you can specify the command line of the filesystem checker here.
Example:
drbd0 MASTER_FSCK="fsck -p -y"
SLAVE_FSCK="fsck -p -y"
drbd1 MASTER_FSCK="fsck -p -y"
SLAVE_FSCK="fsck -p -y"

/etc/fstab
Finally you need to add device and mount point to /etc/fstab.
Example:

/dev/nb0    /home/httpd       ext2  noauto       0 0
/dev/nb1    /var/spool/mail   ext2  noauto,sync  0 0

back prev next
Philipp Reisner
Last modified: Wed Aug 23 21:53:17 CEST 2000