Chinaunix首页 | 论坛 | 博客
  • 博客访问: 386720
  • 博文数量: 80
  • 博客积分: 1750
  • 博客等级: 上尉
  • 技术积分: 1380
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-13 11:35
文章分类
文章存档

2014年(3)

2013年(1)

2012年(54)

2011年(22)

分类: 云计算

2011-12-25 13:22:57

Drbd+Heartbeat+Pacemaker实现MFS(moosefs)的高可用

用途:
解决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进行资源测试。

相关:
HA体系架构及内部处理流程:http://hi.baidu.com/leolance/blog/item/bd8ff9ca54b0731192457eb3.html
Distributed Replicated Block Device 的高可用性:http://hi.baidu.com/leolance/blog/item/a1591230a6671e2a5ab5f5e1.html
在已有数据的的硬盘上创建drbd高可用复制:http://hi.baidu.com/leolance/blog/item/505eee2e29d4998a023bf60d.html
DRBD使用总结:http://hi.baidu.com/leolance/blog/item/bc64453a2f6c192c70cf6c8a.html
使用heartbeat需要了解的:http://hi.baidu.com/leolance/blog/item/e6608a7a8dd41e2a0cd7daba.html
从​头​开​始​搭​建​集​群​:
moosefs master LSB Resource Agent script (/etc/init.d/mfsmaster):http://hi.baidu.com/leolance/blog/item/c94d8b31b0520599a71e1256.html

来源:http://hi.baidu.com/leolance/blog/item/7ac035205870f020c9955905.html
阅读(2064) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~