zookeeper 3.3.4中的zkServer.sh

近日在Red Hat Linux上安装zookeeper 3.3.4版本,发现zkServer.sh脚本中关于status的写法有点问题,总是提示服务未运行。查看代码,发现脚本中使用了 -q 参数,但这个参数在笔者的nc命令中,不支持。

status)
# -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output
STAT=`echo stat | nc -q 1 localhost $(grep “^[[:space:]]*clientPort” “$ZOOCFG” | sed -e ‘s/.*=//’) 2> /dev/null| grep Mode`
if [ "x$STAT" = "x" ]
then
echo “Error contacting service. It is probably not running.”
exit 1
else
echo $STAT
exit 0
fi
;;

去掉-q参数,同时去掉最后的“grep Mode”,使输出结果信息更丰富:

STAT=`echo stat | nc localhost $(grep “^[[:space:]]*clientPort” “$ZOOCFG” | sed -e ‘s/.*=//’) 2> /dev/null`

在笔者的4节点zookeeper集群中,运行结果如下:

[admin@vm-dw-141-70 bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /home/admin/zookeeper-3.3.4/bin/../conf/zoo.cfg
Zookeeper version: 3.3.3-1203054, built on 11/17/2011 05:47 GMT Clients: /127.0.0.1:57549[0](queued=0,recved=1,sent=0) Latency min/avg/max: 0/3/16 Received: 11 Sent: 10 Outstanding: 0 Zxid: 0×100000008 Mode: leader Node count: 4


Data Warehouse For Ever原创文章,转载请注明出处

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>