全部博文(80)
分类: 云计算
2011-12-25 13:22:57
用途:
解决mfs master的单点问题,同样可以作为其他需要高可用环境的标准配置方法
规划:
使用drbd实现主备机的灾容,Heartbeat做心跳监测,Pacemaker实现服务(资源)的切换及控制等
描述:
drbd双主模式对网络和配置要求比较高,在此结构下不采用;
drbd需要清空一个分区,并且不能格式化
可单独由heartbeat实现服务的切换及failover;
需要ha项目中的其他组件,如GLUE和ResourceAgent。
软件:
DRBD下载地址:
DRBD 8.3.9:
HA下载地址:
Heartbeat 3.0.4:
Cluster Glue 1.0.7:
Resource Agents 1.0.3:
Pacemaker 1.0.5:
mfs下载:
moosefs 1.6.20:
环境:
mfsmaster:192.168.1.1
mfsbackup:192.168.1.2
VIP:192.168.1.10
安装:
设置hosts:
# vi /etc/hosts
192.168.1.1 mfs.master
192.168.1.2 mfs.backup
DRBD:
# wget
# tar zxvf drbd-8.3.9.tar.gz
# cd drbd-8.3.9
# ./configure --prefix=/usr/local/drbd --with-km
# make && make install
# vi /usr/local/drbd/etc/drbd.d/global_common.conf
syncer {
# rate after al-extents use-rle cpu-mask verify-alg csums-alg
rate 100M;
}
# vi /usr/local/drbd/etc/drbd.d/mfs.res
resource mfs {
device /dev/drbd0;
disk /dev/lvm/mfsdata;
meta-disk internal;
on mfs.master {
address 192.168.1.1:7789;
}
on mfs.backup {
address 192.168.1.2:7789;
}
}
# cp /usr/local/drbd/etc/rc.d/init.d/drbd /etc/init.d/
# insmod /lib/modules/2.6.18-8.el5/kernel/drivers/block/drbd.ko
# modprobe drbd
# chkconfig --add drbd
# chkconfig --level 35 drbd on
# service drbd start
# drbdadm create-md all
# mkfs.ext3 /dev/drbd0
# vi /etc/fstab
/dev/drbd0 /mfsmeta ext3 defaults,noatime,nodiratime 0 0
以上主备机同样的配置,查看同步状态:
# cat /proc/drbd
GIT-hash: 1c3b2f71137171c1236b497969734da43b5bec90 build by , 2010-12-20 19:19:37
0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:89190240 nr:613604 dw:89803844 dr:620461 al:45275 bm:5 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
在主机上执行:
# drbdsetup /dev/drbd0 primary -o
# mount /mfsmeta
至此drbd安装完成,可以根据文档,做一些测试。
MFS:
# wget
# tar zxvf mfs-1.6.20-2.tar.gz
# cd mfs-1.6.20
# ./configure --prefix=/usr/local/mfs
# make
# make install
# vi /usr/local/mfs/etc/mfsmaster.cfg
DATA_PATH = /mfsdata/metalog
# mkdir /mfsmeta/metalog
# chown nobody.nobody /mfsmeta/metalog
设置临时hosts,测试mfs启动:
# vi /etc/hosts
192.168.1.1 mfsmaster
# /usr/local/mfs/sbin/mfsmaster start
mfs master安装完成,其他的chunkserver安装和详细配置,请参考文档。
HA:
配置:
# export PREFIX=/usr
# export LCRSODIR=$PREFIX/libexec/lcrso
# export CLUSTER_USER=hacluster
# export CLUSTER_GROUP=haclient
# getent group ${CLUSTER_GROUP} >/dev/null || groupadd -r ${CLUSTER_GROUP}
#
getent passwd ${CLUSTER_USER} >/dev/null || useradd -r -g
${CLUSTER_GROUP} -d /var/lib/heartbeat/cores/hacluster -s /sbin/nologin
-c "cluster user" ${CLUSTER_USER}
GLUE:
# wget -O cluster-glue.tar.bz2
# tar jxvf cluster-glue.tar.bz2
# cd Reusable-Cluster-Components-*
# ./autogen.sh && ./configure --prefix=$PREFIX --with-daemon-user=${CLUSTER_USER} --with-daemon-group=${CLUSTER_GROUP}
# make
# make install
Resource Agent:
# wget -O resource-agents.tar.bz2
# tar jxvf resource-agents.tar.bz2
# cd Cluster-Resource-Agents-*
# ./autogen.sh && ./configure --prefix=$PREFIX
# make
# make install
Heartbeat:
# wget -O heartbeat.tar.bz2http://hg.linux-ha.org/dev/archive/tip.tar.bz2
# tar jxvf heartbeat.tar.bz2
# cd Heartbeat-*
# ./bootstrap && ./configure --prefix=$PREFIX
# make
# make install
# cp doc/ha.cf $PREFIX/etc/ha.d/
# cp doc/authkeys $PREFIX/etc/ha.d/
# chmod 0600 $PREFIX/etc/ha.d/authkeys
配置heartbeat:
# vi $PREFIX/etc/ha.d/ha.cf
debugfile /opt/logs/heartbeat/ha-debug
logfile /opt/logs/heartbeat/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
ucast eth0 192.168.1.2
auto_failback on
ping 192.168.1.254
respawn hacluster /usr/lib64/heartbeat/ipfail
crm on
# service heartbeat start
具体配置说明请参考文档。
Pacemaker:
# wget -O pacemaker.tar.bz2
# tar jxvf pacemaker.tar.bz2
# cd Pacemaker-1-0-*
# ./autogen.sh && ./configure --prefix=$PREFIX --with-lcrso-dir=$LCRSODIR
# make
# make install
# ldconfig -v
# crm
crm(live)# configure node mfs.master
crm(live)# configure node mfs.backup
crm(live)# configure primitive
mfsmaster_drbd ocf:linbit:drbd params drbd_resource="mfs"
drbdconf="/usr/local/drbd/etc/drbd.conf" meta migration-threshold="10"
crm(live)# configure monitor mfsmaster_drbd 30s:20s
crm(live)# configure primitive mfsmaster_fs ocf:heartbeat:Filesystem params device="/dev/drbd0" directory="/mfsmeta" fstype="ext3"
crm(live)# configure primitive mfsmaster_vip ocf:heartbeat:IPaddr2 params ip="192.168.1.10" nic="eth0:0"
crm(live)# configure primitive mfsmaster lsb:mfsmaster
crm(live)# configure monitor mfsmaster 30s:30s
crm(live)# configure group mfsmaster_group mfsmaster_vip mfsmaster_fs mfsmaster
crm(live)# configure ms mfsmaster_drbd_ms mfsmaster_drbd meta master-max="1" master-node-max="1" clone-max="2" clone-node-max="1" notify="true"
crm(live)# configure colocation mfsmaster_colo inf: mfsmaster_group mfsmaster_drbd_ms:Master
crm(live)# configure order mfsmaster_order inf: mfsmaster_drbd_ms:promote mfsmaster_group:start
crm(live)# configure property
$id="cib-bootstrap-options" expected-quorum-votes="2"
stonith-enabled="false" no-quorum-policy="ignore"
start-failure-is-fatal="false"
crm(live)# configure commit
crm(live)# quit
设置VIP为mfsmaster:
# vi /etc/hosts
192.168.1.10 mfsmaster
可以使用crm_mon查看资源状态,如果正常应该是类似:
# crm_mon
============
Last updated: Sun Jan 23 14:01:53 2011
Stack: Heartbeat
Current DC: mfs.backup (985860ea-ae2b-4490-b7e9-19f902321358) - partition with quorum
Version: 1.0.10-b0266dd5ffa9c51377c68b1f29d6bc84367f51dd
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ mfs.master mfs.backup ]
Resource Group: mfsmaster_group
mfsmaster_vip (ocf::heartbeat:IPaddr2): Started mfs.master
mfsmaster_fs (ocf::heartbeat:Filesystem): Started mfs.master
mfsmaster (lsb:mfsmaster): Started mfs.master
Master/Slave Set: mfsmaster_drbd_ms
Masters: [ mfs.master ]
Slaves: [ mfs.backup ]
至此,mfs的高可用环境搭建完成,可以使用crm node stndby和crm node online进行资源测试。
相关: