存档

文章标签 ‘ha’

Linux集群的安装与配置(Part II,配置)

2009年8月13日 baalchina 没有评论

Heartbeat的配置文件主要是3个,也就是前面我们cp到/etc/ha.d下面的ha.cfharesources以及authkeys,作用可以理解为系统配置,资源配置,以及认证的设置。一个个搞定。

 

ha.cf

配置比较简单,保证能跑起来

#logfile
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility     local0

#time setting
keepalive 2
deadtime 30
warntime 10
initdead 120

#network setting
udpport 694
bcast eth1
ucast eth1 192.168.100.2

#node setting
auto_failback on
node    linux-ha-a
node    linux-ha-b

我这边跑的是双网卡。其中eth1作为心跳线,配置了192.168.100.1/2两个地址。

haresources

最简配制的话其实就是一条:

 

#this is resource config
linux-ha-a 210.28.92.233 httpd::start

三段:

主机名,集群的ip,需要启动的服务::传递给这个服务的参数。

文件介绍上说两台设备的haresources要完全一样,你可别真的完全一样把主机名也一样了…哈。

 

 

authkeys

这个支持3种认证方式,sha1>md5>crc。其中前两种需要指定密钥。crc只做校验用,没认证的效果。这个文件需要保证600权限。

因为是测试就简单点了,用MD5,验证码用linux-ha的md5值(17bc50a13f1dd31c14f2a3f321e017dc)。实际上直接输入一个字符串就可以了,没必要输入md5的值。

 

注意这个类似于eigrp的认证,是支持多个key-chain的。

auth 1
#1 crc
#2 sha1 HI!
1 md5 17bc50a13f1dd31c14f2a3f321e017dc

注意auth 1必须对应下面的1 md5 key

 

检测效果/MAC切换机制

全部配置完成之后可以打开虚拟ip地址,网页可以打开,然后再关掉server-a的接口,然后再刷新,看看可否看到页面?

我做的时候没自动切换,结果跑到交换机上#clea ip arp 才有效…郁闷…注意这个MAC地址:

MAC:

210.xx.yy.231   0          0050.56af.15fd arpa   VL922
210.xx.yy.232   0          0050.56af.3842 arpa   VL922
210.xx.yy.233   0          0050.56af.3842 arpa   VL922

这时候232这台设备生效。233为虚拟MAC。

可以看到的是,ha并没有诸如HSRP/VRRP那样的虚拟MAC机制。而是直接用的设备的MAC。

你ssh到233,其实就是连接到232。

待解决

如果跑的是http,那么就要考虑共享存储的问题。静态的还好,如果是动态的呢?

如果是数据库,同样要考虑存储。不过mysql本身的cluster应该可以解决--据说是不用共享存储的。

分类: Cluster, Linux 标签: , ,

Linux集群的安装与配置(Part I,安装)

2009年8月11日 baalchina 没有评论

集群的作用有很多,比如HA(high availability),比如负载均衡等。我这里只做HA,保证可用性。

 

软件用的是开源的heartbeat,http://www.linux-ha.org

安装详解:

下载软件包:

#wget http://hg.linux-ha.org/lha-2.1/archive/STABLE-2.1.4.tar.bz2

 

解压编译并安装

 

 

#./ConfigureMe configure

#make

#make install

 

可能会少很多软件包,一个个打上就行了。我的CentOS 5.3,安装的时候自定义只选择开发工具,需要以下的包:

#yum install libnet
#yum install glib2-devel
#yum install libxml2-devel(这个没说,但是后面是需要的)

#yum install PyXML

 

另外需要注意的是,如果他告诉你缺某个包,你yum之后,重新make还是会报错的,需要重新./configure再make。这点比较诡异。

扫尾搞定配置文件

cp doc/ha.cf /etc/ha.d/
cp doc/haresources /etc/ha.d/
cp doc/authkeys /etc/ha.d/
cp ldirectord/ldirectord.cf /etc/ha.d/

 

服务的启动、停止等

 

/etc/rc.d/init.d/heartbeat start | stop | restert| status

 

安装的Troubleshooting

 

configure: WARNING: The following recommended components noted earlier are missing:
     uuid library, Python.h, security/pam_appl.h, gnutls/gnutls.h, gnutls/gnutls.h
    We will continue but you may have lost some non-critical functionality.
configure: error: The following required components noted earlier are missing:
     glib2-devel, libnet
    Please supply them and try again.

./bootstrap exiting due to error (sorry!).

这个是缺少包了。把几个包yum一下就行了。

题外话:

libnet也可以自己编译,这个比较诡异。

wget http://ncu.dl.sourceforge.net/project/libnet/libnet/0.10.11/libnet-0.10.11.tar.gz
cd libnet
cp makfiles/linux.mak port.mak(注意是makfile不是makefile啊)

 

#yum install hearbeat

提示如下:

Installing:
heartbeat               i386       2.1.3-3.el5.centos       extras       1.7 M
Installing for dependencies:
PyXML                   i386       0.8.4-4                  base         1.1 M
heartbeat-pils          i386       2.1.3-3.el5.centos       extras       213 k
heartbeat-stonith       i386       2.1.3-3.el5.centos       extras       311 k

原来是要PyXML这个包,注意大小写

 

接下来继续编译,安装
make又错:

cc1: warnings being treated as errors
xml.c: In function 'write_xml_file':
xml.c:635: warning: unused variable 'in'
xml.c: In function 'get_message_xml':
xml.c:775: error: 'BZ_OK' undeclared (first use in this function)
xml.c:775: error: (Each undeclared identifier is reported only once
xml.c:775: error: for each function it appears in.)
xml.c:796: warning: implicit declaration of function 'BZ2_bzBuffToBuffDecompress'
xml.c:799: error: 'BZ_OUTBUFF_FULL' undeclared (first use in this function)
gmake[3]: *** [xml.lo] 错误 1
gmake[3]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4/lib/crm/common'
gmake[2]: *** [all-recursive] 错误 1
gmake[2]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4/lib/crm'
gmake[1]: *** [all-recursive] 错误 1
gmake[1]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4/lib'
make: *** [all-recursive] 错误 1

这个应该是bz报错,bz是什么?bzip2?

不管了

yum install bzip2-devel

继续

编译完成之后有这个提示:

chown hacluster /var/lib/heartbeat/cores/hacluster
chown: “hacluster”: 无效的用户
gmake[2]: [install-exec-local] 错误 1 (忽略)
chmod 700 /var/lib/heartbeat/cores/hacluster
cd /usr/lib/heartbeat;                          \
        for file in `ls /usr/share/heartbeat`;                  \
        do if [  -d $file ]; then continue; fi; \
                rm -f $file && ln -s /usr/share/heartbeat/$file .;      \
        done
gmake[2]: Nothing to be done for `install-data-am'.
gmake[2]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4'
gmake[1]: Leaving directory `/root/Heartbeat-STABLE-2-1-STABLE-2.1.4'

注意用户问题哦。

 

 

[root@linux-ha-a ~]# /etc/rc.d/init.d/heartbeat start
logd is already running
Starting High-Availability services:
[失败]
heartbeat: udpport setting must precede media statementsheartbeat[20883]: 2009/08/13_06:26:00 ERROR: Invalid user id name [hacluster]
heartbeat[20883]: 2009/08/13_06:26:00 ERROR: Bad uid list [hacluster]
heartbeat[20883]: 2009/08/13_06:26:00 ERROR: Invalid apiauth directive [ipfail uid=hacluster]

这个就是结果啦。

解决方法:

useradd hacluster
groupadd haclient

chown hacluster /var/lib/heartbeat/cores/hacluster
chmod 700 /var/lib/heartbeat/cores/hacluster

 

这个报错:

heartbeat: udpport setting must precede media statementsheartbeat[21237]: 2009/08/13_06:39:21 ERROR: Auth Key [1] not found in keyfile [/etc/ha.d/authkeys]
heartbeat[21237]: 2009/08/13_06:39:21 ERROR: Authentication configuration error.
heartbeat[21237]: 2009/08/13_06:39:21 ERROR: Configuration error, heartbeat not started.

这个有点好玩,意思是udpport的设置必须在media设置之前。但是实际上是authkey报错造成的,解决方法就是正确配置authkey。

分类: Cluster, Linux 标签: , , ,