Linux LVS - Heartbeat - High Availability Cluster - 2 nodes
Đây là dạng cơ bản nhất. Mình làm vs 2 node, chưa có đồng bộ file + cơ sở dữ liệu.
Ta phân tích file cấu hình:
/etc/ha.d/authkeys
auth 2
2 sha1 Ultramonkey!
File này là cấu hình keys trao đổi giữa 2 node, ko có gì đặc biệt.
/etc/ha.d/ha.cf
logfacility local0
keepalive 1
deadtime 10
warntime 5
initdead 120
udpport 694
mcast eth0 225.0.0.1 694 1 0
auto_failback off
node server1.hbn.local
node server2.hbn.local
ping 192.168.1.1
respawn hacluster /usr/lib/heartbeat/ipfail
crm off
file cấu hình HA. Chú ý node là FDN, full domain name trong file host
/etc/ha.d/haresources
server1.hbn.local \
ldirectord::ldirectord.cf \
LVSSyncDaemonSwap::master \
IPaddr2::192.168.1.100/24/eth0/192.168.1.255
File này để cấu hình ldirectord, mình chưa rõ lắm, hix
/etc/ha.d./ldirectord.cf
checktimeout=10
checkinterval=2
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=no
# Virtual Service for HTTP
virtual=192.168.1.100:80
fallback=127.0.0.1:80
real=192.168.1.10:80 gate
real=192.168.1.20:80 gate
service=http
request="alive.html"
receive="I'm alive!"
scheduler=wrr
persistent=1800
protocol=tcp
checktype=negotiate
# Virtual Service for HTTPS
virtual=192.168.1.100:443
fallback=127.0.0.1:443
real=192.168.1.10:443 gate
real=192.168.1.20:443 gate
service=https
request="alive.html"
receive="I'm alive!"
scheduler=wrr
persistent=1800
protocol=tcp
checktype=negotiate
File này quan trọng, chú ý vào các node. 100 là virtual ip, sẽ được lắng nghe ( IP ảo). các node thật là real
Mỗi server tạo file alive.htm ở doc root, để chứng thực giữa 2 node, trong đó có nội dung: I'm alive!, theo file cấu hình ldirectord.cf của bạn.
Để ý: dùng lệnh ip addr sh lo và ip addr sh eth0, ip ảo sẽ chuyển từ lo sang eth0 ở máy active.
Thực ra bài này là clustering nhiều hơn. Làm tiền đề cho bài sau, load balancing $_$
Video: http://www.mediafire.com/?madcuy9toh2fscp
Next step: Load Balancing, 4 nodes
------------------------------------------------------------
Thanks for reading
--------------------------------------------------------------------------
All my Lab:
Linux Lab -- window and Cisco Lab
to be continued - I will update more.
Nam Habach