zookeeper入门学习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zookeeper入门学习相关的知识,希望对你有一定的参考价值。
zookeeper安装
单机模式
首先,下载zookeeper-3.4.8.tar.gz
创建/usr/zookeeper,解压到zookeeper目录
[[email protected] zookeeper]# tar -zxvf zookeeper-3.4.8.tar.gz
配置环境变量:
为了今后操作方便,我们需要对Zookeeper的环境变量进行配置,方法如下在/etc/profile文件中加入如下内容:
[[email protected] liutie]# vi /etc/profile
#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_131
JRE_HOME=/usr/java/jdk1.8.0_131/jre
ZOOKEEPER_HOME=/usr/zookpeer/zookpeer-3.4.8
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:ZOOKEEPER_HOME/bin
使环境变量生效
[[email protected] liutie]# source /etc/profile
进入zookeeper文件夹的bin目录修改zoo_simple.cfg为zoo.cfg
[[email protected] conf]# mv zoo_sample.cfg zoo.cfg
修改zoo.cfg
[[email protected] conf]# vi 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. dataDir=/tmp/zookeeper # the port at which the clients will connect clientPort=2181 # # 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
保存后进入bin目录启动服务端
[[email protected] bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 9176.
以上是关于zookeeper入门学习的主要内容,如果未能解决你的问题,请参考以下文章