zookeeper学习一:zookeeper的下载、安装、和常见启动问题的解决

本文主要讲解zookeeper的下载、安装、和常见启动问题的解决

一:下载

官网下载地址:http://mirror.bit.edu.cn/apache/zookeeper/ 

1:选择要下载的版本,这里我选择的是3.5.5版本

2:选择带有bin名称的包进行下载(至于为什么选择,下面解释)

二:安装

1:将下载的下来的包解压,并手动创建“data”和“log”两个文件夹

2:进入conf文件夹下,选择“zoo_sample.cfg”文件,复制一份更名“zoo.cfg”

3:进入zoo.cfg进行编辑

 

# The number of milliseconds of each tick

#tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take

#initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper 服务器的客户端,
#而是 Zookeeper 服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。
#当已经超过 10 个心跳的时间(也就是 tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,
#那么表明这个客户端连接失败。总的时间长度就是 10*2000=20 秒

initLimit=10

# The number of ticks that can pass between 
# sending a request and getting an acknowledgement

#syncLimit:这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,
#最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 5*2000=10 秒
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.

#dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
dataDir=D:\apache-zookeeper-3.5.5-bin\apache-zookeeper-3.5.5-bin\data
dataLogDir=D:\apache-zookeeper-3.5.5-bin\apache-zookeeper-3.5.5-bin\log
# the port at which the clients will connect

#clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
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

 

三:启动

进入bin目录,点击zkServer.com进行启动,如果你启动成功就不用看下面了。

四:常见问题

1:启动闪退

如果您启动闪退:说明有报错。先查看报错信息,在解决报错

点击zkServer.cmd文件,在最下面添加pause,这样就可以看到报错信息

错误:文件名、目录名或卷标语法不正确

如果报错信息是这个,查看一下你的jdk环境变量的配置,看是否有JAVA_HOME,并且看它的 路径是否真实存在。

因为,zookeeper里面配置的是系统中的jdk环境变量

2:找不到或无法加载主类 org.apache.zookeeper.server.quorum.QuorumPeerMain

这里就要说上面为什么要选择src的包了

从目前的最新版本3.5.5开始,带有bin名称的包才是我们想要的下载可以直接使用的里面有编译后的二进制的包,而之前的普通的tar.gz的包里面是只是源码的包无法直接使用

 

----------------------------------------------------------------------------------------------------------------------此系列所有内容均学习传智播客视频

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值