yundian 发表于 2015-9-5 13:48:41

Centos5.5 YUM安装heartbeat

  1. 2台主机,分别用一台node1,一台node2
如果你不知道请用下面命令

uname -n
  
  2. 网卡分配 vim /etc/hosts


  

127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.0.151   node1
192.168.0.152   node2
10.0.0.111      vip1
10.0.0.112      vip2


3.安装软件  
  

yum -y install httpd
yum -y install ipvsad
yum -y install heartbeat其中http做测试使用  
  4.关掉多余的服务(当然你也可以不关闭,我是在虚拟机做的)
  

/sbin/chkconfig acpid off
/sbin/chkconfig anacron off
/sbin/chkconfig apmd off
/sbin/chkconfig auditd off
/sbin/chkconfig autofs off
/sbin/chkconfig bluetooth off
/sbin/chkconfig cpuspeed off
/sbin/chkconfig cups off
/sbin/chkconfig gpm off
/sbin/chkconfig haldaemon off
/sbin/chkconfig iptables off
/sbin/chkconfig isdn off
/sbin/chkconfig kudzu off
/sbin/chkconfig mDNSResponder off
/sbin/chkconfig mdmonitor off
/sbin/chkconfig messagebus off
/sbin/chkconfig netfs off
/sbin/chkconfig nfslock off
/sbin/chkconfig nifd off
/sbin/chkconfig pcmcia off
/sbin/chkconfig portmap off
/sbin/chkconfig rhnsd off
/sbin/chkconfig rpcgssd off
/sbin/chkconfig rpcidmapd off
/sbin/chkconfig sendmail off
/sbin/chkconfig xfs off

5. copy文件  
  

cp /usr/share/doc/heartbeat-2.1.3/ha.cf             /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/authkeys      /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/haresources   /etc/ha.d/

6.修改配置

  
  vim
/etc/ha.d/ha.cf
  

logfile /var/log/ha-log    # 日志文件
logfacility   local0    # 登陆/调试日子同时记录给syslog
keepalive 2    # 设定heartbeat之间的检测时间间隔
deadtime 30    # 在30秒后宣布接点死亡,主服务器、从服务器切换
warntime 10    # 日志中发出"last hearbeat"警告之前等待的时间,单位秒
initdead 120   # 一些配置下,重启网络需要一些时间才能正常工作,就是这里设置,一般设置为deadtime的两倍
udpport 694    # 使用端口694进行bcast和ucast通信,这是默认的
bcast   eth1            # 表示在eth1接口上使用来发送心跳信息
ucast eth1 10.0.0.111# 采用网卡eth1的udp单薄来通知心跳,ip为对方ip
#baud 19200    # 波特率,串口通信的速度
node    node1    # 必须配置的,急群众机器的主机名,与"uname -n"输出相同
node    node2    # 同上
ping 192.168.0.1    # 用来验证外网线联通的ip,推荐为上级路由器

  
  vi
/etc/ha.d/authkeys
  这里要修改它的权限chmod 600 /etc/ha.d/authkeys否则无法启动



auth 1    # 认证算法选择,只要前后对应即可
1 crc
#2 sha1 HI!
#3 md5 Hello!

vi
/etc/ha.d/haresources  
  

node1 10.0.0.222 httpd
  
  7.配置备机、备机做相同的操作
  8. 启动服务
  

service      heartbeat            start
  
  9.测试、主备机分别新建html文件   
vim /var/www/html/index.html
  

test node1   主机test node2   备机

LINUX下火狐主备机http://10.0.0.222
  


  


  参考
  动手搭建centos下用heartbeat实现双机热备
  heartbeat V2在CentOS4.6上简要安装、配置笔记



  
页: [1]
查看完整版本: Centos5.5 YUM安装heartbeat