Apache-2.2

心跳讓我心痛

  • October 6, 2011

我有 2 個 Ubuntu 11.04 VM,我在其上安裝了 Heartbeat + apache2 以實現“高可用性”設置。Heartbeat 已啟動並在兩者上執行,但我無法 ping 虛擬 IP(集群 ip)

從我遵循的指南中,心跳應該自動在活動節點上創建一個別名。但我在兩個虛擬機中都沒有看到任何別名

設置如下:

在此處輸入圖像描述

ha-node1 配置:

root@ha-node1:/etc/ha.d# cat ha.cf
autojoin none
#mcast bond0 239.0.0.43 694 1 0
warntime 5
deadtime 15
initdead 60
keepalive 2
node ha-node1
node ha-node2
pacemaker respawn
logfile /var/log/ha-log
debugfile /var/log/ha-debug
udpport 694
auto_failback on
bcast eth0

root@ha-node1:/etc/ha.d# cat haresources
ha-node1 IPaddr::10.0.0.10 apache2

root@ha-node1:/etc/ha.d# crm_mon -1
============
Last updated: Thu Oct  6 17:42:57 2011
Stack: Heartbeat
Current DC: ha-node1 (710962f3-6239-4519-8ab7-b176af92cfe4) - partition with quorum
Version: 1.0.9-da7075976b5ff0bee71074385f8fd02f296ec8a3
2 Nodes configured, unknown expected votes
0 Resources configured.
============

Online: [ ha-node1 ha-node2 ]

root@ha-node1:/etc/ha.d# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0c:29:cb:ae:9d
         inet addr:10.0.0.8  Bcast:10.255.255.255  Mask:255.0.0.0
         inet6 addr: fe80::20c:29ff:fecb:ae9d/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:25247 errors:0 dropped:0 overruns:0 frame:0
         TX packets:17038 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:25278878 (25.2 MB)  TX bytes:2374181 (2.3 MB)
         Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
         inet addr:127.0.0.1  Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:8 errors:0 dropped:0 overruns:0 frame:0
         TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

root@ha-node1:/etc/ha.d# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
   link/ether 00:0c:29:cb:ae:9d brd ff:ff:ff:ff:ff:ff
   inet 10.0.0.8/8 brd 10.255.255.255 scope global eth0
   inet6 fe80::20c:29ff:fecb:ae9d/64 scope link
      valid_lft forever preferred_lft forever

ha-node2 配置:

root@ha-node2:/etc/ha.d# cat ha.cf
autojoin none
#mcast bond0 239.0.0.43 694 1 0
warntime 5
deadtime 15
initdead 60
keepalive 2
node ha-node1
node ha-node2
pacemaker respawn
logfile /var/log/ha-log
debugfile /var/log/ha-debug
udpport 694
auto_failback on
bcast eth0

root@ha-node2:/etc/ha.d# cat haresources
ha-node1 IPaddr::10.0.0.10 apache2

root@ha-node2:/etc/ha.d# crm_mon -1
============
Last updated: Thu Oct  6 17:44:07 2011
Stack: Heartbeat
Current DC: ha-node1 (710962f3-6239-4519-8ab7-b176af92cfe4) - partition with quorum
Version: 1.0.9-da7075976b5ff0bee71074385f8fd02f296ec8a3
2 Nodes configured, unknown expected votes
0 Resources configured.
============

Online: [ ha-node1 ha-node2 ]

root@ha-node2:/etc/ha.d# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0c:29:d9:ca:5c
         inet addr:10.0.0.9  Bcast:10.255.255.255  Mask:255.0.0.0
         inet6 addr: fe80::20c:29ff:fed9:ca5c/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:23310 errors:0 dropped:0 overruns:0 frame:0
         TX packets:15397 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:25070323 (25.0 MB)  TX bytes:2044327 (2.0 MB)
         Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
         inet addr:127.0.0.1  Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:8 errors:0 dropped:0 overruns:0 frame:0
         TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

root@ha-node2:/etc/ha.d# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
   link/ether 00:0c:29:d9:ca:5c brd ff:ff:ff:ff:ff:ff
   inet 10.0.0.9/8 brd 10.255.255.255 scope global eth0
   inet6 fe80::20c:29ff:fed9:ca5c/64 scope link
      valid_lft forever preferred_lft forever

crm_mon -1告訴我配置了 0 個資源。但我已經清楚地IPaddr在 haresources 中添加了資源。我無法 ping 或瀏覽虛擬 IP。我在設置中做錯了嗎?

0 Resources configured表示故障轉移 IP未配置為 HA 資源。

順便說一句,如果您只需要 IP 故障轉移,那麼 CARP(通過 ucarp/ucarpd)要簡單得多。

引用自:https://serverfault.com/questions/319033