Configuring DRBD

Configuration of the nodes      First initialization of the nodes     What to do in case of disconnection

Configuration of the nodes

DRBD will allow to synchronise / replicate a partition blocks in different fashion (master-slave synchronous, asynchronous, multi-master, …). We will use it in master-slave replication for the rest of the configuration, so there will be one primary where the change occurs and one secondary which is a read-only copy of the primary until a fail-over is done.

The DRBD service itself can be managed by a cluster, of course, but the configuration must be done outside of it, as is it done in a non-cluster installation of DRBD. Advantage of using the cluster framework to manage this service, is that it is the cluster that will promote / demote resources accordingly accross the nodes failure and recovery.

If working with a cluster, we will avoid the DRBD startup script from being automatically launch at startup :

# chkconfig –-del drbd


Then we configure one replicated resource by adding a configuration file in the /etc/drbd.d directory (the only requirement on the name of the file is that it has a .res extension) :

resource iscsi {
   on storage1 {
      device /dev/drbd1;
      disk /dev/sda1;
      address 192.168.20.113:7789;
      meta-disk internal;
   }
   on storage2 {
      device /dev/drbd1;
      disk /dev/sda1;
      address 192.168.20.114:7789;
      meta-disk internal;
   }
}

back to top

 

First initialization of the nodes

Once the configuration file is in place, we need to manually initialize the DRBD replication the first time by writing the meta data on both partitions. So we do :

# drbdadm create-md iscsi
# drbdadm up iscsi

Repeat the above two commands on the other node two.

Then you choose on of your two nodes to be the initial primary. Obviously, we will choose here storage1 and we do the following command :

# drbdadm primary –-force iscsi

You can view the state of the resource by using the command drbd-overview. She tells you which node is primary, which is secondary and the status of the replication (uptodate, inconsitent, …).
 

back to top
 

What to do in case of diconnection between the two nodes

If you got the status unknown for the remote node, it is usually means that there has been some problems leading to a lost of synchronisation, to force it back without loosing everything, you will select one node where the last modifications will be discarded and do :

# drbdadm secondary iscsi
# drbdadm connect --discard-my-data iscsi

On the other node, you will do :

# drbdadm connect iscsi
# drbdadm primary iscsi

If you check back with drbd-overview, you will see if the status get back to the norma.

You can use the above procedure also in case of split-brain error detection (will be notified in the logs if this is the case).

 

So at this stage, we have a running DRBD synchronisation between storage1 and storage2 of /dev/sda1, using iscsi as resource name and offered to the system via the /dev/drbd1 special device file.

Now stop the DRBD resource using the default startup on both nodes :

# /etc/init.d/drbd stop

 

back to top