a) drbd-8.3.2.tar.gz(主备)
b) mysql-5.0.27.tar.gz(主备)
二、安装步骤
a) Cd /var/local/software
b) Tar zxvf drbd-8.3.2.tar.gz
c) Cd drbd-8.3.2
d) Make
e) Make install
f) Insmod drbd/drbd.ko
g) Lsmod |grep drbd
h) Vi /etc/hosts
59.64.28.22 vm1
59.64.28.57 vm2
j) vi /etc/drbd.conf
global { usage-count yes; }
common { syncer { rate 10M; } }
resource r0 {
protocol C;
startup {
degr-wfc-timeout 120;
}
#disk {
# on-io-error detach;
#}
net {
cram-hmac-alg sha1;
shared-secret "FooFunFactory";
}
#syncer {
# rate 10M;
# al-extents 257;
#}
on vm1 {
device /dev/drbd0;
disk /dev/sda3;
address 59.64.28.22:7788;
meta-disk internal;
}
on vm2 {
device /dev/drbd0;
disk /dev/sda3;
address 59.64.28.57:7788;
meta-disk internal;
}
}
k) mkfs.ext3 /dev/sda3
l) dd if=/dev/zero of=/dev/sda3 bs=1M count=1
m) drbdadm create-md r0(主上执行)
n) /etc/init.d/drbd start
o) drbdsetup /dev/drbd0 primary �Co
p) drbdadm primary r0
q) drbdadm secondary r0
r) mkdir /mnt/drdb
s) mount /dev/drbd0 /mnt/drbd
t) 注:备机DRBD设备无法被挂载
u) 安装MYSQL配置如下
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/mnt/drbd/ \
--disable-maintainer-mode \
--with-mysqld-user=mysql \
--with-unix-socket-path=/tmp/mysql.sock \
--without-comment \
--without-debug \
--with-bench \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
三、主备切换
a) service mysql stop
b) umount /dev/drb0;
c) /etc/init.d/drbd stop
d) drbdadm primary r0
e) mount /dev/drbd0 /mnt/drbd
f) drbdadm secondary r0
四、相关命令
a) /etc/init.d/drbd status //查看主同步情况
drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by [email protected], 2010-11-24 19:22:37
m:res cs ro ds p mounted fstype
0:r0 Connected Primary/Secondary UpToDate/UpToDate C /mnt/drbd ext3
b) /etc/init.d/drbd status //查看备同步情况
drbd driver loaded OK; device status:
version: 8.3.2 (api:88/proto:86-90)
GIT-hash: dd7985327f146f33b86d4bff5ca8c94234ce840e build by [email protected], 2010-08-14 14:56:54
m:res cs ro ds p mounted fstype
0:r0 Connected Secondary/Primary UpToDate/UpToDate C
c) /etc/init.d/drbd start/stop/status
d) cat /proc/drbd
e) drbdsetup /dev/drbd1 primary �Co
f) drbdadm create-md r0
g) dd if=/dev/zero of=/dev/sda2 bs=1M count=1
h) drbdadm secondary r0
i) drbdadm primary r0
j) umount /dev/drbd0