|
DRBD its open source, simple, efficient and impressive performance for the majority who favored the operation and maintenance. The main function of the device is a block-level data between two of the same size synchronous mirroring on different nodes. drbd is a kernel module and associated scripts constituted for building high availability clusters. This paper describes its installation, for your reference.
DRBD about features, functions, and basic knowledge, you can refer to: DRBD Principles and Features Overview
A demonstration environment
OS version: CentOS release 6.5 (Final)
orasrv1: 192.168.21.10
orasrv2: 192.168.21.13
DRBD version Version: 8.3.15 (api: 88)
Two, yum install drbd (two-node)
1, following installation through yum way
Configuring epel source can be downloaded from here, or direct access mode with wget
http://download.Fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# Wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# Rpm -Uvh epel-release-6-8.noarch.rpm
# Yum -y install drbd83 kmod-drbd83
# Modprobe drbd
# Lsmod | grep drbd
drbd 345363 0
2, the configuration section, refer to the third point of the subsequent compilation install drbd Part 4 dots
### Note, when installed via yum, drbd different profile directory
### Drbd.conf file is placed under the / etc directory, and the remaining two profiles stored in the directory /etc/drbd.d 1
Third, the compiler install drbd
1, install user space tools (two-node)
# Yum -y install kernel-devel kernel-headers flex gcc
# Pwd
usr / local / src ### drbd archive storage location
# Tar -xvf drbd-8.3.15.tar.gz
# Cd drbd-8.3.15
# ./configure --prefix = / Usr / local / drbd --with-km
# Make KDIR = / usr / src / kernels / 2.6.32-431.el6.x86_64 /
# Make install
# Ls / usr / local / drbd / ## View installed files
etc lib sbin share var
# Cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/init.d/drbd
# Chkconfig --add drbd
# Chkconfig drbd on1
2, install drbd module (two-node)
# Cd /usr/local/src/drbd-8.3.15/drbd
# Make clean
# Make KDIR = / usr / src / kernels / 2.6.32-431.el6.x86_64 /
# Cp drbd.ko / lib / modules / `uname -r` / kernel / lib /
# Depmod
# Modprobe drbd ### drbd module loaded into the Linux kernel
NOTE: /usr/src/kernels/2.6.18-274.18.1.el5-i686/ kernel source tree path needs according to their own system modifications.
3. Verify drbd kernel loads (two-node)
# Lsmod | grep drbd
drbd 345363 0
4, configure the system disk (two-node)
This example ### species currently assigned to separate 2 node / dev / sdb disk, following the completion of the second node
# Fdisk / dev / sdb ### sequentially input n, p, 1, a carriage return (enter), carriage return (enter), w
# Partprobe ### If you still can not see the partition, reboot and find out why
# Fdisk -l / dev / sdb1
5. Configure drbd.conf and global_common.conf (two-node)
# Mv /usr/local/drbd/etc/drbd.conf /usr/local/drbd/etc/drbd.conf.bk
# Cp /usr/local/src/drbd-8.3.15/scripts/drbd.conf /usr/local/drbd/etc/drbd.conf
See # more /usr/local/drbd/etc/drbd.conf ### drbd.conf should include the following contents include
# You can find an example in /usr/share/doc/drbd.../drbd.conf.example
include "drbd.d / global_common.conf";
include ". drbd.d / * res";
# Mv /usr/local/drbd/etc/drbd.d/global_common.conf /usr/local/drbd/etc/drbd.d/global_common.conf.bk
# Vi /usr/local/drbd/etc/drbd.d/global_common.conf ### global_common.conf can refer drbd.conf.example
global {
usage-count yes;
# Minor-count dialog-refresh disable-ip-verification
}
common {
protocol C;
handlers {
}
startup {
wfc-timeout 0; degr-wfc-timeout 120;
}
disk {
on-io-error detach;
}
net {
# Sndbuf-size rcvbuf-size timeout connect-int ping-int ping-timeout max-buffers
# Max-epoch-size ko-count allow-two-primaries cram-hmac-alg shared-secret
# After-sb-0pri after-sb-1pri after-sb-2pri data-integrity-alg no-tcp-cork
cram-hmac-alg sha1;
shared-secret "MySQL-HA";
}
syncer {
# Rate after al-extents use-rle cpu-mask verify-alg csums-alg
rate 35M;
}
}
### Configuration resource file redisk.res
# Vi /usr/local/drbd/etc/drbd.d/redisk.res
resource redisk {
on orasrv1.xlk.com {
device / dev / drbd0;
disk / dev / sdb1;
address 192.168.21.10:7789;
meta-disk internal;
}
on orasrv2.xlk.com {
device / dev / drbd0;
disk / dev / sdb1;
address 192.168.21.13:7789;
meta-disk internal;
}
}
### Can also directly copy the configuration file to node 2, you do not need to configure two separate configuration file copy mode, as follows:
# Scp /usr/local/drbd/etc/drbd.d/* 192.168.21.13:/usr/local/drbd/etc/drbd.d/
# Scp /usr/local/drbd/etc/drbd.conf 192.168.21.13:/usr/local/drbd/etc/
6, create a device metadata (two-node execution)
# Drbdadm create-md redisk
Writing meta data ...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
[Root @ orasrv1 drbd.d] # drbdadm up redisk
[Root @ orasrv1 drbd.d] # /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.15 (api: 88 / proto: 86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by root@orasrv1.xlk.com, 2015-10-31 09:16:05
m: res cs ro ds p mounted fstype
0: redisk WFConnection Secondary / Unknown Inconsistent / DUnknown C1
5, set the Primary node (master node)
The following operation is only executed in the node 1 (orasrv1)
# Drbdadm primary --force redisk
0: State change failed: (-2) Need access to UpToDate data
Command 'drbdsetup 0 primary' terminated with exit code 17
# Drbdadm - --overwrite-data-of-peer primary redisk
# Mkfs.ext3 / dev / drbd0
# Mkdir / data
# Mount / dev / drbd0 / data
# Df -h | grep data
/ Dev / drbd0 2.0G 36M 1.9G 2% / data
### Create / data directory on the second node
# Mkdir / data
### See drbd status information:
#cat / proc / drbd
Four, DRBD data mirroring function test
### First, complete the following operations at the primary site
# Cp -R / usr / local / drbd / data
# Ls / data / drbd
etc lib sbin share var
# Du -sh / data / drbd
324K / data / drbd
# Umount / data
# Drbdadm secondary redisk
# Cat / proc / drbd
version: 8.3.15 (api: 88 / proto: 86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by root@orasrv1.xlk.com, 2015-10-31 10:58:13
0: cs: Connected ro: Secondary / Secondary ds: UpToDate / UpToDate C r -----
ns: 1044700 nr: 0 dw: 33780 dr: 1045517 al: 3 bm: 64 lo: 0 pe: 0 ua: 0 ap: 0 ep: 1 wo: f oos: 0
### Completed the following in the standby node
# Drbdadm primary redisk
# Cat / proc / drbd
version: 8.3.15 (api: 88 / proto: 86-97)
GIT-hash: 0ce4d235fc02b5c53c1c52c53433d11a694eab8c build by root@orasrv2.xlk.com, 2015-10-31 10:59:26
0: cs: Connected ro: Primary / Secondary ds: UpToDate / UpToDate C r -----
ns: 0 nr: 1044700 dw: 1044700 dr: 672 al: 0 bm: 64 lo: 0 pe: 0 ua: 0 ap: 0 ep: 1 wo: f oos: 0
# Mount / dev / drbd0 / data
# Du -sh / data / drbd ### two-node data and directory exactly the same size
324K / data / drbd |
|
|
|