您的位置:首页 > 理论基础 > 计算机网络

集群之heartbeat(v2){haresource}实现httpd高可用

2013-10-26 22:31 483 查看
批注:本次只提供实验操作配置过程{最精简但能实现需求},不总结框架





实验材料:
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.100  node1.jeffery.com  node1
192.168.220.101 node2.jefffery.com  node2

③主机名配置(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服务,并且不能开机启动
yum  install  httpd  -y
chkconfig httpd off
echo ‘node{1/2}’  >/var/www/html/index.html

6.启动+测试
service heartbeat start    ##启动本地的heartbeat
ssh  node2 ‘service heartbeat start’  ##启动远程的node2的heartbeat

截图:



将node1设置为standy(使用/usr/lib/heartbeat/hb_standby切换)



本文出自 “keepalive” 博客,请务必保留此出处http://jefferyyu.blog.51cto.com/2843635/1315767
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: