2010年3月31日 星期三

Heartbeat HA 設定摘要-以HTTP服務為例

環境說明:
以兩台主機做 HA,當一設備無法提供服務後,另一台自動提供服務

OS: CentOS 5.1
兩部主機 master,slave 及相關 IP 如下
master: 192.168.6.103
slave: 192.168.6.102
服務 ip: 192.168.6.104
ping_ip: 192.168.6.253
提供服務 http
master、slave /etc/hosts 加入下面內容
192.168.6.103 master
192.168.6.102 slave


1.master、slave 安裝 heartbeat
yum install heartbeat


2.master、slave 設定 authkeys
新增 /etc/ha.d/authkeys 內容如下
auth 1
1 sha1 YourSecreKey

改變權限
chmod 600 /etc/ha.d/authkeys


3.master、slave 設定 ha.cf
新增 /etc/ha.d/ha.cf 內容
# File to write other messages
logfile /var/log/ha.log

# Facility to use for syslog()/logger
logfacility local0

# keepalive: how long between heartbeats?
keepalive 2

#deadtime: how long-to-declare-host-dead?
deadtime 30

# Very first dead time (initdead)
initdead 120

# What interfaces to broadcast heartbeats over?
bcast eth0

# What UDP port to use for bcast/ucast communication?
udpport 694

# auto_failback: determines whether a resource will
# automatically fail back to its "primary" node, or remain
# on whatever node is serving it until that node fails, or
# an administrator intervenes.
#
# The possible values for auto_failback are:
# on - enable automatic failbacks
# off - disable automatic failbacks
# legacy - enable automatic failbacks in systems
# where all nodes do not yet support
# the auto_failback option.
auto_failback on

# Tell what machines are in the cluster
# node nodename ... -- must match uname -n
node master
node slave

# Treats IP as a psuedo-cluster-member
# Used together with ipfail below...
# note: don't use a cluster node as ping node
ping 192.168.6.253

# Processes started and stopped with heartbeat. Restarted unless
# they exit with rc=100
respawn hacluster /usr/lib/heartbeat/ipfail

# Access control for client api
# default is no access
apiauth ipfail gid=haclient uid=hacluster


4.master、slave 設定 haresources
新增 /etc/ha.d/haresources 內容
# HA 的主要電腦的 hostname 虛擬介面 IP 服務名稱
server1 192.168.6.104 httpd


其他說明
1.當master 上線時,master ping ping_ip 可以回應,但 master 上 httpd 因故發生無法服務的狀態時,httpd 服務並不會自動轉移至 slave。
2.防火牆相關設定: udp/694

沒有留言: