heartbeat安裝配置實驗

realji發表於2008-05-13

heartbeat的安裝配置

1:下載相關安裝包,使用原始碼編譯方式。
1.1 下載 libnet.tar.gz
1.2 下載最新的穩定版tar.gz檔案,注意是在頁面下方提示有下載的地址

Alternatively, if you prefer to build from source or want to use specific version of the code not available on those sites, grab a tar-ball directly from our version control system, Mercurial.

To do this, point your browser to a URL like:

http://hg.linux-ha.org/dev/archive/{some_version}.tar.bz2

Eg. http://hg.linux-ha.org/dev/archive/STABLE-2.1.0.tar.bz2

To obtain a list of all available versions, see

See Mercurial for more details on our repository
”讀懂這塊很重要。
2:編譯安裝Libnet 。

2.1 新增haclient組 和 heartbeat 使用者 :
#groupaddhaclient
#useradd -u 694 -g haclient hacluster

2.2 編譯安裝 heatbeat。注意 heartbeat編譯安裝有些不一樣,用裡面的Configureme 配上 configure ,然後再 make ,make install。

3:修改系統主機名等相關資訊,主機名修改在/etc/sysconfig/network檔案中修改,改後重啟生效。
3.1 修改主機名解析檔案 ,/etc/hosts。內容如下:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.101 node1.example.com node1
10.0.0.101 node1
192.168.0.102 node2.example.com node2
10.0.0.102 node2
,其中本機業務ip為 192.168.0.101,HA心跳用ip 為10.0.0.101 ,主機名為node1。可以將此檔案複製至備機。目的就是要保證2臺機器可以透過主機名通訊。
4:配置 heartbeat ,在這裡,我僅用到了雙機互相熱備。所以相對網上的很多資料,不一定匹配。
4.1 從heart編譯目錄/doc 中複製檔案ha.cf , haresource, authkeys 到 heartbeat的預設配置目錄 /etc/ha.d/中。
4.2 編輯 authkeys ,內容如下:
#
# Authentication file. Must be mode 600
#
#
# Must have exactly one auth directive at the front.
# auth send authentication using this method-id
#
# Then, list the method and key that go with that method-id
#
# Available methods: crc sha1, md5. Crc doesn't need/want a key.
#
# You normally only have one authentication method-id listed in this file
#
# Put more than one to make a smooth transition when changing auth
# methods and/or keys.
#
#
# sha1 is believed to be the "best", md5 next best.
#
# crc adds no security, except from packet corruption.
# Use only on physically secure networks.
#
#auth 1
#1 crc
#2 sha1 HI!
#3 md5 Hello!
auth 1
1 crc

,注意檔案第1行的提示,要把檔案屬性改為 600 , 執行 chmod 600 /etc/ha.d/authkeys
4.3 編輯 ha.cf ,內容如下:

logfile /var/log/ha-log # Log file 日誌檔案位置
keepalive 2 # Heartbeat interval 心跳包間隔
deadtime 20 # How long to say the server's death 宣告伺服器死亡時間間隔
warntime 10 # 告警時間間隔
initdead 60 # 在某些系統上,系統啟動或重啟之後需要經過一段時間網路才能正常工作,該選項用於解決這種情況產生的時間間隔。取值至少為deadtime的兩倍。)

udpport 694 # Heartbeat port 埠
bcast eth1 # Linux Heartbeat interface 心跳網路卡

auto_failback off # How to do when the failure server comes back 服務停止後是否恢復
node node1 # How many servers in the HA system 系統中的節點名稱,依次排列
node node2
ping 10.0.0.102 #ping a robust server to ensure the server's health; ping目的地址,由於此次使用的是雙機,所以此部分的配置2臺伺服器互相設為對方ip ,有的建議配置為閘道器Ip,但如果閘道器 down了呢??
respawn hacluster /usr/lib/heartbeat/ipfail #

4.4 編輯haresouce檔案,增加 以下
node1 192.168.0.200 weblogic
,意思 是主節點使用虛擬Ip 192.168.0.200 提供 weblogic服務。 weblogic 是建立在/etc/rc.d/init.d裡面的。
檔案內容如下:
#!/bin/sh
# chkconfig: 345 20 80
# description: Weblogic auto start-stop script.

DOMAIN_HOME=/root/weblogic_8.15
WLS_OWNER=root

case "$1" in
'start')
su - ${WLS_OWNER} -c "cd ${DOMAIN_HOME}; ./startWebLogic.sh&"
;;
'stop')
su - ${WLS_OWNER} -c "cd ${DOMAIN_HOME}; ./stopWebLogic.sh"
;;
esac
,注意如果修改過weblogic配置中的服務埠,記得要修改 stopWebLogic.sh 檔案,將其中的7001 改為你設定的那個服務埠,否則 無法停止weblogic的。


至此配置結束。使用/etc/rc.d/init.d/heartbeat start 啟動 heartbeat , 此指令碼也支援 stop和restart及status 。
總計花費時間從昨日下午3點至今天17點,計11個小時。
還有些遺留問題未解決。比如使用負載均衡的配置,Lvs 。還有2個以上節點的配置,實驗都還沒有做。

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7425608/viewspace-1003969/,如需轉載,請註明出處,否則將追究法律責任。

相關文章