a . Environment Preparation
System environment
CentOS Release 6.3 (Final)
Kernel information
2.6.32-279.el6.x86_64
IP Address
VIP 192.168.64.120
Master 192.168.64.132 Heart jumper:10.0.0.1 hostname :D bmaster.test
Slave 192.168.64.135 Heart jumper:10.0.0.2 host name :D bbak.test
Mirrored disk
Master/dev/sdc
Slave/dev/sdc
Fdisk-l
Install dependent environments
Yum-y install gcc gcc-c++ make Glibcflex kernel kernel-devel kernel-headers
Download the installation package
wget http://oss.linbit.com/drbd/8.4/drbd-8.4.3.tar.gz
two . Installation Configuration
Installation:
Ls
Tar zxfdrbd-8.4.3.tar.gz
Ls
CD drbd-8.4.3
./CONFIGURE--PREFIX=/USR/LOCAL/DRBD--with-km
Ls/usr/src/kernels/2.6.32-431.5.1.el6.x86_64
ls/usr/src/kernels/
Uname-r
Makekdir=/usr/src/kernels/2.6.32-431.5.1.el6.x86_64
echo $?
Make install
echo $?
Add Boot Boot
Cp/usr/local/drbd/etc/rc.d/init.d/drbd/etc/rc.d/init.d
Chkconfig--ADDDRBD
Chkconfig Drbdon
Loading DRBD Module
Depmod
Modprobe DRBD
Modprobe DRBD
Loading DRBD Module Error
[[Email protected]]# depmod
[Email protected]]# modprobe DRBD
FATAL:MODULEDRBD not found.
Error: Fatal:module DRBD not found. kernel not supported, update kernel, then restart
To see if the module is loaded into the kernel
[[Email protected] ~] #lsmod |grep DRBD
DRBD 325658 0
LIBCRC32C 1246 1 DRBD
after successful installation, the system will have the command of DRBD.
/sbin/dr
Dracut Drbdadm Drbdmeta Drbdsetup
Master configuration file
Cat>>/usr/local/drbd/etc/drbd.conf <<eof
# You can Findan example in/usr/share/doc/drbd.../drbd.conf.example
Include "drbd.d/global_common.conf";
Include "Drbd.d/*.res";
Eof
Global configuration file
Cp/usr/local/drbd/etc/drbd.d/global_common.conf/usr/local/drbd/etc/drbd.d/global_common.conf.bk
>/usr/local/drbd/etc/drbd.d/global_common.conf
Cat>>/usr/local/drbd/etc/drbd.d/global_common.conf <<eof
Global {
Usage-count No;
# Minor-count Dialog-refreshdisable-ip-verification
}
Common {
Protocol C;
startup {
Wfc-timeout 120;
Degr-wfc-timeout 120;
}
Disk {
On-io-error detach;
Fencing resource-only;
}
NET {
Cram-hmac-alg "SHA1";
Shared-secret "Mydrbdlab";
}
Syncer {
Rate 100M;
}
}
Eof
Resource configuration file
Cat>>/usr/local/drbd/etc/drbd.d/mysql.res <<eof
Resource MySQL {
On dbmaster.test {
device/dev/drbd0;
DISK/DEV/SDC1;
Address 10.0.0.1:7789;
Meta-disk internal;
}
On dbbak.test {
device/dev/drbd0;
DISK/DEV/SDC1;
Address 10.0.0.2:7789;
Meta-disk internal;
}
}
Eof
DRBD Device Creation
[[Email protected]]# mknod/dev/drbd0 B 147 0
[[Email protected]]# drbdadm CREATE-MD MySQL
Error :
' MySQL ' isn't defined in your config (forthis host).
Online said error 4:' DRBD ' notdefined in your config (for this host). This is because it is not loaded into the DRBD module
Solution: Need to specify /etc/hosts inside the host
Normal :
[Email protected] drbd.d]# DRBDADMCREATE-MD my1
Writing Meta Data ...
Initializing activity log
Not initializing bitmap
New DRBD meta data Block successfullycreated.
[Email protected] drbd.d]# Drbdadm create-mdmy1
Writing Meta Data ...
Initializing activity log
Not initializing bitmap
New DRBD meta data Block successfullycreated.
Start DRBD
/usr/local/drbd/etc/rc.d/init.d/drbdstart
cp/usr/local/drbd/etc/rc.d/init.d/drbd/etc/init.d/
Chkconfig ADDDRBD
[Email protected]]# ps-ef|grep DRBD
Root 13262 2 0 13:46? 00:00:00 [Drbd-reissue]
Root 13600 2 0 15:42? 00:00:00 [Drbd_submit]
Root 13604 2 0 15:42? 00:00:00 [Drbd_w_my1]
Root 13614 2 0 15:42? 00:00:00 [Drbd_r_my1]
Root 13621 2 0 15:42? 00:00:00 [Drbd_a_my1]
Root 13625 2384 0 15:43 pts/1 00:00:00 grep DRBD
View status
[Email protected]]#/USR/LOCAL/DRBD/ETC/RC.D/INIT.D/DRBD Status
DRBD driverloaded OK; Device Status:
version:8.4.3 (api:1/proto:86-101)
git-hash:89a294209144b68adb3ee85a73221f964d3ee515 build by [email protected],2014-05-09 13:43:20
M:res CS ro ds p mounted fstype
0:my1 Connected secondary/secondary inconsistent/inconsistent C
[[Email protected]]# CAT/PROC/DRBD
version:8.4.3 (api:1/proto:86-101)
git-hash:89a294209144b68adb3ee85a73221f964d3ee515 build by [email protected],2014-05-09 13:43:20
0:cs:connected ro:secondary/secondaryds:inconsistent/inconsistent C R-----
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0ua:0 ap:0 ep:1 wo:f oos:5236960
[[Email protected]]#
settings for the master node (primary)
DRBDSETUPPRIMARY/DEV/DRBD0--force Configuration as the primary node
Mount Device (primary)
Description: Mount Before the DRBD partition, first verify that the DRBD partition of the current host is the primary state and that the status can be queried through the Cat/proc/drdb command.
Create File System (primary)
Mkfs.ext4/dev/drbd0
Mount Device (primary)
Mount/dev/drbd0/data--->dbdata
Test
[[Email protected]]# touch {1..9}
Uninstall downgrade
[[Email protected]~]# umount/data
[Email protected]~]# drbdsetup/dev/drbd0 Secondary
Upgrade, then mount, view
[Email protected]]# drbdsetup/dev/drbd0 Primary
[[Email protected]]# mount/dev/drbd0/data
[Email protected]]# ls
[[Email protected]]# cd/data/
[Email protected]]# ls
1 2 3 4 5 6 7 8 9 ABC Lost+found rzsz-3.48.tar.gz
three . configuration File Description
The above related configuration file description:
Cat/etc/drbd.d/global_common.conf
Global {
Usage-count No; #? canceling The DRBD user statistics
# Minor-count Dialog-refresh disable-ip-verification
}
Common {
Protocol C; #? Select the C protocol for DRBD
Startup {#? Start Delay Configuration
Wfc-timeout 120;
Degr-wfc-timeout 120;
}
Disk {#?fence anti-brain crack
On-io-error detach;
Fencing resource-only;
}
NET {
Cram-hmac-alg "SHA1"; #? communication algorithms used by the primary and standby nodes
Shared-secret "Mydrbdlab";
}
Syncer {
Rate 100M; #? sync rate, depending on bandwidth
}
}
Cat/etc/drbd.d/web.res
Resource Web {#?web is a resource name
On Master-nfs {#?master-nfs is the node name
device/dev/drbd0; #? Defining virtual Devices
DISK/DEV/SDB1; #? Specify a real device
Address 192.168.2.1:7789; #? listening to itself IP Port
Meta-disk internal;
}
On Slave-nfs {
device/dev/drbd0;
DISK/DEV/SDB1;
Address 192.168.2.2:7789;
Meta-disk internal;
}
}
Eof
This article is from the "Small Box" blog, please be sure to keep this source http://zhangxiaohe.blog.51cto.com/7821029/1409978