首页 > 其他 > 详细

zookeeper安装及使用

时间:2017-12-27 16:57:02      阅读:199      评论:0      收藏:0      [点我收藏+]

0. 下载并安装

1. 开机启动

cd  /etc/rc.d/init.d

touch zookeeper

vi zookeeper

#!/bin/bash
#chkconfig
#description: service zookeeper
export JAVA_HOME=/usr/java/jdk1.8.0_144
export ZOO_LOG_DIR=/rocky/data/zookeeper/dataLog
ZOOKEEPER_HOME=/usr/local/services/zookeeper-3.4.9
su root ${ZOOKEEPER_HOME}/bin/zkServer.sh "$1"

或者

#!/bin/bash  
#chkconfig: 2345 10 90  
#description: service zookeeper  
export    JAVA_HOME=/opt/java/jdk1.8.0_121  
export     ZOO_LOG_DIR=/opt/zookeeper/log  
ZOOKEEPER_HOME=/opt/zookeeper/zookeeper-3.4.10  
case  "$1"   in  
          start)  su  root   ${ZOOKEEPER_HOME}/bin/zkServer.sh   start;;  
          start-foreground)  su  root  ${ZOOKEEPER_HOME}/bin/zkServer.sh    start-foreground;;  
          stop)  su  root   ${ZOOKEEPER_HOME}/bin/zkServer.sh   stop;;  
          status)  su root  ${ZOOKEEPER_HOME}/bin/zkServer.sh    status;;  
          restart)  su root   ${ZOOKEEPER_HOME}/bin/zkServer.sh   restart;;  
          upgrade)su root   ${ZOOKEEPER_HOME}/bin/zkServer.sh   upgrade;;  
          print-cmd)su root   ${ZOOKEEPER_HOME}/bin/zkServer.sh   print-cmd;;  
          *)  echo  "requirestart|start-foreground|stop|status|restart|print-cmd";;  
esac

复制zoo_sample.cfg并修改zoo.cfg(data及 datalog目录)

[root@dev_pc1 conf]# cat zoo.cfg 
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
#data directory   /usr/local/services/zookeeper-3.4.9/data
dataDir=/rocky/data/zookeeper/data
#log directory  /usr/local/services/zookeeper-3.4.9/logs
dataLogDir=/rocky/data/zookeeper/dataLog
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

 

2. 添加权限

[root@dev_pc1 init.d]# chmod +x zookeeper

3. 添加到开机启动

[root@dev_pc1 init.d]# chkconfig --add zookeeper

问题
service zookeeper does not support chkconfig

解决方法

[root@dev_pc1 init.d]# vi zookeeper
#!/bin/bash
#chkconfig:2345 10 90
#description: service zookeeper

查看

[root@dev_pc1 init.d]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use ‘systemctl list-unit-files‘.
      To see services enabled on particular target use
      ‘systemctl list-dependencies [target]‘.

netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
zookeeper       0:off   1:off   2:on    3:on    4:on    5:on    6:off

 重启 reboot

验证方式一   service zookeeper status

[root@dev_pc1 ~]# service zookeeper status
ZooKeeper JMX enabled by default
Using config: /usr/local/services/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone

验证方式二  lsof -i:2181

yum install lsof
[root@dev_pc1 conf]# lsof -i:2181
COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    835 root   23u  IPv6  16742      0t0  TCP *:eforward (LISTEN)

验证方式三  netstat -lntup

tcp6       0      0 :::2181                 :::*                    LISTEN      835/java 

 

zookeeper安装及使用

原文:https://www.cnblogs.com/rocky-fang/p/7880309.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!