一、Zookeeper单体版安装
在安装zookeeper之前要先安装jdk环境,具体在linux环境安装jdk1.8请参照linux笔记。
1.在/usr/local/zoo 文件夹下执行命令 wget http://apache.fayea.com/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz 下载zookeeper压缩包,并执行tar -zxvf 进行解压。
2.初次使用zookeeper需要将conf文件夹下的zoo_sample.cfg修改为zoo.cfg。
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=/tomcathxw/zookeeper/apache-zookeeper-3.5.5-bin/data
dataLogDir=/tomcathxw/zookeeper/apache-zookeeper-3.5.5-bin/logs
# 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
3.在zookeeper安装目录下建立一个文件夹data。
4.修改zoo.cfg文件中的dataDir为data的路径,保存退出。
5.启动zookeeper,zkServer.sh.
(遇到的问题,在bin目录下执行zkServer.sh start提示我命令不存在???
原因是zookeeper没有配置环境变量,可以选择配置环境变量或者使用命令./zkServer.sh start)
(修改之后。。。。命令好使了,但是启动失败,连原因都没有,查看zookeeper目录下的logs发现报错:Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain
) 这里注意一个大坑:
在zookeeper3.5.5版本中,官网下载有两个文件:
要选择第一个压缩包下载,第二个压缩包是源码包,第一个压缩包下载后按照正常步骤就可以运行起来,太坑了。
要选择第一个压缩包下载,第二个压缩包是源码包,第一个压缩包下载后按照正常步骤就可以运行起来,太坑了。