DRBD Setup

From DHVLab

Revision as of 12:06, 8 September 2016 by Wiki admin (talk | contribs) (Created page with "== Setting up DRBD == DRBD is the distributed replicated storage system. We use /dev/drbd0 (/dev/drbd/by-res/sync) with ext4, to share data and configuration files that should...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Setting up DRBD

DRBD is the distributed replicated storage system. We use /dev/drbd0 (/dev/drbd/by-res/sync) with ext4, to share data and configuration files that should be available to the cluster master node. It is mounted under /sync. /dev/drbd1 (/dev/drbd/by-res/virt) is used as a VirtIO block device that is directly passed to the KVM, which is a cluster resource.

#install packages
yum -y install drbd84-utils kmod-drbd84
#reboot or load module
modprobe drbd
#install fix if necessary 
curl -o /usr/lib/ocf/resource.d/linbit/drbd 'http://git.linbit.com/gitweb.cgi?p=drbd-utils.git;a=blob_plain;f=scripts/drbd.ocf;h=cf6b966341377a993d1bf5f585a5b9fe72eaa5f2;hb=c11ba026bbbbc647b8112543df142f2185cb4b4b'

/etc/drbd.conf

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

/etc/drbd.d/global_common.conf

global {
  usage-count yes;
}
common {
  handlers {}
  startup {}
  options {}
  disk {}
  net {
    protocol C;
  }
}

/etc/drbd.d/virt.res

resource virt {

   protocol C;
   meta-disk internal;
   device /dev/drbd1;
   syncer {
       verify-alg sha1;
   }
   on CLUSTER_N1.clan {
      disk /dev/centos/virt;
      address CLUSTERLAN_CLUSTER_N1_IP:7790;
   }

   on CLUSTER_N2.clan {
      disk /dev/centos/virt;
      address CLUSTERLAN_CLUSTER_N2_IP:7790;
  }
}

/etc/drbd.d/sync.res

resource sync {

   protocol C;
   meta-disk internal;
   device /dev/drbd0;
   syncer {
       verify-alg sha1;
   }
   on CLUSTER_N1.clan {
      disk /dev/centos/sync;
      address CLUSTERLAN_CLUSTER_N1_IP:7789;
   }

   on CLUSTER_N1.clan {
      disk /dev/centos/sync;
      address CLUSTERLAN_CLUSTER_N2_IP:7789;
  }
}
#create drbd
drbdadm create-md virt
drbdadm create-md sync

#start the drbd service
systemctl start drbd.service

#on primary cluster node only!!
drbdadm  virt primary --force 
drbdadm  sync primary --force 

#watch synchronization using
cat /proc/drbd
#or 
service drbd status

#create sync directory on both nodes
mkdir /sync 

#create filesystem on drbd device, primary node only!
mkfs.ext4 /dev/drbd/by-res/sync

#mount device on primary node only!
mount /dev/drbd/by-res/sync /sync

#make secondary node slave. secondary node only!
drbdadm secondary virt
drbdadm secondary sync