First, make sure that the two machines are synchronized in time and SSH configured.
Method one installs through the Yum Source: Yum Installation 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
Method Two compilation installation: The default path is/USR/LOCAL/DRBD/ETC
#yum Install docbook-style-xsl #编译drbd时候用到
#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
Switch to your own kernel version
CP drbd.ko/lib/modules/' uname-r '/kernel/lib5
Depmod
Modprobe DRBD Loading Module
Lsmod |grpe DRBD To see if the load was successful
I was installed through Yum Source, in fact the configuration is similar
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 name, you can change it yourself:
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 files must be the same on two nodes, so you can synchronize all the files you just configured to the DRBDBB node based on SSH:
7.scp-r/etc/drbd.d/r0.res global_common.conf [email protected]:/etc/drbd.d/
8. Initialize the defined resource and start the service on two nodes:
Drbdadm CREATE-MD R0
Systemctl Start DRBD
[Email protected] drbd.d]# CAT/PROC/DRBD
version:8.4.6 (api:1/proto:86-101)
git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 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. Next we need to set one of the nodes to primary and execute the following command on the node to be set to primary, which operates on DRBDAA
Drbdadm Primary--force R0
[Email protected] yum.repos.d]# CAT/PROC/DRBD
version:8.4.6 (api:1/proto:86-101)
git-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by [email protected], 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 the file system and mount it:
File system mounts can only be performed on primary nodes, so it is only possible to format the DRBD device after the master node has been set up, and this is done on DRBDAA.
MKFS.EXT4/DEV/DRBD0 Formatting block Storage
Mkdir/mydata//Create mount point
mount/dev/drbd0/mydata/
11. Switch primary and Secondary nodes:
For the DRBD service of the main primary/secondary model, only one node can be primary at a time, so to switch the roles of the two nodes, the original primary node can only be set to secondary earlier. Before the original secondary node is set to primary.
On the Coro1:
1 UMOUNT/MYDATA/2 drbdadm Secondary web//change to secondary node
On the Coro2:
1 Drbdadm Primary web//change to primary Node 2 cat/proc/drbd3 mkdir/mydata//Create mount point 4 Moun T/DEV/DRBD0/MYDATA/5 ls/mydata/
As you can see, Coro2 has become a primary, and the directories previously created on Coro1 can also be accessed. Once the test is complete, change the Coro1 to primary and mount it again.
This article is from "Rain" blog, be sure to keep this source http://gushiren.blog.51cto.com/3392832/1685207
centos7.0 Installation Configuration DRBD