环境:centos 6.5 最小化安装,drbd-8.4.6,drbd-utils-8.9.5,在两个系统上新建sdb1分区
1、在主从节点上安装drbd-8.4.6
1
2
3
4
5
6
7
8
9
|
echo
"192.168.100.162 mysql-slave.example.com"
>>
/etc/hosts
echo
"192.168.100.160 mysql-proxy.server.local"
>>
/etc/hosts
yum
install
-y kernel kernel-devel kernel-headers gcc flex libxslt
tar
zxf drbd-8.4.6.
tar
.gz
cd
drbd-8.4.6
make
KDIR=
/usr/src/kernels/2
.6.32-431.el6.x86_64/
make
install
modprobe drbd
lsmod |
grep
drbd
|
2、在主从节点上安装drbd-utils-8.9.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
tar
zxf drbd-utils-8.9.5.
tar
.gz
cd
drbd-utils-8.9.5
.
/configure
--prefix=
/usr/local/drbd
--without-83support
make
make
install
echo
$?
cp
/usr/local/drbd/etc/rc
.d
/init
.d
/drbd
/etc/init
.d
/drbd
chkconfig --add drbd
chkconfig drbd on
vim
/usr/local/drbd/etc/drbd
.conf
global {
usage-count no;
}
common {
syncer { rate 200M; }
}
resource r0 {
protocol C;
startup {
wfc-timeout 120;
degr-wfc-timeout 120;
}
disk {
on-io-error detach;
}
net{
timeout 60;
connect-int 10;
ping
-int 10;
max-buffers 2048;
max-epoch-size 2048;
cram-hmac-alg
"sha1"
;
shared-secret
"Mysql-abcD"
;
}
on mysql-proxy.server.
local
{
device
/dev/drbd0
;
disk
/dev/sdb1
;
address 192.168.100.160:6666;
meta-disk internal;
}
on mysql-slave.example.com {
device
/dev/drbd0
;
disk
/dev/sdb1
;
address 192.168.100.162:6666;
meta-disk internal;
}
}
mkdir
-p
/usr/local/drbd/var/run/drbd
drbdadm create-md r0
service drbd start
service drbd status
|
3、将主节点设置为Primary
1
2
3
4
5
|
drbdadm -- --overwrite-data-of-peer primary all
drbdadm primary all
mkfs.ext4
/dev/drbd0
mkdir
/drbd
mount
/dev/drbd0
/debd
|
4、查看从节点上数据
1
2
3
4
5
6
|
service drbd stop
mkdir
/drbd
mount
/dev/sdb1
/drbd
ls
/drbd
umount
/drbd
service drbd start
|
5、主从节点切换
1
2
3
4
5
6
7
|
#将主节点drbd的状态变为从
umount
/data
drbdadm secondary all
#在从节点上进行挂载
drbdadm primary all
mount
/dev/drbd0
/drbd
ls
/drbd
|
参考博文:
http://xianglinhu.blog.51cto.com/5787032/1659415
https://www.centos.bz/2012/02/drbd-compile-install-deploy/
本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/1729243,如需转载请自行联系原作者