DRBD with OCFS2

Introduction
This is a guide for DRBD with OCFS2.

The tough part came with finding that Samba Active Directory (AD) Domain Controller (DC) sysvol is not being replicated between DC – a current Samba4 known limitation.

Q: Why DRBD only is not enough...

There might be case in which there is multiple write access to the block device by multiple servers, thus without cluster files system we will have trouble on file locking etc. due to the fact that DRBD volumes are being mounted by two or more servers, so OCFS2 is selected for its performance and also its popularity.

You can use always use other cluster files system.

This guide covers only a two node, dual primary configuration. If you required more nodes, please read up on DRBD for more information.

Emerge
Install the following packages:

The DRBD 8.4 guide suggests the use of heartbeat and pacemaker, but I think that was just too complicated. You are welcome to try and add on an option with heartbeat and pacemaker.

DRBD Configuration
We will now configure DRBD.

Please check the DRBD User’s Guide Ver 8.4 on their website it is well written with examples.

This is a Global DRBD configuration. It will need to change according to your DRBD need. Please check the on the manual for more info.

Please create the files below.

If you have multiple resource setup, you can do it one resource per files to avoid confusion.

Below files is a 2 Node Resource example. Note on the Comment Part, they will need to be uncommented later when we enable dual primary.

In plain English, we will use on serverNode01 (IP 192.168.11.23) and  on serverNode02 (IP 192.168.11.27) to create a drbd node  respectively on both server. Both drbd nodes will store the metadata internally.

OCFS2 Configuration
We will now continue with OCFS2 setup.

Unfortunately ocfs2 configuration doesn't include the cluster files example and thus you will need to copy the files below as an example.

Please change as necessary to suit your needs:

Now it is time to change files. There are a lot of configurable parameters there but we will only make one change. and change it to ocfs2 cluster name.

It is also time we add the required mount to. Please add the following.

DRBD Initialization and Setup
After we have all this.

It is time to initial DRBD

Let us up the DRBD devices.

When both nodes are up we can check on the BRDB status.

When Both node is up, we will see something...

The Secondary/Unknown become Secondary/Secondary.

We now have the DRBD device.

Lets start to synchronize both DRBD nodes by making it primary

Let us check the synchronization status

Please wait until it is done.

Let make 2nd Node primary

Let start the DRBD services

Yes, our DRBD cluster are done. Now lets continue to the OCFS2 Setup

OCFS2 Setup
The 1st things that we need to do are to mount the required kernel config and dlm that is needed by OCFS2. Since that we already modified the. You can simple follow the command below.

We should now start the OCFS2 Cluster

Now let us make the DRBD cluster run OCFS2

Enable Dual-Primary Mode
Enabling Dual-Primary mode is easy, just uncomment the resources files we have made on top.

Then it's time to make changes on both nodes, in sequence primary then only secondary.

Check if drbd are now dual primary

We can now mount it the OCFS2 cluster on both node.

Adding both DRBD and OCFS2 on system boot
Let us start both DRBD and OCFS2 when system boot up.

Manual Split Brain Recovery
Summary from Under certain condition, Split Brain will happen and cannot be recover automatically by system. And we have to manually recovery the DRBD disk.

Split Brain Victim, Choose a node upon which the changes will be discarded
We will disconnect this node, make it secondary and connect it back to the drbd array and we will discard all the differences so that it will sync with the latest version from other node.

Split Brain Survivor, Choose The node upon which we have the latest version of files
We just connect this back to the drbd array so the secondary will sync from here.

Result
Sync should happen and we should have our array back. What if that don't happen.

Troubleshooting and error recovery