DRBD: Difference between revisions

From Leo's Notes
This page was last edited on 31 March 2015, at 19:57.
Line 57: Line 57:
  echo "/dev/drbd0 /mnt/drbd ext4 noauto 0 0 " >>  /etc/fstab
  echo "/dev/drbd0 /mnt/drbd ext4 noauto 0 0 " >>  /etc/fstab


Configure the DRBD config in /etc/drbd.d/*conf. You may want to disable the survey.
Configure DRBD by creating a file in /etc/drbd.d/mysql.res
Configure DRBD by creating a file in /etc/drbd.d/mysql.res
<syntaxhighlight lang="text">
resource mysql {
resource mysql {
  device    "/dev/brdb0";
disk {
  disk      "/dev/loop0";
on-io-error detach;
  meta-disk internal;
}
  on node1 {
 
    address ipv4 10.0.42.100:7700;
device    /dev/drbd0;
  }
disk      /dev/loop0;
  on node2 {
meta-disk internal;
    address ipv4 10.0.42.254:7700;
 
  }
on node1 {
address 172.20.10.10:7700;
}
 
on node2 {
address 172.20.10.9:7700;
}
}
}
</syntaxhighlight>
</syntaxhighlight>
If you get an error like:
'mysql' not defined in your config (for this host).
You are probably doing something wrong.


== See Also ==
== See Also ==

Revision as of 19:57, 31 March 2015

DRBD (Distributed Replicated Block Device) is a virtual block device that is distributed across two or more machines.

Installation

On a clean installation of RHEL 7 or equivalent, run updates, and ensure that you have NTP and a recent kernel installed.

From ElRepo

Get the DRBD packages from ELRepo:

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum install drbd84-utils kmod-drbd84

From Source

Install prerequisites:

yum install gcc flex make autoconf m4

Get the source from their git repository. Releases from tarballs may fail depending on which kernel version you're using.

git clone git://git.drbd.org/drbd-8.4.git
cd drbd-8.4
make
make install

The make install should have loaded the module and you can verify this:

lsmod | grep drbd

If it isn't loaded, load it using modprobe

modprobe drbd

Compile the userspace utilities:

git clone git://git.drbd.org/drbd-utils.git
cd drbd-utils
./aclocal.sh
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
make
make install

Note: I got errors about man pages not being found. Ugh.


Configuration

This section will configure DRBD for use in a redundant MySQL setup.

DRBD syncs volumes. If you did not configure a partition or have a separate disk to mirror, you can create a file volume instead.

mkdir /var/drbd
cd /var/drbd

# Create a 50GB volume
dd if=/dev/zero of=data_volume.dat bs=1024 count=52428800

# Create a partition
fdisk data_volume.dat

# Create a device
losetup /dev/loop0 /var/drbd/data_volume.dat

mkdir -p /mnt/drbd
echo "/dev/drbd0 /mnt/drbd ext4 noauto 0 0 " >>  /etc/fstab

Configure the DRBD config in /etc/drbd.d/*conf. You may want to disable the survey. Configure DRBD by creating a file in /etc/drbd.d/mysql.res resource mysql { disk { on-io-error detach; }

device /dev/drbd0; disk /dev/loop0; meta-disk internal;

on node1 { address 172.20.10.10:7700; }

on node2 { address 172.20.10.9:7700; } } </syntaxhighlight>

If you get an error like:

'mysql' not defined in your config (for this host).

You are probably doing something wrong.

See Also