Skip to main content

DRBD + Pacemaker & Corosync NFS Cluster Centos7

On Both Nodes

Host file

10.1.2.114 nfs1 nfs1.localdomain.com
10.1.2.115 nfs2 nfs2.localdomain.com

Corosync will not work if you add something like this: 127.0.0.1 nfs1 nfs2.localdomain.com - however you do not need to delete 127.0.0.1 localhost

Firewall

Option 1 Firewalld

On NFS1

On NFS2

Disable SELINUX

SELINUX=disabled

Pacemaker Install

Install PaceMaker and Corosync

Authenticate as the hacluster user

Start and enable the service

ON NFS1

Test and generate the Corosync configuration

ON BOTH NODES

Start the cluster

Verify Corosync installation

Master should have ID 1 and slave ID 2

ON NFS1

Create a new cluster configuration file

Disable the Quorum & STONITH policies in your cluster configuration file

Prevent the resource from failing back after recovery as it might increases downtime

LVM partition setup

Both Nodes

Create a empty partition

Welcome to fdisk (util-linux 2.23.2).

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):(ENTER)
Partition number (1-4, default 1): (ENTER)
First sector (2048-16777215, default 2048): (ENTER)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): (ENTER)
Using default value 16777215
Partition 1 of type Linux and of size 8 GiB is set

Command (m for help): w
The partition table has been altered!

Create LVM partition

View LVM partition after creation

Look in "/dev/mapper/" find the name of your LVM disk

OUTPUT:

**You will use "vg00-drbd--r0" in the "drbd.conf" file in the below steps

DRBD Installation

Install the DRBD package

Edit the DRBD config and add the to hosts it will be connecting to (NFS1 and NFS2)

Delete all and replace for the following

include "drbd.d/global_common.conf";
include "drbd.d/*.res";

global {
usage-count no;
}
resource r0 {
protocol C;
startup {
degr-wfc-timeout 60;
outdated-wfc-timeout 30;
wfc-timeout 20;
}
disk {
on-io-error detach;
}
net {
cram-hmac-alg sha1;
shared-secret "Daveisc00l123313";
}
on nfs1.localdomain.com {
device /dev/drbd0;
disk /dev/mapper/vg00-drbd--r0;
address 10.1.2.114:7789;
meta-disk internal;
}
on nfs2.localdomain.com {
device /dev/drbd0;
disk /dev/mapper/vg00-drbd--r0;
address 10.1.2.115:7789;
meta-disk internal;
}
}

Delete all and replace for the following

common {
        handlers {
        }
        startup {
        }
        options {
        }
        disk {
        }
        net {
                 after-sb-0pri discard-zero-changes;
                 after-sb-1pri discard-secondary; 
                 after-sb-2pri disconnect;
         }
}

On NFS1

Create the DRBD partition and assign it primary on NFS1

On NFS2

Configure r0 and start DRBD on NFS2

Pacemaker cluster resources

On NFS1

Add resource r0 to the cluster resource

Create an additional clone resource r0-clone to allow the resource to run on both nodes at the same time

Add DRBD filesystem resource

Filesystem resource will need to run on the same node as the r0-clone resource, since the pacemaker cluster services that runs on the same node depend on each other we need to assign an infinity score to the constraint:

Add the Virtual IP resource 

The VIP needs an active filesystem to be running, so we need to make sure the DRBD resource starts before the VIP

Verify that the created resources are all there

And finally commit the changes

On Both Nodes

Installing NFS

Install nfs-utils

Stop all services

Setup service

Reboot both servers

Test failover

Other notes on DRBD

To update a resource after a commit

Edit with vi tmp.xml or do a pcs -f tmp.xml %do your thing% 

Delete a resource

Delete cluster

pcs cluster destroy
Recover a split brain

Secondary node
drbdadm secondary all
drbdadm disconnect all
drbdadm -- --discard-my-data connect all

Primary node
drbdadm primary all
drbdadm disconnect all
drbdadm connect all

On both
drbdadm status
cat /proc/drbd