First ensure that the two machines synchronized, configuring SSH.
Method of installation through yum source: yum install under the default path is/etc/DRBD.d/
# rpm –import http://elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
# yum -y install drbd84-utils kmod-drbd84
Second method to compile and install: the default path is/usr/local/DRBD/etc
#Yum install DocBook-style-XSL # compile DRBD use
#mkdir -p /tmp/drbdinst
#wget –directory-prefix=/tmp/drbdinst/ http://oss.linbit.com/drbd/8.4/drbd-8.4.6.tar.gz
#cd /tmp/drbdinst
#tar -zxfp drbd-8.4.6.tar.gz
#cd drbd-8.4.6
#yum -y install flex gcc make
#make KDIR=/usr/src/kernels/3.10.0-229.11.1.el7.x86_64
#make install
mkdir -pv /usr/local/drbd/var/run/drbd
cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/rc.d/init.d
systemctl enable drbd
cd drbd
make clean
make KDIR=/usr/src/kernels/3.10.0-229.11.1.el7.x86_64
Replace your kernel version
cp drbd.ko /lib/modules/’uname -r’/kernel/lib5
depmod
Modprobe DRBD module is loaded
Lsmod |GRPE DRBD to see if loaded successfully
I installed via yum sources, configuring same
vim /etc/drbd.d/global_common.conf
global {
usage-count no;
}
common {
protocol C;
handlers {
pri-on-incon-degr “/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f”;
pri-lost-after-sb “/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f”;
local-io-error “/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f”;
}
startup {
wfc-timeout 30;
degr-wfc-timeout 30;
}
options {
}
disk {
on-io-error detach;
fencing resource-only;
}
net {
cram-hmac-alg “sha1”;
shared-secret “mydrbd”;
}
syncer {
rate 100M;
}
}
5. define a resource, r0 is the resource names, you can change:
vim /etc/drbd.d/r0.res
resource r0 {
device /dev/drbd0;
disk /dev/sda1;
meta-disk internal;
on drbdAA {
address 9.111.222.59:7789;
}
on drbdBB {
address 9.111.222.60:7789;
}
}
6. the above document must be the same on both nodes and, therefore, can be based on SSH configuration files are all synchronized to drbdBB node:
7.scp -r /etc/drbd.d/r0.res global_common.conf root@drbdBB:/etc/drbd.d/
8. in two defined initialization of resources on the node and start the service:
drbdadm create-md r0
systemctl start drbd
[root@drbdBB drbd.d]# cat /proc/drbd
version: 8.4.6 (api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R7, 2015-04-10 05:13:52
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r—–
ns:1600728 nr:2048 dw:1600636 dr:3325 al:37 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
9. we need to be one of the nodes is set to Primary, execute the following command on the node that you want to set as Primary, here in the drbdAA operation
drbdadm primary –force r0
[root@drbdAA yum.repos.d]# cat /proc/drbd
version: 8.4.6 (api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R7, 2015-04-10 05:13:52
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r—–
ns:2048 nr:1600728 dw:1606877 dr:3714 al:2 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
10. create and mount the file system:
Mount only on the Primary node for the file system and, therefore, only after the primary node is set to format the DRBD device, it operates at the drbdAA.
Mkfs./drbd0 format for block storage
Create a mount point//
mount /dev/drbd0 /mydata/
11. switch the Primary and Secondary nodes:
On the main terms of DRBD service Primary/Secondary model, only one node at a time for the Primary, so to switch roles of two nodes, only after having first set original Primary node to a Secondary, to the Secondary node is set to Primary.
On coro1:
Drbdadm secondary Web//become a secondary node
On coro2:
1 drbdadm primary Web//4//5 primary node//create the mount point/
As you can see, coro2 has become the Primary, created in the coro1 directory will be able to access before. Once the test is complete, coro1 becomes a Primary and mount again.
Leave a Reply