我在Ubuntu 14.04 LTS上使用以下指南设置Corosync / Pacemaker集群+ HAproxy: http : //www.sebastien-han.fr/blog/2012/04/15/active-passive-failover-cluster-on-a-的MySQL-加莱拉群集与- HAProxy的-LSB剂/
我没有添加虚拟IP设置,只有两个节点,都安装了Haproxy。 我正在使用lsb:haproxy,我的configuration如下:
为了testing一切,我运行以下命令来终止haproxy进程:sudo kill -9 [PID#]
然后,我检查群集的状态并收到以下错误消息:“失败的操作:权限不足”。 我没有更改haproxy用户/组定义,我的aisexec {}对用户和组都使用root。
如果我想让Corosync / Pacemakerpipe理Haproxy,我的权限应该是什么?
编辑:当我运行下面的服务停止命令,haproxy按预期重新启动。 检查crm status
haproxy守护进程正常运行
# sudo service haproxy stop # sudo crm status HaproxyHA (lsb:haproxy): Started node1 Failed Actions:
但是当我手动杀死pid时,我一直看到错误:
# sudo kill -9 $PID HaproxyHA (lsb:haproxy): Started node1 (unmanaged) FAILED Failed Actions:
在执行更改后,Federico提到(/bin/kill $pid || return 7)
它不会改变我的问题,我在我的日志中find这个:
pengine: warning: unpack_rsc_op: Processing failed op stop for HaproxyHA on node1: not running (7)
我认为问题是在初始化脚本 ,它不尊重LSB规范 。
如果您查看文件/etc/init.d/haproxy
中的函数haproxy_stop
:
haproxy_stop() { if [ ! -f $PIDFILE ] ; then # This is a success according to LSB return 0 fi for pid in $(cat $PIDFILE) ; do /bin/kill $pid || return 4 done rm -f $PIDFILE return 0 }
特别是/bin/kill $pid || return 4
/bin/kill $pid || return 4
。 这使得进程被杀死的情况下,返回值是4,根据规范这是: 用户没有足够的权限 。 这是不正确的。
如果在处理除状态以外的任何init-script动作时发生错误,init脚本将打印一条错误消息并以非零状态码退出:
1 generic or unspecified error (current practice) 2 invalid or excess argument(s) 3 unimplemented feature (for example, "reload") 4 user had insufficient privilege 5 program is not installed 6 program is not configured 7 program is not running 8-99 reserved for future LSB use 100-149 reserved for distribution use 150-199 reserved for application use 200-254 reserved
你可以尝试改变:
/bin/kill $pid || return 7
正确的方法是使用killproc(8)停止守护进程,如果失败, killproc
根据LSB设置返回值。
例如。
/sbin/killproc -p $PIDFILE $HAPROXY
当且仅当该pid属于
$PIDFILE
时,才将信号SIGTERM发送到在$PIDFILE
find的pid。 如果命名的$PIDFILE
不存在,killproc就认为$ HAPROXY的守护进程没有运行。 如果程序没有运行,则退出状态设置为0,否则成功将缺省信号SIGTERM和SIGKILL发送到7。 如果没有指定信号,并且没有终止程序,因为它已经被终止。