win10安装Zookeeper3.4.12

Posted hongdada

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了win10安装Zookeeper3.4.12相关的知识,希望对你有一定的参考价值。

目录

为了方便在本地开发环境进行调试,希望在win10环境中安装一个zookeeper

安装:

下载:

下载最新的stable版

zookeeper-3.4.12.tar.gz

配置环境变量:

ZOOKEEPER_HOME=D:Program Fileszookeeper-3.4.12

PATH=%ZOOKEEPER_HOME%in

目录说明:

bin:

.sh 为 linux 环境
.cmd 为 windows 环境

conf:

zoo_sample.cfg 为样例配置文件,需要修改自己的名称,一般为 zoo.cfg
log4j.properties 为日志配置文件

contrib

contrib 为一些常用于操作 zk 的工具包

lib

zk 依赖的某些包

recipes

zk 某些用法的代码实例

dist-maven

maven 编译后的发布目录

配置文件说明:

启动zk前,你需要做的就是将 zoo_sample.cfg 改名为 zoo.cfg,因为 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=C:\\zookeeper-3.4.5\\data
dataLogDir=C:\\zookeeper-3.4.5\\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
  • tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
  • dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
  • dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
  • clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。

启动:

启动服务端:

D:Program Fileszookeeper-3.4.12in
$ zkServer.cmd

call "D:Program FilesJavajdk1.8.0"injava "-Dzookeeper.log.dir=D:Program Fileszookeeper-3.4.12in.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "D:Program Fileszookeeper-3.4.12in..uildclasses;D:Program Fileszookeeper-3.4.12in..uildlib*;D:Program Fileszookeeper-3.4.12in..*;D:Program Fileszookeeper-3.4.12in..lib*;D:Program Fileszookeeper-3.4.12in..conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:Program Fileszookeeper-3.4.12in..confzoo.cfg"
2018-12-04 11:14:28,112 [myid:] - INFO  [main:[email protected]] - Reading configuration from: D:Program Fileszookeeper-3.4.12in..confzoo.cfg
2018-12-04 11:14:28,127 [myid:] - INFO  [main:[email protected]] - autopurge.snapRetainCount set to 3
2018-12-04 11:14:28,127 [myid:] - INFO  [main:[email protected]] - autopurge.purgeInterval set to 0
2018-12-04 11:14:28,128 [myid:] - INFO  [main:[email protected]] - Purge task is not scheduled.
2018-12-04 11:14:28,130 [myid:] - WARN  [main:[email protected]] - Either no config or no quorum defined in config, running  in standalone mode
2018-12-04 11:14:28,210 [myid:] - INFO  [main:[email protected]] - Reading configuration from: D:Program Fileszookeeper-3.4.12in..confzoo.cfg
2018-12-04 11:14:28,211 [myid:] - INFO  [main:[email protected]] - Starting server
2018-12-04 11:14:37,250 [myid:] - INFO  [main:[email protected]] - Server environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
2018-12-04 11:14:37,250 [myid:] - INFO  [main:[email protected]] - Server environment:host.name=hongda
2018-12-04 11:14:37,251 [myid:] - INFO  [main:[email protected]] - Server environment:java.version=1.8.0_181
2018-12-04 11:14:37,251 [myid:] - INFO  [main:[email protected]] - Server environment:java.vendor=Oracle Corporation 2018-12-04 11:14:37,251 [myid:] - INFO  [main:[email protected]] - Server environment:java.home=D:Program FilesJavajdk1.8.0jre
2018-12-04 11:14:37,252 [myid:] - INFO  [main:[email protected]] - Server environment:java.class.path=D:Program Fileszookeeper-3.4.12in..uildclasses;D:Program Fileszookeeper-3.4.12in..uildlib*;D:Program Fileszookeeper-3.4.12in..zookeeper-3.4.12.jar;D:Program Fileszookeeper-3.4.12in..libaudience-annotations-0.5.0.jar;D:Program Fileszookeeper-3.4.12in..libjline-0.9.94.jar;D:Program Fileszookeeper-3.4.12in..liblog4j-1.2.17.jar;D:Program Fileszookeeper-3.4.12in..lib
etty-3.10.6.Final.jar;D:Program Fileszookeeper-3.4.12in..libslf4j-api-1.7.25.jar;D:Program Fileszookeeper-3.4.12in..libslf4j-log4j12-1.7.25.jar;D:Program Fileszookeeper-3.4.12in..conf
2018-12-04 11:14:37,253 [myid:] - INFO  [main:[email protected]] - Server environment:java.library.path=D:Program FilesJavajdk1.8.0in;C:WINDOWSSunJavain;C:WINDOWSsystem32;C:WINDOWS;D:Program Filescmderin;D:Program Filescmdervendorconemu-maximus5ConEmuScripts;D:Program Filescmdervendorconemu-maximus5;D:Program Filescmdervendorconemu-maximus5ConEmu;D:Program Files
odejs
ode_global;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;%android_HOME%;%ANDROID_HOME%	ools;%ANDROID_HOME%uild-tools;%ANDROID_HOME%platform-tools;D:Program FilesTomcat8in;D:Program FilesJavajdk1.8.0in;D:Program FilesJavajdk1.8.0jrein;D:Program Filesmysqlin;D:Program Files (x86)JetBrainsIDEA Configuration And Cachegradlein;D:Program Files (x86)JetBrainsIDEA Configuration And Cachemavenin;D:Program Filescmder;D:Program Files
odejs;D:Program Filescurlin;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;D:Program FilesMicrosoft VS Codein;D:Program Files (x86)JetBrainsIDEA Configuration And Cachegradlein;D:Program FilesGitcmd;C:Program FilesTortoiseGitin;D:Program FilesPythonPython36Scripts;D:Program FilesPythonPython36;C:UsersqhongAppDataLocalMicrosoftWindowsApps;D:Program FilesMicrosoft VS Codein;C:Program FilesBandizip;C:UsersqhongAppDataLocalPandoc;C:Program Filessmartmontoolsin;C:UsersqhongAppDataLocalMicrosoftWindowsApps;D:Program FilesGitmingw64;D:Program FilesGitusrin;.
2018-12-04 11:14:37,257 [myid:] - INFO  [main:[email protected]] - Server environment:java.io.tmpdir=C:UsersqhongAppDataLocalTemp2018-12-04 11:14:37,258 [myid:] - INFO  [main:[email protected]] - Server environment:java.compiler=<NA>
2018-12-04 11:14:37,259 [myid:] - INFO  [main:[email protected]] - Server environment:os.name=Windows 10
2018-12-04 11:14:37,260 [myid:] - INFO  [main:[email protected]] - Server environment:os.arch=amd64
2018-12-04 11:14:37,260 [myid:] - INFO  [main:[email protected]] - Server environment:os.version=10.0
2018-12-04 11:14:37,260 [myid:] - INFO  [main:[email protected]] - Server environment:user.name=qhong
2018-12-04 11:14:37,261 [myid:] - INFO  [main:[email protected]] - Server environment:user.home=C:Usersqhong
2018-12-04 11:14:37,261 [myid:] - INFO  [main:[email protected]] - Server environment:user.dir=D:Program Fileszookeeper-3.4.12in
2018-12-04 11:14:37,277 [myid:] - INFO  [main:[email protected]] - tickTime set to 2000
2018-12-04 11:14:37,278 [myid:] - INFO  [main:[email protected]] - minSessionTimeout set to -1
2018-12-04 11:14:37,278 [myid:] - INFO  [main:[email protected]] - maxSessionTimeout set to -1
2018-12-04 11:14:38,473 [myid:] - INFO  [main:[email protected]] - Using org.apache.zookeeper.server.NioserverCnxnFactory as server connection factory
2018-12-04 11:14:38,477 [myid:] - INFO  [main:[email protected]] - binding to port 0.0.0.0/0.0.0.0:2181

查看:

D:Developmentpayment-server (master -> origin)
$ netstat -ano|grep "2181"
  TCP    0.0.0.0:2181           0.0.0.0:0              LISTENING       19912
  TCP    18.16.202.169:4403     18.16.200.41:2181      ESTABLISHED     18436
  TCP    18.16.202.169:10786    18.16.200.43:2181      ESTABLISHED     13780
  TCP    [::]:2181              [::]:0                 LISTENING       19912

D:Developmentpayment-server (master -> origin)
$ tasklist | findstr "19912"
java.exe                     19912 Console                    1     44,660 K

启动客户端:

D:Program Fileszookeeper-3.4.12in
$ zkCli.cmd -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2018-12-04 11:29:00,775 [myid:] - INFO  [main:[email protected]] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
2018-12-04 11:29:00,779 [myid:] - INFO  [main:[email protected]] - Client environment:host.name=hongda
2018-12-04 11:29:00,779 [myid:] - INFO  [main:[email protected]] - Client environment:java.version=1.8.0_181
2018-12-04 11:29:00,781 [myid:] - INFO  [main:[email protected]] - Client environment:java.vendor=Oracle Corporation 2018-12-04 11:29:00,782 [myid:] - INFO  [main:[email protected]] - Client environment:java.home=D:Program FilesJavajdk1.8.0jre
2018-12-04 11:29:00,782 [myid:] - INFO  [main:[email protected]] - Client environment:java.class.path=D:Program Fileszookeeper-3.4.12in..uildclasses;D:Program Fileszookeeper-3.4.12in..uildlib*;D:Program Fileszookeeper-3.4.12in..zookeeper-3.4.12.jar;D:Program Fileszookeeper-3.4.12in..libaudience-annotations-0.5.0.jar;D:Program Fileszookeeper-3.4.12in..libjline-0.9.94.jar;D:Program Fileszookeeper-3.4.12in..liblog4j-1.2.17.jar;D:Program Fileszookeeper-3.4.12in..lib
etty-3.10.6.Final.jar;D:Program Fileszookeeper-3.4.12in..libslf4j-api-1.7.25.jar;D:Program Fileszookeeper-3.4.12in..libslf4j-log4j12-1.7.25.jar;D:Program Fileszookeeper-3.4.12in..conf
2018-12-04 11:29:00,783 [myid:] - INFO  [main:[email protected]] - Client environment:java.library.path=D:Program FilesJavajdk1.8.0in;C:WINDOWSSunJavain;C:WINDOWSsystem32;C:WINDOWS;D:Program Filescmderin;D:Program Filescmdervendorconemu-maximus5ConEmuScripts;D:Program Filescmdervendorconemu-maximus5;D:Program Filescmdervendorconemu-maximus5ConEmu;D:Program Files
odejs
ode_global;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;%ANDROID_HOME%;%ANDROID_HOME%	ools;%ANDROID_HOME%uild-tools;%ANDROID_HOME%platform-tools;D:Program FilesTomcat8in;D:Program FilesJavajdk1.8.0in;D:Program FilesJavajdk1.8.0jrein;D:Program FilesMySQLin;D:Program Files (x86)JetBrainsIDEA Configuration And Cachegradlein;D:Program Files (x86)JetBrainsIDEA Configuration And Cachemavenin;D:Program Filescmder;D:Program Files
odejs;D:Program Filescurlin;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;D:Program FilesMicrosoft VS Codein;D:Program Files (x86)JetBrainsIDEA Configuration And Cachegradlein;D:Program FilesGitcmd;C:Program FilesTortoiseGitin;D:Program FilesPythonPython36Scripts;D:Program FilesPythonPython36;C:UsersqhongAppDataLocalMicrosoftWindowsApps;D:Program FilesMicrosoft VS Codein;C:Program FilesBandizip;C:UsersqhongAppDataLocalPandoc;C:Program Filessmartmontoolsin;C:UsersqhongAppDataLocalMicrosoftWindowsApps;D:Program FilesGitmingw64;D:Program FilesGitusrin;.
2018-12-04 11:29:00,787 [myid:] - INFO  [main:[email protected]] - Client environment:java.io.tmpdir=C:UsersqhongAppDataLocalTemp2018-12-04 11:29:00,788 [myid:] - INFO  [main:[email protected]] - Client environment:java.compiler=<NA>
2018-12-04 11:29:00,788 [myid:] - INFO  [main:[email protected]] - Client environment:os.name=Windows 10
2018-12-04 11:29:00,788 [myid:] - INFO  [main:[email protected]] - Client environment:os.arch=amd64
2018-12-04 11:29:00,789 [myid:] - INFO  [main:[email protected]] - Client environment:os.version=10.0
2018-12-04 11:29:00,789 [myid:] - INFO  [main:[email protected]] - Client environment:user.name=qhong
2018-12-04 11:29:00,789 [myid:] - INFO  [main:[email protected]] - Client environment:user.home=C:Usersqhong
2018-12-04 11:29:00,789 [myid:] - INFO  [main:[email protected]] - Client environment:user.dir=D:Program Fileszookeeper-3.4.12in
2018-12-04 11:29:00,792 [myid:] - INFO  [main:[email protected]] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 [email protected]
Welcome to ZooKeeper!
2018-12-04 11:29:02,164 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):Client[email protected]] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2018-12-04 11:29:02,169 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):[email protected]] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
JLine support is enabled
2018-12-04 11:29:02,216 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):[email protected]] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x10029a625410000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

操作命令:

ls:

[zk: 127.0.0.1:2181(CONNECTED) 1] ls /
[zookeeper]

create:

[zk: 127.0.0.1:2181(CONNECTED) 2] create /name hongdada
Created /name
[zk: 127.0.0.1:2181(CONNECTED) 4] ls /
[name, zookeeper]

get:

[zk: 127.0.0.1:2181(CONNECTED) 5] get /name   
hongdada                                      
cZxid = 0x2                                   
ctime = Tue Dec 04 13:08:06 CST 2018          
mZxid = 0x2                                   
mtime = Tue Dec 04 13:08:06 CST 2018          
pZxid = 0x2                                   
cversion = 0                                  
dataVersion = 0                               
aclVersion = 0                                
ephemeralOwner = 0x0                          
dataLength = 8                                
numChildren = 0                               

set:

[zk: 127.0.0.1:2181(CONNECTED) 7] set /name hondadadada
cZxid = 0x2
ctime = Tue Dec 04 13:08:06 CST 2018
mZxid = 0x3
mtime = Tue Dec 04 13:09:03 CST 2018
pZxid = 0x2
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 11
numChildren = 0

参考:

Windows安装和使用zookeeper

Windows 安装 ZooKeeper

以上是关于win10安装Zookeeper3.4.12的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7.5搭建Zookeeper3.4.12集群与命令行操作

solr7.5+zookeeper3.4.12+jdk1.8+zkui

CentOS7 安装kylin2.6.0集群

win10chm格式的文件打开一片空白,只有左上角有帮助两个字!

kafka 和zookeeper集群配置参考

苹果电脑安装windows