时间:2021-07-01 10:21:17 帮助过:26人阅读
2.
192.168
.
253.129
drbd1
3.
192.168
.
253.140
drbd2
部署mysql的高可用高扩展集群
1.
[root@drbd1 ~]
# mke2fs -j /dev/sda
2.
[root@drbd1 ~]
# mkdir /database
3.
[root@drbd1 ~]
# mount /dev/sda /database/
4.
[root@drbd1 ~]
# mount -a
5.
[root@drbd1 ~]
# mount
6.
[root@drbd1 ~]
# df -h | grep /database
7.
/
dev
/
sda
20G
173M
19G
1
%
/
database
DRBD的部署
1.
[root@drbd1 ~]
# uname -a
2.
<a href
=
"http://www.it165.net/os/oslin/"
target
=
"_blank"
class
=
"keylink"
>Linux<
/
a> drbd1
2.6
.
32
-
220.el6
.x86_64
#1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/<a href="http://www.it165.net/os/oslin/" target="_blank" class="keylink">Linux</a>
通过yum安装drbd服务
默认centos6.x中并没有提供DRBD的源,这时要么采用源码编译方法,要么使用第三方的YUM源。这里使用了http://elrepo.org/tiki/tiki-index.php提供的源
1.
rpm
-
Uvh http:
/
/
elrepo.org
/
elrepo
-
release
-
6
-
5.el6
.elrepo.noarch.rpm
2.
[root@drbd1 yum.repos.d]
# rpm -qa | grep elrepo-release
3.
elrepo
-
release
-
6
-
5.el6
.elrepo.noarch
实际上就是往yum.repos.d里面添加一个源配置elrepo.repo
使用yum list查看,进行安装
1.
[root@drbd1 yum.repos.d]
# yum list all | grep drbd
2.
drbd83
-
utils.x86_64
8.3
.
16
-
1.el6
.elrepo elrepo
3.
drbd84
-
utils.x86_64
8.4
.
4
-
2.el6
.elrepo elrepo
4.
kmod
-
drbd83.x86_64
8.3
.
16
-
1.el6
.elrepo elrepo
5.
kmod
-
drbd84.x86_64
8.4
.
4
-
1.el6
.elrepo elrepo
6.
[root@drbd1 ]
# yum --enablerepo=elrepo install drbd83-utils kmod-drbd83
检查DRBD是都安装成功,若安装完成,让内核加载DRBD模块
复制样例配置文件为即将使用的配置文件
1.
vim
/
usr
/
share
/
doc
/
drbd83
-
utils
-
8.3
.
16
/
drbd.conf.example
配置DRBD
1.
[root@drbd1 etc]
# vim /etc/drbd.conf
2.
# You can find an example in /usr/share/doc/drbd.../drbd.conf.example
3.
include
"drbd.d/global_common.conf"
;
4.
include
"drbd.d/*.res"
;
配置 vim /etc/drbd.d/global_common.conf
01.
vim
/
etc
/
drbd.d
/
global_common.conf
02.
global
{
03.
usage
-
count no;
04.
# minor-count dialog-refresh disable-ip-verification
05.
}
06.
common {
07.
protocol C;
08.
handlers {
09.
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"
;
10.
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"
;
11.
local
-
io
-
error
"/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f"
;
12.
# fence-peer "/usr/lib/drbd/crm-fence-peer.sh";
13.
# split-brain "/usr/lib/drbd/notify-split-brain.sh root";
14.
# out-of-sync "/usr/lib/drbd/notify-out-of-sync.sh root";
15.
# before-resync-target "/usr/lib/drbd/snapshot-resync-target-lvm.sh -p 15 -- -c 16k";
16.
# after-resync-target /usr/lib/drbd/unsnapshot-resync-target-lvm.sh;
17.
}
18.
startup {
19.
#wfc-timeout 120;
20.
#degr-wfc-timeout 120;
21.
}
22.
disk {
23.
on
-
io
-
error detach;
24.
#fencing resource-only;
25.
}
26.
net {
27.
cram
-
hmac
-
alg
"sha1"
;
28.
shared
-
secret
"mydrbdlab"
;
29.
}
30.
syncer {
31.
rate
1000M
;
32.
}
33.
}
配置/etc/drbd.d/web.res
01.
[root@drbd2 etc]
# vim /etc/drbd.d/web.res
02.
resource web {
03.
on drbd1 {
04.
device
/
dev
/
drbd0;
05.
disk
/
dev
/
sda;
06.
address
192.168
.
253.129
:
7789
;
07.
meta
-
disk internal;
08.
}
09.
on drbd2 {
10.
device
/
dev
/
drbd0;
11.
disk
/
dev
/
sda;
12.
address
192.168
.
253.140
:
7789
;
13.
meta
-
disk internal;
14.
}
15.
}
启动DRBD
1.
[root@drbd1 ~]
# drbdadm create-md all
2.
Writing meta data...
3.
initializing activity log
4.
NOT initialized bitmap
5.
New drbd meta data block successfully created.
启动DRBD时,可能出现以下错误
01.
[root@drbd1 ~]
# drbdadm create-md all
02.
md_offset
21474832384
03.
al_offset
21474799616
04.
bm_offset
21474144256
05.
Found ext3 filesystem
06.
20971520
kB data area apparently used
07.
20970844
kB left usable by current configuration
08.
Device size would be truncated, which
09.
would corrupt data
and
result
in
10.
‘access beyond end of device‘
errors.
11.
You need to either
12.
*
use external meta data (recommended)
13.
*
shrink that filesystem first
14.
*
zero out the device (destroy the filesystem)
15.
Operation refused.
16.
Command
‘drbdmeta 0 v08 /dev/sda internal create-md‘
terminated with exit code
40
17.
drbdadm create
-
md web: exited with code
40
这事需要如下命令覆盖文件系统中的设备块信息
1.
[root@drbd1 ~]
# dd if=/dev/zero of=/dev/sda bs=1M count=128
2.
记录了
128
+
0
的读入
3.
记录了
128
+
0
的写出
4.
134217728
字节(
134
MB)已复制,
0.448662
秒,
299
MB
/
秒
再重新启动DRBD,可以通过dmesg命令查看DRBD的启动过程
ysql+heartbeat+DRBD+LVS实现mysql高可用
标签: