Centos搭建TFSNameserverHA


背景

tfs要求用gcc 4.1.2编译,两种方案1是用centos5(自带gcc 4.1.2), 2使用centos6把gcc降到4.1.2。我使用的是第一个方法成功运行tfs,当做HA的时候问题来了,官方要求是用heartbeat 3.x,centos5是2.x。开始选择在centos5下编译heartbeat 3成功,但还需要编译pacemaker,编译的时候遇到些问题,可能是版本匹配,依赖不全等,就算编译通过考虑后续还需要编译XXX岂不浪费时间,毕竟centos5已经很老了。

于是决定把centos5编译的tfs放到centos6里成功运行,在centos6里搭建HA。

这种方式存在问题是在centos6的tfs部分运维命令不好用,无法加载xxx依赖库。解决方法是使用centos5中的运维命令即可。(从长远看还是把centos6 gcc降到4.1.2,有空再说吧)

好了言归正传。

系统环境

nameserver1 master 192.168.6.129eth0

nameserver2 slave 192.168.6.128 eth0

vip192.168.6.100 (vip eth0:0)

(开启方貌似不用手动执行 ifconfig eth0:0 192.168.6.100 netmask 255.255.255.0 up)

系统都是vmware安装的centos6.6.。

首先安装包

yum install heartbeat

还需要安装pacemaker这里需注意不要用yum安装,因为安装的pacemaker是1.1.12版本,pacemaker在1.1.8版本之后把crm分离出去了,所以下载了pacemaker-1.1.7版本编译安装(http://down1.chinaunix.net/distfiles/pacemaker-1.1.7.tar.gz)

编译前先安装依赖

yum install perl-TimeDate OpenIPMI-libs lm_sensors libxslt libibverbs librdmacm pkgconfig libtool intltool gettext-devel glib2-devel python-devel libxml2-devel pam-devel ncurses-devel pygtk2 libtool-ltdl libqb clusterlib libtool-ltdl-devel swig gnutls-devel resource-agents clusterlib cluster-glue-libs-devel heartbeat-devel

(注意使用了epel源。)


#tar –vxf pacemaker-1.1.7.tar.gz

#cd ClusterLabs-pacemaker-b5b0a7b

#./ autogen.sh

#./ configure

#make && make install

以上两台主机都要装。



配置namesever

两台主机的namesever的ns.conf

[public]

#vip

ip_addr = 192.168.6.100

#监听端口

port =8108

[nameserver]

ip_addr_list = 192.168.6.129|192.168.6.128

上面几项在两台主机写法一样,其他项都不变,只关注这些就行。

配置hearbeat

假设两台主机名称为

192.168.6.129 test1

192.168.6.128 test2

(test1,test2修改成你的主机名,在test1上直接执行ping test2能通表示正确,修改主机名参照http://blog.csdn.net/l241002209/article/details/42269435)

然后在test1上执行

#cd $TBLIB_ROOT/scripts/ha/

#vi ha.cf

debugfile /var/log/ha-debug

debug 1

keepalive 2

warntime 5

deadtime 10

initdead 30

auto_failback off

autojoin none

ucast eth0 192.168.6.128 <--注意这里是对端的地址

udpport 694

node tes1

node test2

compression bz2

logfile /var/log/ha-log

logfacility local0

crm respawn

(修改完成保存退出:wq)

#./deploy

#./nsdep

然后在test2上执行

#cd $TBLIB_ROOT/scripts/ha/

#vi ha.cf

debugfile /var/log/ha-debug

debug 1

keepalive 2

warntime 5

deadtime 10

initdead 30

auto_failback off

autojoin none

ucast eth0 192.168.6.129 <--注意这里是对端的地址

udpport 694

node tes1

node test2

compression bz2

logfile /var/log/ha-log

logfacility local0

crm respawn

(修改完成保存退出:wq)

#./deploy

#./nsdep

两台主机的authkeys必须统一

在test1执行

#sudo scp /etc/ha.d/authkeys root@192.168.6.128:/etc/ha.d/

(root用户不加sudo,下面不在赘述)

配置crm

在test1,test2分别执行

#sudo vi /etc/passwd

找到hacluster:x:498:498:heartbeat user:/var/lib/heartbeat/cores/hacluster: /sbin/nologin(基本上在最后一行)

把最后的/sbin/nologin改成/bin/bash

(修改完成保存退出:wq)

#sudo passwd hacluster

密码自己设,输入两遍。

#su hacluster

输密码

#crm_attribute --type crm_config--attr-name symmetric-cluster --attr-value true

#crm_attribute --type crm_config--attr-name stonith-enabled --attr-value false

#crm_attribute --type rsc_defaults --nameresource-stickiness --update 100

(注意如果提示连不上什么的错误,请先启动heartbeat, #sudo service heartbeat start)

# exit

#vi ns.xml

…………

<instance_attributesid="ip-alias-instance_attributes">

<nvpair id="ip-alias-instance_attributes-ip"name="ip" value="192.168.6.100"/>

<nvpair id="ip-alias-instance_attributes-nic"name="nic" value="eth0:0"/>

</instance_attributes>

<operations>

…………..

<primitive class="ocf"id="tfs-name-server" provider="heartbeat"type="NameServer">

<instance_attributesid="tfs-name-server-instance_attributes">

<nvpair id="tfs-name-server-instance_attributes-basedir"name="basedir" value="这里写tfs的安装路径"/>

<nvpair id="tfs-name-server-instance_attributes-nsip"name="nsip" value="192.168.6.129"/>(注意tes1写192.168.6.129,test2写192.168.6.128,其他标红的地方也要根据主机实际情况写。作者其他都是相同的)

<nvpair id="tfs-name-server-instance_attributes-nsport"name="nsport" value="8108"/>

<nvpair id="tfs-name-server-instance_attributes-user"name="user" value="启动tfs的用户名"/>

</instance_attributes>


………………

(修改完成保存退出:wq)

#sudo cp ns.xml /var/lib/heartbeat/crm/

#sudo chown hacluster:haclient /var/lib/heartbeat/crm/ns.xml

#su hacluster

#cibadmin --replace --obj_type=resources--xml-file /var/lib/heartbeat/crm/ns.xml

#exit

#sudo service heartbeat start (注意之前启动过了就是restart)

验证HA

启动后需等待片刻或

# sudo tail -f /var/log/ha-log (实时查看,不想看了ctrl+c)

在test1,test2分别执行netstat –lntp

会发现只有一台主机有nameserver进程

\

\在有此进程的主机上执行(换成你的进程号)

#sudo kill 49148

然后去另一台主机上执行(可能需要等几秒)

#netstat –lntp

会发现nameserver启动了。

说明当有一台主机的nameserver暴走,HA的另一台主机会启动nameserver来保证tfs正常运作。


相关内容

    暂无相关文章