zookeeper在window下的搭建
安装zk前置条件
- 安装jdk,并配置环境变量
- 下载zookeeper。在官网http://zookeeper.apache.org/下载zookeeper,本文中使用使用的版本是:zookeeper-3.3.6
- 将文件解压到D:\zookeeper
单机安装
- 将解压后的文件重命名,修改后的文件目录为
D:\zookeeper\zookeeper-single
- 将zoo_sample.cfg重命名为zoo.cfg,并指定data和log的路径,端口
#tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
#dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
#dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
#clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求# 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=D:\\zookeeper\\zookeeper-single\\data
dataLogDir=D:\\zookeeper\\zookeeper-single\\log
# the port at which the clients will connect
# 服务端口
clientPort=2180
#
# 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
- 启动zookeeper
D:\zookeeper\zookeeper-single\bin>cd D:\zookeeper\zookeeper-single\bin
D:\zookeeper\zookeeper-single\bin>D:
D:\zookeeper\zookeeper-single\bin>zkServer.cmd
启动日志如下:
D:\zookeeper\zookeeper-single\bin>java "-Dzookeeper.log.dir=D:\zookeeper\zookeeper-single\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "D:\zookeeper\zookeeper-single\bin\..\build\classes;D:\zookeeper\zookeeper-single\bin\..\build\lib\*;D:\zookeeper\zookeeper-single\bin\..\*;D:\zookeeper\zookeeper-single\bin\..\lib\*;D:\zookeeper\zookeeper-single\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:\zookeeper\zookeeper-single\bin\..\conf\zoo.cfg"
2020-04-19 11:58:41,389 - INFO [main:QuorumPeerConfig@90] - Reading configuration from: D:\zookeeper\zookeeper-single\bin\..\conf\zoo.cfg
2020-04-19 11:58:41,401 - WARN [main:QuorumPeerMain@105] - Either no config or no quorum defined in config, running in standalone mode
2020-04-19 11:58:41,510 - INFO [main:QuorumPeerConfig@90] - Reading configuration from: D:\zookeeper\zookeeper-single\bin\..\conf\zoo.cfg
2020-04-19 11:58:41,512 - INFO [main:ZooKeeperServerMain@94] - Starting server
2020-04-19 11:58:41,550 - INFO [main:Environment@97] - Server environment:zookeeper.version=3.3.6-1366786, built on 07/29/2012 06:22 GMT
2020-04-19 11:58:41,551 - INFO [main:Environment@97] - Server environment:host.name=JT3RNV28I7B8K6A
2020-04-19 11:58:41,555 - INFO [main:Environment@97] - Server environment:java.version=1.8.0_45
2020-04-19 11:58:41,557 - INFO [main:Environment@97] - Server environment:java.vendor=Oracle Corporation
2020-04-19 11:58:41,559 - INFO [main:Environment@97] - Server environment:java.home=D:\Program Files\Java\jre1.8.0_45
2020-04-19 11:58:41,560 - INFO [main:Environment@97] - Server environment:java.class.path=D:\zookeeper\zookeeper-single\bin\..\build\classes;D:\zookeeper\zookeeper-single\bin\..\build\lib\*;D:\zookeeper\zookeeper-single\bin\..\zookeeper-3.3.6.jar;D:\zookeeper\zookeeper-single\bin\..\lib\jline-0.9.94.jar;D:\zookeeper\zookeeper-single\bin\..\lib\log4j-1.2.15.jar;D:\zookeeper\zookeeper-single\bin\..\conf
2020-04-19 11:58:41,565 - INFO [main:Environment@97] - Server environment:java.library.path=C:\ProgramData\Oracle\Java\javapath;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\Ruby23-x64\bin;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;D:\MyPath;D:\Program Files\Java\jdk1.8.0_45\bin;D:\Program Files\Apache\apache-maven-3.1.0\bin;D:\Program Files\Apache\apache-ant-1.9.6\bin;D:\Program Files\gradle-2.2.1\bin;D:\Program Files\MongoDB\Server\3.2\bin;D:\Program Files\TortoiseSVN\bin;D:\Program Files\Git\cmd;D:\Program Files\Git\usr\bin;D:\Program Files\TortoiseGit\bin;D:\Library\androidSdk\platform-tools;D:\Program Files (x86)\MySQL\MySQL Server 5.1\bin;D:\Program Files\nodejs\;C:\Android;C:\Windows\System32;D:\Python;C:\Program Files (x86)\HP\Common\HPDestPlgIn\;C:\Program Files (x86)\HP\IdrsOCR_15.3.1129.0\;D:\Python\Scripts\;D:\Python\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm;D:\Users\Administrator\AppData\Local\Programs\Fiddler;C:\Program Files (x86)\HP\Common\HPDestPlgIn\;.
2020-04-19 11:58:41,569 - INFO [main:Environment@97] - Server environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\
2020-04-19 11:58:41,570 - INFO [main:Environment@97] - Server environment:java.compiler=<NA>
2020-04-19 11:58:41,571 - INFO [main:Environment@97] - Server environment:os.name=Windows 8.1
2020-04-19 11:58:41,576 - INFO [main:Environment@97] - Server environment:os.arch=amd64
2020-04-19 11:58:41,580 - INFO [main:Environment@97] - Server environment:os.version=6.3
2020-04-19 11:58:41,581 - INFO [main:Environment@97] - Server environment:user.name=Administrator
2020-04-19 11:58:41,583 - INFO [main:Environment@97] - Server environment:user.home=C:\Users\Administrator
2020-04-19 11:58:41,584 - INFO [main:Environment@97] - Server environment:user.dir=D:\zookeeper\zookeeper-single\bin
2020-04-19 11:58:41,597 - INFO [main:ZooKeeperServer@673] - tickTime set to 2000
2020-04-19 11:58:41,597 - INFO [main:ZooKeeperServer@682] - minSessionTimeout set to -1
2020-04-19 11:58:41,601 - INFO [main:ZooKeeperServer@691] - maxSessionTimeout set to -1
2020-04-19 11:58:41,710 - INFO [main:NIOServerCnxn$Factory@143] - binding to port 0.0.0.0/0.0.0.0:2180
2020-04-19 11:58:41,730 - INFO [main:FileSnap@82] - Reading snapshot D:\zookeeper\zookeeper-single\data\version-2\snapshot.0
2020-04-19 11:58:41,740 - INFO [main:FileTxnSnapLog@256] - Snapshotting: 0
伪集群搭建
- 按照上面的步骤搭建好单机节点,并且复制成3份,本文中的目录如下
D:\zookeeper\zookeeper0
D:\zookeeper\zookeeper1
D:\zookeeper\zookeeper2
- 修改每一个节点的zoo.cfg中的clientPort、dataDir、dataLogDir
zookeeper0的zoo.cfg修改后
#tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
#dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
#dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
#clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求# 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=D:\\zookeeper\\zookeeper0\\data
dataLogDir=D:\\zookeeper\\zookeeper0\\log
# the port at which the clients will connect
clientPort=2180
#
# 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.A=B:C:D 其中A是服务器的编号,B是服务器的ip地址,C是leader选举的端口,D是zk节点通信端口
server.0=localhost:12287:13387
server.1=localhost:12288:13388
server.2=localhost:12289:13389
zookeeper1的zoo.cfg修改后
#tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
#dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
#dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
#clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求# 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=D:\\zookeeper\\zookeeper1\\data
dataLogDir=D:\\zookeeper\\zookeeper1\\log
# 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#server.A=B:C:D 其中A是服务器的编号,B是服务器的ip地址,C是leader选举的端口,D是zk节点通信端口
server.0=localhost:12287:13387
server.1=localhost:12288:13388
server.2=localhost:12289:13389
zookeeper2的zoo.cfg修改后
#tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
#dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
#dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
#clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求# 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=D:\\zookeeper\\zookeeper2\\data
dataLogDir=D:\\zookeeper\\zookeeper2\\log
# the port at which the clients will connect
clientPort=2182
#
# 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.A=B:C:D 其中A是服务器的编号,B是服务器的ip地址,C是leader选举的端口,D是zk节点通信端口
server.0=localhost:12287:13387
server.1=localhost:12288:13388
server.2=localhost:12289:13389
- 在各个节点里面的dateDir目录下创建myid文件(注意没有后缀名)
文件内容就是各个节点的编号,zookeeper0的myid文件里面就是0,zookeeper1的myid文件里面就是1,zookeeper2的myid文件里面就是2 - 启动各个节点,集群搭建完毕
配置参数含义
在zoo.cfg中的配置参数的含义如下
- tickTime:基本事件单元,这个时间是作为Zookeeper服务器之间或客户端与服务器之间维持心跳的时间间隔,每隔tickTime时间就会发送一个心跳;最小 的session过期时间为2倍tickTime
- dataDir:存储内存中数据库快照的位置,除非另有说明,否则指向数据库更新的事务日志。注意:应该谨慎的选择日志存放的位置,使用专用的日志存储设备能够大大提高系统的性能,如果将日志存储在比较繁忙的存储设备上,那么将会很大程度上影像系统性能。
- client:监听客户端连接的端口。
- initLimit:允许follower连接并同步到Leader的初始化连接时间,以tickTime为单位。当初始化连接时间超过该值,则表示连接失败。
- syncLimit:表示Leader与Follower之间发送消息时,请求和应答时间长度。如果follower在设置时间内不能与leader通信,那么此follower将会被丢弃。
- server.A=B:C:D
A:其中 A 是一个数字,表示这个是服务器的编号;
B:是这个服务器的 ip 地址;
C:Leader选举的端口;
D:Zookeeper服务器之间的通信端口。
配置zk集群需要新增的是 server.A=B:C:D 配置,其中 A 对应myid 文件里面的内容。B是集群的各个IP地址,C:D 是端口配置。
Zookeeper的一些常用命令
- 启动zookeeper: ./zkServer.sh start
- 关闭zookeeper: ./zkServer.sh stop
- 客户端连接 ./zkCli.sh -server localhost:2181
- 查询当前zookeeper的状态 ./zkServer.sh status
- 客户端连接上zookeeper后,可以使用help命令来查询zookeeper的命令
- 关闭与服务端的连接 : close
- 连接服务端:connect 127.0.0.1:2181
- 创建节点 create /name value
- 获取节点的信息 get /name
- 列出节点 ls /name
- 删除节点信息 delete /name
- 列出节点 ls2 /name 是ls的加强版
- 列出历史执行命令 history
- 重新执行某个命令和history结合使用 redo 20
- sync 强制同步
- stat 查看节点信息
- 显示配额 listquota /name
- 设置配额 setquota /name
- 删除配额 delquota /name
- addauth命令用于节点认证,使用方式:如addauth digest username:password
- setAcl命令用于设置节点Acl,Acl由三部分构成:1为scheme,2为user,3为permission,一般情况下表示为scheme
zookeeper在window下的搭建相关推荐
- window下eclipse搭建C/C++开发环境(超简单无需插件版) .
经过若干google之后(百度就不用说了),又经过了若干尝试,终于用最简单的步骤配起来了.(一些比较旧的文章写的太繁杂了,随着各个工具的升级,搭建环境很简单了). 前言:写博客不是为了炫耀什么.发泄什 ...
- window下eslipse搭建django遇到的问题以及解决方法积累(持续更新)
1.模板系统: 问题:because environment variable DJANGO_SETTINGS_MODULE is undefined 解决:右键 -- Run As -- Run C ...
- window下zookeeper的下载启动和报错等问题
在使用dubbo等需要用到zookeeper,之前window下本地部署,启动一直有问题,后面折腾了下才部署成功,此次记录下来. 将zookeeper下载之后,解压到指定目录即可,无需安装.例如:解压 ...
- window下搭建qnx编译环境
引言 window下搭建qnx编译环境 流程说明 1. 前置条件说明 1.1 安装cmake 下载地址(https://cmake.org/files/v3.18/ 的make-3.18.1-win6 ...
- 第1章 Window下VSCode的C语言开发环境搭建 (一)
文章目录 文档视频讲解链接地址 第01章 开发环境搭建 1.1 C语言开发环境搭建 1. 常用的C语言开发环境介绍 VC++ 6.0 VS 2019 Clion DevC++ vim编辑 VSCode ...
- window下使用nw.js开发桌面应用程序环境的搭建
安装node window下去node官网下载长期支持版本或者最新稳定版都可以. 按装nw用来管理和按装nw.js npm install -g nrm # 用来设置npm镜像地址 npm insta ...
- 基于zookeeper的solrCloud集群搭建
转自:https://blog.csdn.net/yougoule/article/details/78445759 基于原文对实践遇到的问题稍作补充 1.安装及搭建相关环境 1.1环境准备 cen ...
- window下安装Memcache
说来惭愧,从事PHP已经1年多了,但是很多PHP相关的知识都不知道. 前一阵子看到网上流传了很久的面试题,才了解到原来还有memcache这么个东西-_-. memcache 具体是什么Google一 ...
- zookeeper 在 windows 下配置伪集群环境
安装启动zookeeper 在 Apache zookeeper 官网下载 https://www.apache.org/dyn/closer.cgi/zookeeper/ 下载后解压,我使用的是3. ...
最新文章
- 打开快手,体验流畅的单目三维手势技术
- javascript算法题:求任意一个1-9位不重复的N位数在该组合中的大小排列序号
- 什么是分镜头剧本?(分镜头剧本是将文字转换成立体视听形象的中间媒介。主要任务是根据解说词和电视文学脚本来设计相应画面,配置音乐音响,把握片子的节奏和风格等。)
- 团队开发——冲刺1.d
- hiho一下第128周 后缀自动机二·重复旋律5
- 新年第一份“欧气”,“中国开发者大调查”第五批中奖名单出炉啦
- 我的世界手机版javaui材质包_我的世界手机版大乱斗卡比模组
- u盘启动盘恢复计算机,怎么还原u盘启动盘为普通u盘?
- Sql server2005 char/varchar/text和nchar/nvarchar/ntest的区别
- 校园网如何更改ip地址
- 关于身份证号或者手机号,密码 隐藏中间几位数字
- OpenHarmony(鸿蒙)操作系统
- 【排序专训】练习题 士兵站队(中位数应用) 解题报告
- 如何忽略IE代理设置
- 清理蓝藻的机器人_蓝藻打捞机 蓝藻打捞设备 蓝藻清除机 绿藻打捞设备 水华清除机...
- elastic官网文档翻译来.1
- iPhone游戏开发
- 中国电子设计自动化(EDA)软件行业未来发展趋势与投资前景分析报告22022-2028年版
- AAA学习攻略-41 个人知识管理的25个方法
- 蜂鸟E203 SOC系统
热门文章
- 大洋洲群狼来了! 这是中国篮球学习契机?
- SAP在快速消费品行业中的实施方案
- 以“数”赋能驱动企业转型 美的集团秘诀都在这里
- 从B站到咪咕圈圈,看汉服「出圈」与年轻人「入圈」
- 猫眼娱乐2020年上半年交出最差答卷,下半年能满血复活吗?
- win8换成linux桌面,Ubuntu/Linux Mint分分钟变Win8风
- 混凝土静力受压弹性模量试验计算公式_2019年度水运材料考试大纲微试验
- ado filter 多条记录_江苏气动断料锯商家,多条锯_邢台富宇来机械厂
- 中只有负下标里才能有零_门诊营销第一人武威名:诊所如何提升成交率之零风险承诺的运用?...
- 用python实现复选框树_如何使用Python中的复选框创建树视图
- window下eclipse搭建C/C++开发环境(超简单无需插件版) .