上海isp 发表于 2015-11-21 10:14:37

heartbeat安装总结文档

  一、准备环境
  1、两台服务器
  操作系统:RHEL6.3-32bit
  master   eth0:192.168.10.150
  eth1:192.168.1.1
  slave       eth0:192.168.10.151
  eh1:192.168.1.2
  cat /etc/hosts
  master 192.168.10.150
  slave 192.168.10.151
  
  2、下载一下两个安装包
  libnet-1.1.6.tar.gz(下载地址:http://download.iyunv.com/detail/u011648187/6021087)
  heartbeat-2.1.3.tar.gz(下载地址:http://download.iyunv.com/detail/u011648187/6021065)
  
  安装heartbeat所需依赖包:
  yum -y install gcc make automake autoconf flex rpm-build kernel-devel libxsltlibxslt-devel bzip2-devel
  
  3、安装libnet
  tar zxvf libnet-1.1.6.tar.gz
  cd libnet-1.1.6
  ./configure ;make ;make install
  
  4、创建heartbeat所需用户和组
  groupadd haclient
  useradd -g haclient hacluster
  
  5、安装heartbeat
  (### yum -y install pam-devel python-devel swig gnu tls )
  tar zxvf heartbeat-2.1.3.tar.gz
  cd heartbeat-2.1.3
  ./ConfigureMe configure --enable-fatal-warnings=no
  ./ConfigureMe make --enable-fatal-warnings=no
  
  #######这里如果出现以下报错:
  configure: error: The following required components noted earlier are missing: glib2-devel
  Please supply them and try again.
  make: *** 没有指明目标并且找不到 makefile。停止。
  
  解决方法:
  请安装glib2-devel
  yum -y install glib2-devel
  再执行
  ./ConfigureMe make --enable-fatal-warnings=no
  make install
  #############到这步如果没有报错信息,说明heartbeat已成功安装#############
  
  
  6、配置heartbeat
  
  1)heartbeat配置文件有三个,分别是:ha.cf authkeys haresources;在/etc/ha.d/目
  
  录下,默认没有这三个配置文件,需要将heartbeat的解压目录下doc目录下的这三个文件
  
  copy到/etc/ha.d/目录下作修改(注意authkeys文件的权限必须为600,否则无法启动
  
  heartbeat服务)。首先配置master节点:
  cd /etc/ha.d/
  chmod 600 authkeys             #更改authkeys文件权限为600
  cat authkeys
  auth1
  1 crc
  
  
  》cat haresources
  master   IPaddr::192.168.10.160/24/eth0    httpd
  
  #这句话的意思是优先在master主机上虚拟一个192.168.10.160的ip地址给eth0:0网卡提供httpd服务,如果master宕掉后,slave会莫得一个192.168.10.160的ip地址给eth0:0网卡,自动接管httpd服务。注:此文件内容所有节点必须一样
  
  》cat ha.cf
  debugfile /var/log/ha.debug          #记录heartbeat的调试信息
  logfile /var/log/ha.log                  #heartbeat的日志文件位置
  logfacility local0                         #系统日志级别
  keepalive 2                                 #心跳间隔(默认单位为秒)
  initdead 20                                 #网络启动时间,至少为daadtime的2倍
  deadtime 10                              #超时间隔,超过10秒收不到对方节点心跳,认为宕机
  auto_failback off                        #当主节点恢复后是否将资源转移到主节点(off表示不自动转移)
  bcast eth0                                 #通过eth0网卡广播(ucast为单播)
  node master                              #设置群集中的节点,这里的主机名必须和uname -n相同
  node slave
  ping 192.168.10.151                  #ping对方地址测试网络连通性
  
  
  
  直接将这三个配置文件copy到slave节点
  scp authkeys haresourcesroot@slave:/etc/ha.d/
  输入密码回车
  6、启动heartbeat服务
  service httpd start          #启动httpd服务
  service heartbeat start   #启动heartbeat服务
  ps -elf|grep heartbeat   #查看heartbeat进程
  tac /var/log/ha.log         #查看heartbeat启动日志
  
  》slave节点配置
  因为slave节点的配置文件是从master节点copy来的,这里只修改ha.cf文件就可以了
  cat ha.cf
  debugfile /var/log/ha.debug          #记录heartbeat的调试信息
  logfile /var/log/ha.log                  #heartbeat的日志文件位置
  logfacility local0                         #系统日志级别
  keepalive 2                                 #心跳间隔(默认单位为秒)
  initdead 20                                 #网络启动时间,至少为daadtime的2倍
  deadtime 10                              #超时间隔,超过10秒收不到对方节点心跳,认为宕机
  auto_failback off                        #当主节点恢复后是否将资源转移到主节点(off表示不自动转移)
  bcast eth0                                 #通过eth0网卡广播(ucast为单播)
  node master                              #设置群集中的节点,这里的主机名必须和uname -n相同
  node slave
  ping 192.168.10.150                  #ping对方地址测试网络连通性
  
  
  chmod 600 authkeys      #更改authkeys文件权限为600
  service httpd start          #启动httpd服务,
  service heartbeat start   #启动heartbeat服务
  ps -elf|grep heartbeat   #查看heartbeat进程
  tac /var/log/ha.log         #查看heartbeat启动日志
  
  
  
  
  
  
页: [1]
查看完整版本: heartbeat安装总结文档