今天完成了Web High Availability
以下記錄整個操作過程
OS:Fedora 13
Requirments:
heartbeat
環境配置:
虛擬IP(VIP):192.168.249.100
Real Server 01
hostname:ha01
Interface:eth1
IP:192.168.249.11
GATEWA:192.168.249.2
Real Server 02
hostname:ha02
Interface:eth1
IP:192.168.249.12
GATEWA:192.168.249.2
1. [以下先以ha01做設定]設定主機名稱
hostname ha01(重開機會重設)
vi /etc/sysconfig/network --> HOSTNAME=ha01
2. 修改hosts檔
vi /etc/hosts
加入192.168.1.11 ha01
192.168.1.12 ha02
3. 安裝套件
yum install heartbeat httpd
4. 複製組態檔
cp /usr/share/doc/heartbeat-3.0.0/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.0/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.0/haresources /etc/ha.d/
5. 修改authkeys
vi /etc/ha.d/authkeys
加入 auth 1
1 crc
6. 修改authkeys權限
chmod 600 /etc/ha.d/authkeys
7. 修改ha.cf
vi /etc/ha.d/ha.cf
logfile /var/log/ha.log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth1
updport 694
auto_failback on
node ha01
node ha02
ping 192.168.249.2
respawn hacluster /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
8. 修改haresources
vi /etc/ha.d/haresources
加入 ha01 192.168.249.100 httpd
("主server hostname" "VIP" "service1" "service2")
9. 將heartbeat設定複製到ha02
cp -r /etc/ha.d/ root@192.168.249.12:/etc/
10. 建立測試環境
echo "This is HA01" > /var/www/html/index.html [HA01]
echo "This is HA02" > /var/www/html/index.html [HA02]
11. 啟動heartbeat服務
/etc/init.d/heartbeat start
(heartbeat啟動時會自動帶起於/etc/ha.d/haresources指定的服務)
12. 用瀏覽器開http://VIP是否出現以下訊息
This is HA01
13. 關閉ha01的heartbeat服務,或是將ha01關機,顯示以下訊息
This is HA02 <-- 表示HA已設定完成~
參考文章:
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17829
https://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=682&view=previous
沒有留言:
張貼留言