集群之heartbeat(v2){haresource}实现httpd高可用
批注:本次只提供实验操作配置过程{最精简但能实现需求},不总结框架http://blog.运维网.com/attachment/201310/212029151.jpg
实验材料:
heartbeat-2.1.4-9.el5.i386.rpm ##主包
heartbeat-pils-2.1.4-10.el5.i386.rpm
heartbeat-devel-2.1.4-9.el5.i386.rpm
heartbeat-stonith-2.1.4-10.el5.i386.rpm
具体配置及步骤:
0.集群配置准备
①时间同步(心跳线需要时间时刻同步)
crontab-e
*/5* * * *ntpdate ntpserver_ip
②节点间互相解析(/etc/hosts)
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.220.100node1.jeffery.comnode1
192.168.220.101 node2.jefffery.comnode2
③主机名配置(uname-n要和解析的结果一致)
④ssh互信通讯(管理方便,可选)
参考:ssh互信章节
1.复制配置样例
cp/usr/share/doc/heartbeat-2.1.4/{ha.cf,authkeys,haresources}/etc/ha.d/
2.主配置文件/etc/ha.d/ha.cf
logfacility local0##日志保存于syslog中
bcast eth0 ##心跳线是以广播形式工作在eth0
auto_failback on ##节点挂了之后,从新活过来,抢回资源
node node1.jeffery.com##添加集群节点1
node node2.jeffery.com##添加集群节点2
ping 192.168.220.2 ##仲裁节点{防止集群分裂的仲裁机制}
3.节点安全认证配置/etc/ha.d/authkeys
auth 1 ##使用钥匙1
1 md5 d41d8cd98f00b204e9800998ecf8427e##钥匙1使用md5加密
##密钥可以随机生成
##可参考{dd if=/dev/random bs=512 count=1 | md5sum }
4.节点资源定义/etc/ha.d/haresources
(首先启动的节点)
node1.jeffery.com IPaddr::192.168.220.200/24/eth0 httpd
5、安装httpd服务,并且不能开机启动
yuminstallhttpd-y
chkconfig httpd off
echo ‘node{1/2}’>/var/www/html/index.html
6.启动+测试
service heartbeat start ##启动本地的heartbeat
sshnode2 ‘service heartbeat start’##启动远程的node2的heartbeat
截图:
http://blog.运维网.com/attachment/201310/222805250.jpg
将node1设置为standy(使用/usr/lib/heartbeat/hb_standby切换)
http://blog.运维网.com/attachment/201310/223047514.jpg
页:
[1]