zookeeper 安装与配置

本贴最后更新于 1952 天前,其中的信息可能已经天翻地覆

linux 下 zookeeper 的安装配置与 windows 下基本相同,仅启动方式有细微差异,本文以 windows 下安装为例。linux 下安装 zookeeper 可参考 dubbo 的官方文档,地址为:http://dubbo.io/books/dubbo-admin-book/install/zookeeper.html

一、下载 zookeeper

下载地址:https://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
解压后得到文件夹 zookeeper-3.4.11
假设保存路径为:E:\zookeeper\zookeeper-3.4.11

二、配置

进入 conf 文件夹,新建文件 zoo.cfg,文件内容如下:


# The number of milliseconds of each tick 心跳检测时间间隔/ms
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=E:\zookeeper\data
#日志位置,此目录位置需要设置为自己服务器的真实路径
dataLogDir=E:\zookeeper\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
#如果需要集群,可使用以下配置
#server.1=10.20.153.10:2555:3555
#server.2=10.20.153.11:2555:3555

如果使用了集群配置,需要在 data 目录下放置 myid 文件。
进入 E:\zookeeper\data 目录,新建文件 myidmyid 指明自己的 id,对应上面 zoo.cfgserver. 后的数字,第一台的内容为 1,第二台的内容为 2。
即可编辑 ip:10.20.153.10 下的 zookeeper 下的 myid 文件内容为:

1

三、启动

进入 bin 文件夹下,双击启动 zkServer.cmd
另外开启一个命令行窗口,输入命令 jps,可以看到 QuorumPeerMain 的进程,如下图:

d852d0d13f954270987d7b68834fe3cf-image.png

此时启动客户端查看一下,在 bin 目录下打开命令行窗口,执行:

zkCli.cmd -server 127.0.0.1:2181

可以看到 zkServer.cmd 对应的命令行窗口中相关日志信息,如下图:

ccf6fe2e447c491aba66e3764feff141-image.png

  • Linux

    Linux 是一套免费使用和自由传播的类 Unix 操作系统,是一个基于 POSIX 和 Unix 的多用户、多任务、支持多线程和多 CPU 的操作系统。它能运行主要的 Unix 工具软件、应用程序和网络协议,并支持 32 位和 64 位硬件。Linux 继承了 Unix 以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

    915 引用 • 931 回帖
  • ZooKeeper

    ZooKeeper 是一个分布式的,开放源码的分布式应用程序协调服务,是 Google 的 Chubby 一个开源的实现,是 Hadoop 和 HBase 的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。

    59 引用 • 29 回帖 • 15 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...