xxggmmxx 发表于 2019-1-6 15:02:41

heartbeat部署指南

  两台机器的环境:
  data-1-1   eth0 10.0.0.7    eth1 172.16.1.7   eth2 10.0.10.7
  data-1-2   eth0 10.0.0.8    eth1 172.16.1.8   eth2 10.0.10.8
  

  # cat /etc/hosts
  127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
  ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
  10.0.10.7    data-1-1
  10.0.10.8    data-1-2
  

  # route add -host 10.0.10.8 dev eth2   互相添加路由
  # route add -host 10.0.10.7 dev eth2   互相添加路由
  

  更新yum源:
  # mkdir /home/oldboy/tools -p
  # cd /home/oldboy/tools
  # wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
  # rpm -ivh epel-release-6-8.noarch.rpm
  

  # rpm -qa|grep epel      检查是否已安装上
  epel-release-6-8.noarch
  

  # sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf是否留下软件包
  

  # yum install heartbeat* -y   都需要安装heartbeat软件及其依赖
  

  启动脚本:/etc/init.d/heartbeat
  配置文件目录:/etc/ha.d
  资源控制目录:/etc/ha.d/resource.d
  核心的配置文件:authkey   haresource   ha.cf
  配置文件模版放置目录:/usr/share/doc/heartbaeat-3.0.4
  

  ha.cf配置文件:
  # cat /etc/ha.d/ha.cf
  debugfile /var/log/ha-debug
  logfile /var/log/ha-log
  logfacility   local0
  keepalive 2
  deadtime 30
  warntime 10
  initdead 60
  udpport 694
  mcast eth0 225.0.0.1 694 1 0
  auto_failback on
  node    data-1-1
  node    data-1-2
  crmno
  

  authkeys配置文件
  # echo chenjisong|sha1sum
  8e901fca8d58aa2e2b315b4af1769ffe54e5257a-
  # cat authkeys
  auth 1
  1 sha1 8e901fca8d58aa2e2b315b4af1769ffe54e5257a
  # chmod 600 authkeys
  

  haresources 配置文件
  # cat haresources
  data-1-1   IPaddr::10.0.0.17/24/eth0      ====虚拟IP
  data-1-2   IPaddr::10.0.0.18/24/eth0      ====虚拟IP
  

  # /etc/ha.d/resource.d/IPaddr 10.0.0.17/24/eth0 start
  # ip a|grep 10.0.0.17
  inet 10.0.0.17/24 brd 10.0.0.255 scope global secondary eth0
  
  # /etc/ha.d/resource.d/IPaddr 10.0.0.18/24/eth0 start
  # ip a|grep 10.0.0.18
  inet 10.0.0.18/24 brd 10.0.0.255 scope global secondary eth0
  
  两台机器上面安装httpd
  然后启停heartbeat服务,查看ip漂移过程
  

  heartbeat的使用场景:

http://s5.运维网.com/wyfs02/M01/76/D2/wKiom1ZdNJXQYfXqAAEfjs0eARs109.png



页: [1]
查看完整版本: heartbeat部署指南