Sideway xtadw@yahoo.com.cn
Linux-HA是我找到的一个开源的linux HA项目,其网站为:,因为是一个英文的网站,许多东西也只看了个大概。
经过实验,顺利在rhel3中创建了一个httpd服务HA集群
,(具体配置请见最后所附实验操作步骤),拔掉server1上的eth0的网线后,server2自动开启挂载nfs并开启httpd服务,接管了server1上的服务,把网线重新插入后,server2自动停止httpd服务,自动卸载nfs,server1接管所有服务。
实现了在出现断网或死机的情况下的HA,但无法实现主服务器httpd服务挂起等原因的HA,对于双机互备方式的HA也不是很清楚。
实验主要步骤:
===================================================================================
Computer1:
Hostname:server1
eth0
eth1 (心跳网卡)
Computer2:
Hostname:server2
eth0
eth1 (心跳网卡)
Computer3:
Hostname:server3
eth0
此服务器开启NFS,供前两台服务器存储网页文件使用
vi /etc/hosts
============================
server1
server2
ha1
ha2
============================
说明:两台服务器进行以下同样的操作
一、安装软件包
RHEL4中所需要安装的软件包
(1) rpm -ivh libtool-libs-1.5.6-4.i386.rpm
(2) rpm -ivh heartbeat-pils-2.0.2-1.i386.rpm
(3) rpm -ivh net-snmp-libs-5.1.2-11.i386.rpm
(4) rpm -ivh curl-7.9.8-5.i386.rpm (rhel3中的)
(5) rpm -ivh heartbeat-stonith-2.0.2-1.i386
(6) rpm -ivh heartbeat-2.0.2-1.i386.rpm
RHEL3中的所需要安装的软件包
rpm -ivh heartbeat-pils-2.0.2-1.i386.rpm
rpm -ivh curl-7.10.6-4.1.i386.rpm (heartbeat-stonith-2.0.2-1.i386的依赖包)
rpm -ivh net-snmp-5.0.8-11.i386.rpm (heartbeat-stonith-2.0.2-1.i386的依赖包)
rpm -ivh libxml2-2.5.10-5.i386.rpm (heartbeat-stonith-2.0.2-1.i386的依赖包 )
rpm -ivh heartbeat-stonith-2.0.2-1.i386
rpm -ivh heartbeat-2.0.2-1.i386.rpm
二、新建配置文件
(1) vi /etc/ha.d/authkeys
===========================
auth 2
2 crc
===========================
(2) chmod 600 /etc/ha.d/authkeys
(3) vi /etc/ha.d/ha.cf
===========================
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 1
deadtime 10
warntime 10
initdead 20
udpport 694
bcast eth1
auto_failback on
node server1
node server2
ping
respawn hacluster /usr/lib/heartbeat/ipfail
===========================
(4) vi /etc/haresources
===========================
server1 Filesystem::192.168.3.3:/var/www::/hafs::nfs::rw,hard httpd
===========================
三、启动服务
(1) /etc/rc.d/init.d/heartbeats start (先在主服务器上启动)
(1) /etc/rc.d/init.d/heartbeats start (然后在备份服务器上启动)
===================================================================================