心跳vs UCarp

任何人都可以解释什么是心跳和UCarp IP故障转移场景之间的主要区别?

他们都似乎提供这个function,也许UCarp更简单的设置?

谢谢。

我假设你对简单的主动 – 被动设置感兴趣。

在这样的设置中,ucarp&heartbeat几乎是一样的。 实质上 – 当机器被选为主/热备份时,他们运行提供的脚本。

心跳可能看起来更复杂[因为它可以帮助你自动注入drdb,重启多个服务等],但最后 – 你可以脚本所有这些,让ucarp调用它]。

亲自 – 我运行单一资源的心跳 – 这是脚本,它的作用如下:

  • [un]绑定合适的ip地址
  • 运行几个arp广播
  • 开始[停止]所需的服务

我非常简单的设置[debian lenny下的心跳2.1.3-6]:我有两台服务器:

  • ser0 [首选主动节点],在eth0上永久分配了10.0.0.2/24
  • ser0b [等待replace主节点的热备节点]在eth0上被永久分配为10.0.0.3/24

分配给活动节点的'floating ip'是10.0.1.1/24分配给eth1

在这种情况下获得高可用性的服务是apache。 我分别同步apache的configuration和从ser0服务到ser0b的内容。

下面的文件在两台机器上是相同的,但有一个明显的例外

的/etc/ha.d/authkeys:

auth 1 1 md5 somethingrandom 

的/etc/ha.d/haresources

 ser0 ha.sh 

/etc/ha.d/ha.cf文件

 keepalive 2 deadtime 10 udpport 694 ; below - address permanently assigned to the peer node . this is for master: ucast eth1 10.0.0.3 ; and on slave i have ; ucast eth1 10.0.0.2 udp eth0 logfacility local0 auto_failback on node ser0 node ser0b 

/etc/init.d/ha.cf [它也可以在/etc/ha.d/resources.d/ha.cf中]

 #!/bin/bash case "$1" in start) ip link set dev eth1 up # bind 'floating' ip to the interface ip aa 10.0.1.1/24 dev eth1 # you might want to add some route-changes here if needed /usr/lib/heartbeat/send_arp -r 10 eth1 10.0.0.1 auto 10.0.0.255 255.255.255.0 # to make sure apache reloads it's config when machine becomes master /etc/init.d/apache2 restart ;; stop) # we are no longer active, un-bind 'floating' ip from the interface ip ad 10.0.1.1/24 dev eth1 # you could stop it as well or just skip this step /etc/init.d/apache2 restart ;; esac exit 0