Building an Nextcloud HA Cluster Part 4 DRBD

image_pdfimage_print

Create necessary Logical Volumes

ACTIVE ‚/dev/system/drbd2‘ [5.00 GiB] inherit
ACTIVE ‚/dev/system/drbd3‘ [40.00 GiB] inherit
ACTIVE ‚/dev/system/drbd5‘ [1.00 GiB] inherit

The 1 GB Volume will be your Webserverdirectory /srv/www/htdocs
The 5 GB Volume is intented to serve as the Mysql Storage Volume.
The 40 GB Volume should server as the Data Volume.

Attention….

before you do anything…¬† create on the drbd.conf to load the DRBD Kernel Module

if you’re good…

modprobe drbd

on both nodes.

To survive the reboot. ūüôā

We have to take care the Module gets loaded

echo „drbd“¬† > /etc/modules-load.d/drbd.conf

 

Create the DRBD Config Files.

Make sure that those files will be created on both Nodes!! 
And also make sure, they are identical!

 

vi mysql.res

#####DRBD Resource Mirror
resource mysql  {
protocol C;

disk {
on-io-error pass_on;
resync-rate 100M;
}
net   {
sndbuf-size 512k;
max-buffers 20840;
max-epoch-size 16383;
#       unplug-watermark  20480;
verify-alg md5;
}
startup {
}
on clusternode0.fullqualifieddomainname.de {
volume 2 {
device     /dev/drbd2;
disk       /dev/system/drbd2;
flexible-meta-disk       internal;
}
address 172.16.0.2:7792;
}
on clusternode1.fullqualifieddomainname.de {
volume 2 {
device /dev/drbd2;
disk   /dev/system/drbd2;
flexible-meta-disk  internal;
}
address 172.16.0.3:7792;
}

}


 

#####DRBD Resource Mirror

resource nextcloud  {
protocol C;

disk {
on-io-error pass_on;
resync-rate 100M;
}
net   {
sndbuf-size 512k;
max-buffers 20840;
max-epoch-size 16383;
#       unplug-watermark  20480;
verify-alg md5;
}
startup {
}
on clusternode0.fullqualifieddomainname.de {
volume 5 {
device     /dev/drbd5;
disk       /dev/system/drbd5;
flexible-meta-disk       internal;
}
address 172.16.0.2:7798;
}
on clusternode1.fullqualifieddomainname.dede {
volume 5 {
device /dev/drbd5;
disk   /dev/system/drbd5;
flexible-meta-disk  internal;
}
address 172.16.0.3:7798;
}

}


 

vi /etc/drbd.d/www.res

DRBD Resource Mirror
resource www {
protocol C;

disk {
on-io-error pass_on;
resync-rate 100M;
}
net   {
sndbuf-size 512k;
max-buffers 20840;
max-epoch-size 16383;
#       unplug-watermark  20480;
verify-alg md5;
}
startup {
}
on clusternode0.fullqualifieddomainname.de {
volume 3 {
device     /dev/drbd3;
disk       /dev/system/drbd3;
flexible-meta-disk       internal;
}
address 172.16.0.2:7794;
}
on clusternode1.fullqualifieddomainname.de {
volume 3 {
device /dev/drbd3;
disk   /dev/system/drbd3;
flexible-meta-disk  internal;
}
address 172.16.0.3:7794;
}

}

 

 

Bringing DRBD UP

Create the DRBD Devices…


suseclusternode0:/etc/drbd.d # drbdadm create-md nextcloud
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
suseclusternode0:/etc/drbd.d # drbdadm create-md www
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
suseclusternode0:/etc/drbd.d # drbdadm create-md mysql
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
suseclusternode0:/etc/drbd.d #

1st Node


drbdadm up nextcloud

drbdadm primary --force nextcloud

drbdadm up mysql

drbdadm primary --force mysql

drbdadm up www

drbdadm primary --force www

Create the Necessary Mountpoints on BOTH NODES!!:
Dont miss it out…

mkdir /var/lib/mysql
mkdir /srv/www/data
mkdir /srv/www/htdocs/nextcloud

Create the Filesystem.
Keep in mind.. DRBD Devices are treated like Blockdevices.
So all our DRBD Devices inside the Logical Volumes are block Devices.. for the Linux Kernel.

#:/etc/drbd.d # blkid |grep drbd
/dev/mapper/system-drbd2: UUID="e1de72cb-19d9-4814-9a34-56c389a993e9" TYPE="xfs"
/dev/mapper/system-drbd3: UUID="88604a7c-d4aa-4196-ab52-b1ab3b8f0f6c" UUID_SUB="7a453a88-90b6-4be3-93d5-6c0707618d64" TYPE="btrfs"
/dev/mapper/system-drbd0: UUID="0da2591c-f45e-4d5f-a21f-e2d9e442b422" TYPE="xfs"
#:/etc/drbd.d #

Create the Filesystems ONLY on the Primary Node!! Never ever on the secondary Node!


mkfs.ext4 /dev/drbd5
mkfs.xfs /dev/drbd2
mkfs.btrfs /dev/drbd3

Mount the Filesystems on the Primary Node


mount /dev/drbd2 /var/lib/mysql
mount /dev/drbd3 /srv/www/data
mount /dev/drbd5 /srv/www/htdocs/nextcloud

2nd Node

drbdadm up  nextcloud

drbdadm up mysql

drbdadm up www

 

Verify

After a while the Filesystems should be in sync…

drbd-overview

 

Connected?

22016103917338737:~ # drbd-overview
2:mysql/2      Connec/C'ting Primar/Unknow UpToDa/DUnkno /var/lib/mysql            xfs   5.0G 251M 4.8G 5%
3:www/3        Connec/C'ting Primar/Unknow UpToDa/DUnkno /srv/www/data             btrfs 40G  935M 38G  3%
5:nextcloud/5  Connec/C'ting Primar/Unknow UpToDa/DUnkno /srv/www/htdocs/nextcloud ext4  992M 195M 730M 22%
v22016103917338737:~ # drbd-overview

If not connected….. Check your secondary Node…

 

1st Node

watch drbd-overview

2nd Node d

drbdadm connect www

drbdadm connect nextcloud

drbdadm connect mysql

 

If  everything looks in Sync and UptoDa and the Primary Secondary Situation is  ok... like in this stdout Output.

v22016103917338737:~ # drbd-overview
2:mysql/2      Connected(2*) Primar/Second UpToDa/UpToDa /var/lib/mysql            xfs   5.0G 251M 4.8G 5%
3:www/3        Connected(2*) Primar/Second UpToDa/UpToDa /srv/www/data             btrfs 40G  935M 38G  3%
5:nextcloud/5  Connected(2*) Primar/Second UpToDa/UpToDa /srv/www/htdocs/nextcloud ext4  992M 195M 730M 22%
v22016103917338737:~ #

you're golden.

 

At the End of this Chapter the necessary Filesystems are up and running,
but we don't have the Clusterframework up and running so far we'll deal with this in the Next Chapter

Building an Nextcloud HA Cluster Part 4 DRBD