| 搭建基于heartbeat的高可用集群 |
|
| 作者:未知 文章来源:网络收集 点击数: 更新时间:2006-3-24 11:41:33
|
| 欢迎转载引用 copyleft by yzjboy all lefts reserved 2005.06.10 1、 软件下载 heartbeat-1.2.3.tar.gz和相关依赖软件(如果已经安装了开发工具包,一般只需要下载libnet-1.1.0-1.fr.c.1.um.1.i386.rpm即可) www.linux-ha.org 2、 软件安装 rpm –ivh libnet-1.1.0-1.fr.c.1.um.1.i386.rpm tar heartbeat-1.2.3.tar.gz ./configure make make install 3、 软件配置 如果不指定安装路径,默认情况下,配置文件在/usr/local/etc/ha.d/下,而相关可执行程序在/usr/local/lib/heartbeat/下。主要的配置文件有3个,aukeys,ha.cf和haresources。下面具体说一下这3个文件的具体功能以及配置。 在说明配置之前先大致阐述一下heartbeat的工作原理:heartbeat最核心的包括两个部分,心跳监测部分和资源接管部分,心跳监测可以通过网络链路和串口进行,而且支持冗余链路,目前1.2.3版本只支持2个节点间的监测和备份( release 2将支持多个节点,可惜正在开发之中),它们之间相互发送报文来告诉对方自己当前的状态,如果在指定的时间内未受到对方发送的报文,那么就认为对方失效,这时需启动资源接管模块来接管运行在对方主机上的资源或者服务。 3.1 authkeys heartbeat的认证配置文件 # # Authentication file. Must be mode 600 # # # Must have exactly one auth directive at the front. # auth send authentication using this method-id # # Then, list the method and key that go with that method-id # # Available methods: crc sha1, md5. Crc doesn't need/want a key. # # You normally only have one authentication method-id listed in this file # # Put more than one to make a smooth transition when changing auth # methods and/or keys. # # # sha1 is believed to be the "best", md5 next best. # # crc adds no security, except from packet corruption. # Use only on physically secure networks. # #auth 1 #1 crc #2 sha1 HI! #3 md5 Hello! 注释说得很清楚,在这里我还是解释一下,该文件主要是用于集群中两个节点的认证,采用的算法和密钥(如果有的话)在集群中节点上必须相同,目前提供了3种算法:md5,sha1和crc。其中crc不能够提供认证,它只能够用于校验数据包是否损坏,而sha1,md5需要一个密钥来进行认证,从资源消耗的角度来讲,md5消耗的比较多,sha1次之,因此建议一般使用sha1算法。 我们如果要采用sha1算法,只需要将authkeys中的auth 指令(去掉注释符)改为2,而对应的2 sha1行则需要去掉注释符(#),后面的密钥自己改变(两节点上必须相同)。改完之后,保存,同时需要改变该文件的属性为600,否则heartbeat启动将失败。具体命令为:chmod 600 authkeys
3.2 ha.cf heartbeat的主要配置文件,由于该文件比较大,我的注释就直接写在相关地方了,如果我们要采用哪个配置选项(或指令),只需要去掉前面的注释符即可。 # # There are lots of options in this file. All you have to have is a set # of nodes listed {"node ...} one of {serial, bcast, mcast, or ucast}, # and a value for "auto_failback". # # ATTENTION: As the configuration file is read line by line, # THE ORDER OF DIRECTIVE MATTERS! # # In particular, make sure that the udpport, serial baud rate # etc. are set before the heartbeat media are defined! # debug and log file directives go into effect when they # are encountered. # # All will be fine if you keep them ordered as in this example. # # # Note on logging: # If any of debugfile, logfile and logfacility are defined then they # will be used. If debugfile and/or logfile are not defined and # logfacility is defined then the respective logging and debug # messages will be loged to syslog. If logfacility is not defined # then debugfile and logfile will be used to log messges. If # logfacility is not defined and debugfile and/or logfile are not # defined then defaults will be used for debugfile and logfile as # required and messages will be sent there. # # File to write debug messages to 用于记录heartbeat的调试信息 #debugfile /var/log/ha-debug # # # File to write other messages to 用于记录heartbeat的日志信息 # #logfile /var/log/ha-log # # # Facility to use for syslog()/logger #如果未定义上述的日志文件,那么日志信息将送往local0(对应的#/var/log/messages),如果这3个日志文件都未定义,那么heartbeat默认情况下 #将在/var/log下建立ha-debug和ha-log来记录相应的日志信息。 logfacility local0 # # # A note on specifying "how long" times below... # # The default time unit is seconds # 10 means ten seconds # # You can also specify them in milliseconds # 1500ms means 1.5 seconds # # # keepalive: how long between heartbeats? #发送心跳报文的间隔,默认单位为秒,如果你毫秒为单位,那么需要在后面跟 #ms单位,如1500ms即代表1.5s #keepalive 2 # # deadtime: how long-to-declare-host-dead? # # If you set this too low you will get the problematic # split-brain (or cluster partition) problem. # See the FAQ for how to use warntime to tune deadtime. #用于配置认为对方节点菪掉的间隔 #deadtime 30 # # warntime: how long before issuing "late heartbeat" warning? # See the FAQ for how to use warntime to tune deadtime. #发出最后的心跳警告报文的间隔 #warntime 10 # # # Very first dead time (initdead) # # On some machines/OSes, etc. the network takes a while to come up # and start working right after you've been rebooted. As a result # we have a separate dead time for when things first come up. # It should be at least twice the normal dead time. #网络启动的时间 #initdead 120 # # # What UDP port to use for bcast/ucast communication? #广播/单播通讯使用的udp端口 #udpport 694 # # Baud rate for [1] [2] [3] [4] 下一页
|
|
[ 收藏此页到: 天天|和讯|博采|ViVi|狐摘|我摘|天极 ] 文章录入:kinda 责任编辑:kinda |
|
上一篇文章: PHPCOLLAB中文甘特图配置说明 下一篇文章: 磁盘镜像配置 |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |