DRBD Linux

Installing drbd 8.x in linux /w pacemaker
Very good guide on youtube: https://www.youtube.com/watch?v=WQGi8Nf0kVc

Words in “”, are commands.

+Prerequisite
sudo apt install build-essential python drbd8-utils pacemaker ntp
Configure NTP on both servers. If you going to use crypt you need to add both ssh-keys on both servers. Easiest by login from each to the other with ssh and accept the key.

To be sure that both servers going to ‘find’ eachother, edit the /etc/hosts and put in both servers ip and hostnames, remove that 127.0.1.1 address pointing to hostname, repeat on both servers. And set static ip on both.

+Setting up the drbd8-device

1. Edit /etc/drbd.conf and copy/paste default-config-drbd8 down below. And adapt it to your needs.
2. Load the kernal module (not sure if its neccassary, “modprobe drbd”)
3. Create resource, “lsblk” not showing the blockdevice.
4. “drbdadm create-md r0” (md = mirrordevice r0=resource)
5. “drbdadm up r0” (activate the resource that we created in previous step)
6. Repeat 1-5 on both servers…

7. “drbdadm — –overwrite-data-of-peer primary r0” //This make ‘This’ -server the primary

To see the syncprogress, issue the command “cat /proc/drbd”.
And to see and overview of the drbd, use command “drbd-overview”.
Be careful with this command (7), its possible for dataloss to occur, thus the ‘– –‘.

8. Create a filesystem, must be done one the primary server. “mkfs.ext4 /dev/drbd0”. Then its going to be replicated.

Now you are able to mount and use the blockdevice. But we going to install a resourcemanager, more convinient, that will make that for us everytime we re-boot. In this case we going to use pacemaker.

Tips!
You can change which server to be the primary/secondary, by using “drbdadm primary/secondary r0”.

+Setting up pacemaker (cluster resourcemanager)

1. Make sure that drbd service isn’t running, on both servers. Using “systemctl disable drbd”. Because we going to have drbd running through pacemaker.
2. Edit /etc/corosync/corosync.conf (remove everything, and use default config from below). And adapt it to your needs.
3. Restart corosync service on both servers. “systemctl restart corosync”
4. Start pacemaker on borh servers, just in case. “systemctl start pacemaker”.
5. Check status/metadata with “crm status”.
6. For simples configs as in this case, we should disable stonith and change some settings, we dont need it. “crm configure property stonith-enabled=false”. “crm configure property no-quorum-policy=ignore”.
7. To configure resources within pacemaker, type “crm configure”, then we are in a interactive commandprompt. Were we can type in and create our policy. We only need to do it once, it will automatically be synced to all nodes…

:policy starts here:
primitive drbd_res ocf:linbit:drbd params drbd_resource=r0 op monitor interval=29s role=Master op monitor interval=31s role=Slave

ms drbd_master_slave drbd_res meta master-max=1 master-noce-max=1 clone-max=2 clone-node-max=1 notify=true

primitive fs_res ocf:heartbeat:Filesystem params device=/dev/drbd0 directory=/path fstype=ext4

colocation fs_drbd_colo INFINITY: fs_res drbd_master_slave:Master

order fs_after_drbd mandatory: drbd_master_slave:promote fs_res:start

commit (to save the config)
quit

To see the configs while in liveconfigmode type: show
And to see corosyncs progress “crm_mon” in terminal.

Default config – drbd8
———————-
#Starts here /etc/drbd.conf

global { usage-count no; }        #//checking who is using it = no
common { protocol C; }            #//protocol that meaning replication A<->B

resource r0 {
on server01 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.?.?:7788;    #//ip that corespond with server01
meta-disk internal;            #//saving metadata on localdisk
}

on server02 {
device /dev/drbd0;
disk /dev/sdb1;
address 192.168.?.?:7788;    #//ip that corespond with server02
meta-disk internal;
}

}

#Default config drbd8 ends here

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Default config – pacemaker
———————-
#Starts here /etc/corosync/corosync.conf

totem {
version: 2
cluster_name: debian
secauth: off
transport: udpu
interface {
ringnumber: 0
bindnetaddr: 192.168.?.0
broadcast: yes
mcastport: 5405
}
}
}

nodelist {
node {
ring0_addr: 192.168.?.?
name: ????
nodeid: 1
}
node {
ring0_addr: 192.168.?.?
name: ????
nodeid: 2
}
}

quorum {
provider: corosync_votequorum
two_node: 1
wait_for_all: 1
last_man_standing: 1
auto_tie_breaker: 0
}

#Default config pacemaker, ends here

This entry was posted in Guides. Bookmark the permalink.