HA高可用HEARTBEAT配置

来源:互联网 发布:cf防沉迷解除软件 编辑:程序博客网 时间:2024/05/17 22:13
1、用yum安装heartbeat、libnet安装包。(heartbeat需要安装两次,第一次安装的为一些依赖文件)
2、将/usr/share/doc/heartbeat 下ha.cf,haesources,authkeys三个文件复制到/etc/ha.d下。
3、ln -s /etc/ha.d /usr/etc/ha.d 做软连接
4、修改配置文件ha.cf、haresources、authkeys
ha.cf
debugfile、logfile 配置调试日志路径。
logfacility
keepalive 2
deadtime  5
warntime 1250ms
initdead 20
udpport  694
ucast 对方IP
ping 网关
auto_failback on
#auto_failback off
#respawn hacluster /usr/lib/heartbeat/ipfail
// 两台主机名(修改/etc/hosts,/etc/sysconfig/network)
node xrhao
node xrTwo
haresources资源文件
xrhao IPaddr::192.168.10.208/32/eth0:0 httpd (主服务器的虚拟IP地址)
authkeys
auth 1
1 crc
5、chmod 600 authkeys
6、将三个配置文件SCP到备服务器上,只需修改HA.CF中的对应IP地址即可。
7、BUG修复(2.14版本)
修改heartbeat启动脚本
heartbeat的启动脚本指的是/etc/init.d/heartbeat,这Bug涉及两方面的内容:

a、crm 临时目录的问题
该问题在之前的文章中已多次提到,请见这里。修改的内容就是下面红色标记部分:
引用
StartHA() {
  EchoNoNl "Starting High-Availability services: "
......
  if
   [ ! -d $RUNDIR/heartbeat/ccm -o ! -d $RUNDIR/heartbeat/crm ]
  then
......

b、heartbeat启动后,导致不能正常重启或关闭机器的问题
由于系统升级的原因,heartbeat启动脚本中chkconfig部分的定义不符合要求,导致不能创建K05heartbeat的链接。换句话说,当heartbeat 已经启动,并手动重启或关闭机器时,不会预先关闭heartbeat进程,而在终止网络、挂载等进程后,heartbeat不断的报错,必须强制关机。
发生该问题时,关机途中,您会在主屏幕上看到类似下面的报错信息:

解决方法是,把heartbeat启动脚本中,下面的内容:
引用
# chkconfig: 2345 75 05
修改为:
引用
# chkconfig: - 75 05
然后重新创建启动服务表:
# chkconfig --del heartbeat
# chkconfig --add heartbeat
可用下面的命令确认修改是否生效:
引用
# find /etc/rc.d/ -name 'K05heartbeat'
/etc/rc.d/rc4.d/K05heartbeat
/etc/rc.d/rc6.d/K05heartbeat
/etc/rc.d/rc1.d/K05heartbeat
/etc/rc.d/rc0.d/K05heartbeat
/etc/rc.d/rc2.d/K05heartbeat
 
8、测试。
service heartbeat start
 
资源脚本例子::
fxl(resouce.d目录下)

#!/bin/sh
logger $0 called with $1
case "$1" in
        start)

                cmdx= `ps aux | grep appfxl | grep -v grep| awk '{print $2}'`
                if [ !$cmdx ];then
                /home/appfxl &
                fi
                ;;
        stop)
                cmd=`ps aux | grep appfxl | grep -v grep | awk '{print $2}'`
                kill $cmd
                ;;
        restart)
                ;;
        *)
esac

exit 0
               

 
原创粉丝点击