免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: applegump
打印 上一主题 下一主题

heartbeat crm模块如何使用 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2012-08-22 09:35 |只看该作者
Pacemaker will try and determine what resources are active on a machine when it starts. To do this, it sends what we call a probe which uses the monitor operation of your ResourceAgent.
There are two common reasons for seeing this message:
Your resource really is active on more than one node
Check you are _not_ starting it on boot
Did Pacemaker suffer an internal failure? If so, please check the Help:Contents page and report it
Your resource doesn't implement the monitor operation correctly
Make sure your Resource Agent conforms to the OCF-spec by using the ocf-tester script


我查到了这段FAQ,看这个意思,在正常情况下

httpd似乎本来就不应该在oradb2-1上被启动,只有kf28-1上的httpd服务停掉了,随着vip转移到oradb2-1上,oradb2-1上的httpd才被启动。

这样理解对吗?

那我应该怎么做配置呢?




论坛徽章:
0
22 [报告]
发表于 2012-08-22 09:43 |只看该作者
本帖最后由 sacry 于 2012-08-22 09:52 编辑

如果你贴出来的脚本是全部的话,那铁定错了。

heartbeat要的lsb脚本是遵循linux standard base的脚本(主要是指返回值)。
http://linux-ha.org/wiki/LSB_Resource_Agents
http://refspecs.linuxbase.org/LS ... ic/iniscrptact.html

你写的脚本是给人看,不是给程序看的。
不管启动停止都是echo,返回值都是0,
两台机器,不管自己的http有没有启动,读到的都是0(program is running or service is OK),所以会悲剧。

PS;判断程序是否启动不是这么判断的..
一个简单通用的做法是
  1. if [ -f $pidfile ] ; then
  2.     pid=`cat $pidfile`
  3.     if [ "x"$pid != "x" ] && kill -0 $pid > /dev/null 2>&1 ; then
  4.         return 0
  5.     else
  6.         return 1
  7.     fi
  8. else
  9.     return 3
  10. fi
复制代码

论坛徽章:
0
23 [报告]
发表于 2012-08-22 09:43 |只看该作者
找不到crm命令啊。我find了一下,这个版本没有crm命令,只有crm_mon

我再把两台机器上的cib.xml贴出来,请各位看看

<cib admin_epoch="0" epoch="0" num_updates="0">
        <configuration>
                <crm_config>
                        <cluster_property_set id="cib-bootstrap-options">
                                <attributes>
                                        <nvpair id="cib-bootstrap-options-symmetric-cluster" name="symmetric-cluster" value="true"/>
                                        <nvpair id="cib-bootstrap-options-no_quorum-policy" name="no_quorum-policy" value="stop"/>
                                        <nvpair id="cib-bootstrap-options-default-resource-stickiness" name="default-resource-stickiness" value="0"/>
                                        <nvpair id="cib-bootstrap-options-default-resource-failure-stickiness" name="default-resource-failure-stickiness" value="0"/>
                                        <nvpair id="cib-bootstrap-options-stonith-enabled" name="stonith-enabled" value="false"/>
                                        <nvpair id="cib-bootstrap-options-stonith-action" name="stonith-action" value="reboot"/>
                                        <nvpair id="cib-bootstrap-options-stop-orphan-resources" name="stop-orphan-resources" value="true"/>
                                        <nvpair id="cib-bootstrap-options-stop-orphan-actions" name="stop-orphan-actions" value="true"/>
                                        <nvpair id="cib-bootstrap-options-remove-after-stop" name="remove-after-stop" value="false"/>
                                        <nvpair id="cib-bootstrap-options-short-resource-names" name="short-resource-names" value="true"/>
                                        <nvpair id="cib-bootstrap-options-transition-idle-timeout" name="transition-idle-timeout" value="5min"/>
                                        <nvpair id="cib-bootstrap-options-default-action-timeout" name="default-action-timeout" value="5s"/>
                                        <nvpair id="cib-bootstrap-options-is-managed-default" name="is-managed-default" value="true"/>
                                </attributes>
                        </cluster_property_set>
                </crm_config>
                <nodes/>
                <resources>
                        <group id="group_1">
                                <primitive class="ocf" id="IPaddr_192_1_101_212" provider="heartbeat" type="IPaddr">
                                        <operations>
                                                <op id="IPaddr_192_1_101_212_mon" interval="5s" name="monitor" timeout="5s"/>
                                        </operations>
                                        <instance_attributes id="IPaddr_192_1_101_212_inst_attr">
                                                <attributes>
                                                        <nvpair id="IPaddr_192_1_101_212_attr_0" name="ip" value="192.1.101.212"/>
                                                </attributes>
                                        </instance_attributes>
                                </primitive>
                                <primitive class="lsb" id="myhttpd_2" provider="heartbeat" type="myhttpd">
                                        <operations>
                                                <op id="myhttpd_2_mon" interval="120s" name="monitor" timeout="60s"/>
                                        </operations>
                                </primitive>
                        </group>
                </resources>
                <constraints>
                        <rsc_location id="rsc_location_group_1" rsc="group_1">
                                <rule id="prefered_location_group_1" score="100">
                                        <expression attribute="#uname" id="prefered_location_group_1_expr" operation="eq" value="kf28-1"/>
                                </rule>
                        </rsc_location>
                </constraints>
        </configuration>
        <status/>
</cib>

论坛徽章:
0
24 [报告]
发表于 2012-08-22 09:47 |只看该作者
22楼的兄弟,我先改改脚本,受教了,谢谢

论坛徽章:
0
25 [报告]
发表于 2012-08-22 10:52 |只看该作者
脚本不会写,哪位能指点指点啊

论坛徽章:
0
26 [报告]
发表于 2012-08-22 12:59 |只看该作者
sacry:


您好

我现在在配heartbeat的crm模式。目前的状况还是启动脚本不太会写,就是符合lsb规范的apache httpd脚本。

我使用的apache httpd是自己安装的,安装路径是/users/ems/apache

您是否能给我一个例子?我对shell 编程了解不多,麻烦您了

论坛徽章:
0
27 [报告]
发表于 2012-08-22 13:43 |只看该作者
回复 26# applegump

apache httpd这种很流行的软件,community肯定会提供脚本的。
事实上推荐的是OCF标准的脚本而不是LSB标准的,你设置的IP资源就是用的OCF的脚本
<primitive class="ocf" id="IPaddr_192_1_101_212" provider="heartbeat" type="IPaddr">

可以试着用这个命令找一下ocf资源放哪个文件夹的,默认提供了哪些脚本。
    locate resource.d

想自己写的话,即使不熟悉shell,照着规范努力下也能敲出来。但是测试环境用用可以,生产环境就.....


=====

为什么还要使用2.0.8版本啊,应该没什么特别的好处。

论坛徽章:
0
28 [报告]
发表于 2012-08-22 13:58 |只看该作者
您好!

你说我设的IP资源是用OCF脚本,这个我还真没仔细看,我这个礼拜才接触heartbeat,很多东西还不是很明白,见笑了。

查了一下 /usr/lib/ocf/resource.d/heartbeat下面确实有个名叫apache的脚本,但是使用这个脚本 ./apache start,启动的好像不是我自己安装的apache,而是系统默认自带的,我的apache安装在/users/ems/apache下。

而且,我这个apache是通过源码编译过来的,自定义了一些功能,它加入了ajp模块,能向后端的tomcat转发请求。我试着改了一下/usr/lib/ocf/resource.d/heartbeat/apache这个脚本,把我安装的apache httpd加了进去,

再./apache start ,报了错。

不知道您有什么建议

2.0.8是我随手在网上搜了一个安装教程,随手找到的一个安装版本,我也不知道这个版本怎样,现在heartbeat最新是什么版本,哪个版本比较稳定,我随手下了这个2.0.8,安装是正常的,在crm功能之前,它表现也比较正常

我就没理会版本的问题了,毕竟接触这东西也才三四天,很多还不明白,见笑了

论坛徽章:
0
29 [报告]
发表于 2012-08-22 14:18 |只看该作者
刚才改了一下/usr/lib/ocf/resource.d/heartbeat/apache这个脚本  

把  HTTPDLIST="/sbin/httpd2 /usr/sbin/httpd2 /sbin/httpd /usr/sbin/httpd $IBMHTTPD" 注掉了

新加了  HTTPDLIST="/users/ems/apache/bin/httpd $IBMHTTPD"

把 DEFAULT_NORMCONFIG="/etc/apache2/httpd.conf" 注掉了

新加了DEFAULT_NORMCONFIG="/users/ems/apache/conf/httpd.conf"

现在使用./apache start 能启动我自己安装的apache httpd

但是使用./apache stop  不能停止

使用./apache status   报  2012/08/22_14:04:23 INFO: apache is stopped.   可是这时apache正在运行着

使用./apache status  报  2012/08/22_14:04:04 ERROR: Monitoring not supported by /users/ems/apache/conf/httpd.conf

不知道是怎么回事

论坛徽章:
0
30 [报告]
发表于 2012-08-22 15:00 |只看该作者
本帖最后由 sacry 于 2012-08-22 15:01 编辑

回复 28# applegump

===================================
》我真正想说的

ocf脚本不是这么启动的,这又是另外一个挺长的话题。

不知道你是学习,还是急着就要部署。
如果时间充分的话重头来比较好,重装一个新点的版本什么的。
不是稳定不稳定的问题,而是2.0.x其实文档较少(整个heartbeat文档就不多),依赖MaillingList,别人的经验。
相比之下,3.x的crm其实就是pacemaker,资料全一点(虽然是英文的)。

===================================
》 可能对你有用的。

LSB是Linux Starnd Base,其实就是/etc/init.d下面的东西,一般可以用来被集群使用,
但是有一些不足,比如不能传参数,只能启动一个实例等。
OCF是open cluster framework,集群专用的标准,对使用来说最大的特点就是【参数】。

想命令行启动的话
export OCF_ROOT=/usr/lib/ocf
export OCF_RESKEY_httpd=/apache/bin/httpd
export OCF_RESKEY_configfile=/apache/conf/httpd.conf
注:我记得要配置PIDFILE的样子。
然后再使用脚本。

想配置到集群的话,没有crm命令只能用cibadmin命令改xml,参照pacemaker文档配吧,
简单点的只要照着ip那个来就可以了。

===================================
》 补充说明

-Hearbeat 1.0
    只支持2台机器...
    没有资源管理。(也就是不可以Apache在节点A上跑MySQL在节点B上跑,要么全A要么全B。)

-Heartbeat 2.0
   多了CRM(集群资源管理) 同时支持旧的haresources和新的cib.xml配置。

-Heartbeat 3.0
   CRM从Heartbeat项目分离成Pacemaker,成为主要要使用的东西,
   Heartbeat本身只是个通信层而已,man一下ha.cf各种deprecated。

heartbeat2.0的最后版本是2.0.14的样子,已经是很久以前的事了(估计四五年是有的了)。
目前heartbeat社区这么个东西已经废了,pacemaker的还挺活跃的,文档还在更新。

所以如果没什么特别要求,现在开始学的话学3(其实是学Pacemaker了)可能好点,资料相对较多。

===================================
》 其他

问道有先后,术业有专攻,人人都是“在路上”,没什么见笑。

我不懂,因为我不想懂不需要懂!
我不懂,但是我明天会懂!!
学,必有所得!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP