当前位置:首页 > 服务端 > Zookeeper下载与安装教程(for windows)

Zookeeper下载与安装教程(for windows)

2022年09月16日 10:04:20服务端6

Zookeeper下载

1、首先进入apache官网

  • https://www.apache.org/
    然后点击中间的Projects->Project List菜单项进入ProjectList页面,如下图:
    Zookeeper下载与安装教程(for windows) _ JavaClub全栈架构师技术笔记
    2、在ProjectList页面中找点Zookeeper链接,然后点击进入Zookeeper的主页,如下图:
    Zookeeper下载与安装教程(for windows) _ JavaClub全栈架构师技术笔记
    3、在Zookeeper主页的顶部点击菜单Project->Releases,进入Zookeeper发布版本信息页面,如下图:
    Zookeeper下载与安装教程(for windows) _ JavaClub全栈架构师技术笔记
    4、找到最新版的下载链接,如下图:
    Zookeeper下载与安装教程(for windows) _ JavaClub全栈架构师技术笔记
    5、目前最新版本是3.6.2,点击链接进入下载的镜像地址页面,如下图:
    Zookeeper下载与安装教程(for windows) _ JavaClub全栈架构师技术笔记
    6、在国内直接选择清华大学的镜像下载链接进行下载就行,下载后如下图:
    Zookeeper下载与安装教程(for windows) _ JavaClub全栈架构师技术笔记

Zookeeper安装

前置条件

  • 已安装JDK
  • 已配置了环境变量JAVA_HOME,PATH

单机模式部署

1、解压apache-zookeeper-3.6.2-bin.tar.gz至D:\zookeeper\apache-zookeeper-3.6.2-bin。
2、复制D:\zookeeper\apache-zookeeper-3.6.2-bin\conf\zoo-sample.cfg,粘贴为D:\zookeeper\apache-zookeeper-3.6.2-bin\zoo.cfg。
3、修改D:\zookeeper\apache-zookeeper-3.6.2-bin\zoo.cfg。
主要修改了dataDir,如下:

# 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\\data
# 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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

# server.N = YYY:A:B

配置文件关键配置项说明:

  • tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
  • initLimit:LF初始通信时限,集群中的follower服务器(F)与leader服务器(L)之间初始连接时能容忍的最多心跳数(tickTime的数量)。
  • syncLimit:LF同步通信时限,集群中的follower服务器与leader服务器之间请求和应答之间能容忍的最多心跳数(tickTime的数量)。
  • dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
  • clientPort:客户端连接端口,这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求
  • autopurge.snapRetainCount:保留数量。
  • autopurge.purgeInterval:清理时间间隔,单位:小时。
  • server.N = YYY:A:B,其中N表示服务器编号,YYY表示服务器的IP地址,A为LF通信端口,表示该服务器与集群中的leader交换的信息的端口。B为选举端口,表示选举新leader时服务器间相互通信的端口(当leader挂掉时,其余服务器会相互通信,选择出新的leader)。一般来说,集群中每个服务器的A端口都是一样,每个服务器的B端口也是一样。但是当所采用的为伪集群时,IP地址都一样,只能时A端口和B端口不一样。

4、启动Zookeeper服务器。
在bin目录下执行

zkServer.cmd

就可以了,如下:

D:\zookeeper\apache-zookeeper-3.6.2-bin\bin>zkServer.cmd

D:\zookeeper\apache-zookeeper-3.6.2-bin\bin>call "C:\Java\jre1.8.0_144"\bin\java "-Dzookeeper.log.dir=D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\logs" "-Dzookeeper.root.logger=INFO,CONSOLE" "-Dzookeeper.log.file=zookeeper-Administrator-server-ECS-A0E1-0001.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f" -cp "D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\build\classes;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\build\lib\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\conf\zoo.cfg"
2020-11-13 14:13:15,368 [myid:] - INFO  [main:QuorumPeerConfig@174] - Reading configuration from: D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\conf\zoo.cfg
2020-11-13 14:13:15,399 [myid:] - INFO  [main:QuorumPeerConfig@460] - clientPortAddress is 0.0.0.0:2181
2020-11-13 14:13:15,399 [myid:] - INFO  [main:QuorumPeerConfig@464] - secureClientPort is not set
2020-11-13 14:13:15,399 [myid:] - INFO  [main:QuorumPeerConfig@480] - observerMasterPort is not set
2020-11-13 14:13:15,399 [myid:] - INFO  [main:QuorumPeerConfig@497] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2020-11-13 14:13:15,399 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2020-11-13 14:13:15,399 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2020-11-13 14:13:15,399 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2020-11-13 14:13:15,399 [myid:] - WARN  [main:QuorumPeerMain@138] - Either no config or no quorum defined in config, running in standalone mode
2020-11-13 14:13:15,399 [myid:] - INFO  [main:ManagedUtil@44] - Log4j 1.2 jmx support found and enabled.
2020-11-13 14:13:15,461 [myid:] - INFO  [main:QuorumPeerConfig@174] - Reading configuration from: D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\conf\zoo.cfg
2020-11-13 14:13:15,461 [myid:] - INFO  [main:QuorumPeerConfig@460] - clientPortAddress is 0.0.0.0:2181
2020-11-13 14:13:15,461 [myid:] - INFO  [main:QuorumPeerConfig@464] - secureClientPort is not set
2020-11-13 14:13:15,461 [myid:] - INFO  [main:QuorumPeerConfig@480] - observerMasterPort is not set
2020-11-13 14:13:15,461 [myid:] - INFO  [main:QuorumPeerConfig@497] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2020-11-13 14:13:15,461 [myid:] - INFO  [main:ZooKeeperServerMain@122] - Starting server
2020-11-13 14:13:15,508 [myid:] - INFO  [main:ServerMetrics@62] - ServerMetrics initialized with provider org.apache.zookeeper.metrics.impl.DefaultMetricsProvider@61443d8f
2020-11-13 14:13:15,524 [myid:] - INFO  [main:FileTxnSnapLog@124] - zookeeper.snapshot.trust.empty : false
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -   ______                  _                         
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -  |___  /                 | |                        
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -     / /    ___     ___   | | __   ___    ___   _ __     ___   _ __
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -    / /    / _ \   / _ \  | |/ /  / _ \  / _ \ | '_ \   / _ \ | '__|
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -   / /__  | (_) | | (_) | |   <  |  __/ |  __/ | |_) | |  __/ | |
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -  /_____|  \___/   \___/  |_|\_\  \___|  \___| | .__/   \___| |_|
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -                                               | |   
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -                                               |_|   
2020-11-13 14:13:15,524 [myid:] - INFO  [main:ZookeeperBanner@42] -
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:zookeeper.version=3.6.2--803c7f1a12f85978cb049af5e4ef23bd8b688715, built on 09/04/2020 12:44 GMT
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:host.name=ecs-a0e1-0001
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.version=1.8.0_144
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.vendor=Oracle Corporation
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.home=C:\Java\jre1.8.0_144
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.class.path=D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\build\classes;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\build\lib\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\audience-annotations-0.5.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\commons-cli-1.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\commons-lang-2.6.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jackson-annotations-2.10.3.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jackson-core-2.10.3.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jackson-databind-2.10.3.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\javax.servlet-api-3.1.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-http-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-io-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-security-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-server-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-servlet-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-util-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jline-2.14.6.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\json-simple-1.1.1.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\log4j-1.2.17.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\metrics-core-3.2.5.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-buffer-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-codec-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-common-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-handler-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-resolver-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-transport-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-transport-native-epoll-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-transport-native-unix-common-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient_common-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient_hotspot-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient_servlet-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\slf4j-api-1.7.25.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\slf4j-log4j12-1.7.25.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\snappy-java-1.1.7.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\zookeeper-3.6.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\zookeeper-jute-3.6.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\zookeeper-prometheus-metrics-3.6.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\conf
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.library.path=C:\Java\jre1.8.0_144\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Python39\Scripts\;C:\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs;D:\nodejs\node_global;C:\Program Files\Git\cmd;C:\Java\jre1.8.0_144\bin;C:\Redis\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm;D:\nodejs\node_global;C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin;C:\Java\jre1.8.0_144\bin;.
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\2\
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:java.compiler=<NA>
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:os.name=Windows Server 2016
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:os.arch=amd64
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:os.version=10.0
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:user.name=Administrator
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:user.home=C:\Users\Administrator
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:user.dir=D:\zookeeper\apache-zookeeper-3.6.2-bin\bin
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:os.memory.free=231MB
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:os.memory.max=3641MB
2020-11-13 14:13:15,539 [myid:] - INFO  [main:Environment@98] - Server environment:os.memory.total=245MB
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@129] - zookeeper.enableEagerACLCheck = false
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@137] - zookeeper.digest.enabled = true
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@141] - zookeeper.closeSessionTxn.enabled = true
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@1444] - zookeeper.flushDelay=0
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@1453] - zookeeper.maxWriteQueuePollTime=0
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@1462] - zookeeper.maxBatchSize=1000
2020-11-13 14:13:15,539 [myid:] - INFO  [main:ZooKeeperServer@243] - zookeeper.intBufferStartingSizeBytes = 1024
2020-11-13 14:13:15,555 [myid:] - INFO  [main:BlueThrottle@141] - Weighed connection throttling is disabled
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ZooKeeperServer@1256] - minSessionTimeout set to 4000
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ZooKeeperServer@1265] - maxSessionTimeout set to 40000
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ResponseCache@45] - Response cache size is initialized with value 400.
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ResponseCache@45] - Response cache size is initialized with value 400.
2020-11-13 14:13:15,555 [myid:] - INFO  [main:RequestPathMetricsCollector@111] - zookeeper.pathStats.slotCapacity = 60
2020-11-13 14:13:15,555 [myid:] - INFO  [main:RequestPathMetricsCollector@112] - zookeeper.pathStats.slotDuration = 15
2020-11-13 14:13:15,555 [myid:] - INFO  [main:RequestPathMetricsCollector@113] - zookeeper.pathStats.maxDepth = 6
2020-11-13 14:13:15,555 [myid:] - INFO  [main:RequestPathMetricsCollector@114] - zookeeper.pathStats.initialDelay = 5
2020-11-13 14:13:15,555 [myid:] - INFO  [main:RequestPathMetricsCollector@115] - zookeeper.pathStats.delay = 5
2020-11-13 14:13:15,555 [myid:] - INFO  [main:RequestPathMetricsCollector@116] - zookeeper.pathStats.enabled = false
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ZooKeeperServer@1481] - The max bytes for all large requests are set to 104857600
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ZooKeeperServer@1495] - The large request threshold is set to -1
2020-11-13 14:13:15,555 [myid:] - INFO  [main:ZooKeeperServer@339] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 clientPortListenBacklog -1 datadir D:\zookeeper\data\version-2 snapdir D:\zookeeper\data\version-2
2020-11-13 14:13:15,571 [myid:] - INFO  [main:Log@169] - Logging initialized @365ms to org.eclipse.jetty.util.log.Slf4jLog
2020-11-13 14:13:15,633 [myid:] - WARN  [main:ContextHandler@1520] - o.e.j.s.ServletContextHandler@32709393{/,null,UNAVAILABLE} contextPath ends with /*
2020-11-13 14:13:15,633 [myid:] - WARN  [main:ContextHandler@1531] - Empty contextPath
2020-11-13 14:13:15,649 [myid:] - INFO  [main:Server@359] - jetty-9.4.24.v20191120; built: 2019-11-20T21:37:49.771Z; git: 363d5f2df3a8a28de40604320230664b9c793c16; jvm 1.8.0_144-b01
2020-11-13 14:13:15,680 [myid:] - INFO  [main:DefaultSessionIdManager@333] - DefaultSessionIdManager workerName=node0
2020-11-13 14:13:15,680 [myid:] - INFO  [main:DefaultSessionIdManager@338] - No SessionScavenger set, using defaults
2020-11-13 14:13:15,680 [myid:] - INFO  [main:HouseKeeper@140] - node0 Scavenging every 660000ms
2020-11-13 14:13:15,680 [myid:] - WARN  [main:ConstraintSecurityHandler@757] - ServletContext@o.e.j.s.ServletContextHandler@32709393{/,null,STARTING} has uncovered http methods for path: /*
2020-11-13 14:13:15,696 [myid:] - INFO  [main:ContextHandler@825] - Started o.e.j.s.ServletContextHandler@32709393{/,null,AVAILABLE}
2020-11-13 14:13:15,727 [myid:] - INFO  [main:AbstractConnector@330] - Started ServerConnector@2f686d1f{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2020-11-13 14:13:15,727 [myid:] - INFO  [main:Server@399] - Started @514ms
2020-11-13 14:13:15,727 [myid:] - INFO  [main:JettyAdminServer@182] - Started AdminServer on address 0.0.0.0, port 8080 and command URL /commands
2020-11-13 14:13:15,727 [myid:] - INFO  [main:ServerCnxnFactory@169] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2020-11-13 14:13:15,727 [myid:] - WARN  [main:ServerCnxnFactory@309] - maxCnxns is not configured, using default value 0.
2020-11-13 14:13:15,727 [myid:] - INFO  [main:NIOServerCnxnFactory@666] - Configuring NIO connection handler with 10s sessionless connection timeout, 2 selector thread(s), 16 worker threads, and 64 kB direct buffers.
2020-11-13 14:13:15,727 [myid:] - INFO  [main:NIOServerCnxnFactory@674] - binding to port 0.0.0.0/0.0.0.0:2181
2020-11-13 14:13:15,755 [myid:] - INFO  [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watch manager
2020-11-13 14:13:15,755 [myid:] - INFO  [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watch manager
2020-11-13 14:13:15,756 [myid:] - INFO  [main:ZKDatabase@132] - zookeeper.snapshotSizeFactor = 0.33
2020-11-13 14:13:15,757 [myid:] - INFO  [main:ZKDatabase@152] - zookeeper.commitLogCount=500
2020-11-13 14:13:15,761 [myid:] - INFO  [main:SnapStream@61] - zookeeper.snapshot.compression.method = CHECKED
2020-11-13 14:13:15,767 [myid:] - INFO  [main:FileSnap@85] - Reading snapshot D:\zookeeper\data\version-2\snapshot.0
2020-11-13 14:13:15,769 [myid:] - INFO  [main:DataTree@1737] - The digest value is empty in snapshot
2020-11-13 14:13:15,780 [myid:] - INFO  [main:FileTxnSnapLog@363] - 8 txns loaded in 3 ms
2020-11-13 14:13:15,780 [myid:] - INFO  [main:ZKDatabase@289] - Snapshot loaded in 22 ms, highest zxid is 0x8, digest is 1371985504
2020-11-13 14:13:15,781 [myid:] - INFO  [main:FileTxnSnapLog@470] - Snapshotting: 0x8 to D:\zookeeper\data\version-2\snapshot.8
2020-11-13 14:13:15,782 [myid:] - INFO  [main:ZooKeeperServer@529] - Snapshot taken in 2 ms
2020-11-13 14:13:15,790 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@136] - PrepRequestProcessor (sid:0) started, reconfigEnabled=false
2020-11-13 14:13:15,790 [myid:] - INFO  [main:RequestThrottler@74] - zookeeper.request_throttler.shutdownTimeout = 10000
2020-11-13 14:13:15,802 [myid:] - INFO  [main:ContainerManager@83] - Using checkIntervalMs=60000 maxPerMinute=10000 maxNeverUsedIntervalMs=0
2020-11-13 14:13:15,802 [myid:] - INFO  [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.

伪集群模式部署

伪集群模式就是在同一主机启动多个zookeeper并组成集群

1、在同一个主机上,通过复制得到三个zookeeper实例

  • zookeeper-3.6.2-12181
  • zookeeper-3.6.2-12182
  • zookeeper-3.6.2-12183

2、对三个zookeeper节点进行配置
zookeeper1配置文件/conf/zoo.cfg修改如下:

tickTime=2000
initLimit=5
syncLimit=2
dataDir=D:\\zookeeper\\data\\zookeeper-cluster\\zookeeper-3.6.2-12181\\data
clientPort=12181

server.1=127.0.0.1:12888:13888
server.2=127.0.0.1:14888:15888
server.3=127.0.0.1:16888:17888

注:server.1中的数字1为服务器的ID,需要与data/myid文件中的id一致

zookeeper2配置文件/conf/zoo.cfg修改如下:

tickTime=2000
initLimit=5
syncLimit=2
dataDir=D:\\zookeeper\\data\\zookeeper-cluster\\zookeeper-3.6.2-12182\\data
clientPort=12182

server.1=127.0.0.1:12888:13888
server.2=127.0.0.1:14888:15888
server.3=127.0.0.1:16888:17888

zookeeper3配置文件/conf/zoo.cfg修改如下:

tickTime=2000
initLimit=5
syncLimit=2
dataDir=D:\\zookeeper\\data\\zookeeper-cluster\\zookeeper-3.6.2-12183\\data
clientPort=12183

server.1=127.0.0.1:12888:13888
server.2=127.0.0.1:14888:15888
server.3=127.0.0.1:16888:17888

3、分别启动三个zookeeper节点

集群模式部署

集群模式就是在不同主机上安装zookeeper然后组成集群的模式,可以参考伪集群模式安装

1、在三台机器上分别部署1个ZooKeeper实例
2、zookeeper配置文件conf/zoo.cfg,如下:

tickTime=2000
initLimit=5
syncLimit=2
dataDir=D:\\zookeeper\\data
clientPort=2181

server.1=127.0.0.1:2888:3888
server.2=127.0.0.2:2888:3888
server.3=127.0.0.3:2888:3888

3、zookeeper的data/myid配置,使用如下命令:
当然zookeeper1 对应的是 1,zookeeper2 对应的是 2,zookeeper3 对应的是 3
4、分别启动三个zookeeper节点,即完成对ZooKeeper集群的安装

Zookeeper简单操作

1、使用客户端连接Zookeeper服务。
在bin目录下执行

zkCli.cmd -server 127.0.0.1:2181

就可以了,如下:

D:\zookeeper\apache-zookeeper-3.6.2-bin\bin>zkCli.cmd -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2020-11-13 14:15:07,950 [myid:] - INFO  [main:Environment@98] - Client environment:zookeeper.version=3.6.2--803c7f1a12f85978cb049af5e4ef23bd8b688715, built on 09/04/2020 12:44 GMT
2020-11-13 14:15:07,952 [myid:] - INFO  [main:Environment@98] - Client environment:host.name=ecs-a0e1-0001
2020-11-13 14:15:07,952 [myid:] - INFO  [main:Environment@98] - Client environment:java.version=1.8.0_144
2020-11-13 14:15:07,954 [myid:] - INFO  [main:Environment@98] - Client environment:java.vendor=Oracle Corporation
2020-11-13 14:15:07,954 [myid:] - INFO  [main:Environment@98] - Client environment:java.home=C:\Java\jre1.8.0_144
2020-11-13 14:15:07,954 [myid:] - INFO  [main:Environment@98] - Client environment:java.class.path=D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\build\classes;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\build\lib\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\*;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\audience-annotations-0.5.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\commons-cli-1.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\commons-lang-2.6.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jackson-annotations-2.10.3.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jackson-core-2.10.3.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jackson-databind-2.10.3.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\javax.servlet-api-3.1.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-http-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-io-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-security-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-server-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-servlet-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jetty-util-9.4.24.v20191120.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\jline-2.14.6.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\json-simple-1.1.1.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\log4j-1.2.17.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\metrics-core-3.2.5.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-buffer-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-codec-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-common-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-handler-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-resolver-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-transport-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-transport-native-epoll-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\netty-transport-native-unix-common-4.1.50.Final.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient_common-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient_hotspot-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\simpleclient_servlet-0.6.0.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\slf4j-api-1.7.25.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\slf4j-log4j12-1.7.25.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\snappy-java-1.1.7.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\zookeeper-3.6.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\zookeeper-jute-3.6.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\lib\zookeeper-prometheus-metrics-3.6.2.jar;D:\zookeeper\apache-zookeeper-3.6.2-bin\bin\..\conf
2020-11-13 14:15:07,954 [myid:] - INFO  [main:Environment@98] - Client environment:java.library.path=C:\Java\jre1.8.0_144\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Python39\Scripts\;C:\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs;D:\nodejs\node_global;C:\Program Files\Git\cmd;C:\Java\jre1.8.0_144\bin;C:\Redis\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm;D:\nodejs\node_global;C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin;C:\Java\jre1.8.0_144\bin;.
2020-11-13 14:15:07,955 [myid:] - INFO  [main:Environment@98] - Client environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\2\
2020-11-13 14:15:07,956 [myid:] - INFO  [main:Environment@98] - Client environment:java.compiler=<NA>
2020-11-13 14:15:07,956 [myid:] - INFO  [main:Environment@98] - Client environment:os.name=Windows Server 2016
2020-11-13 14:15:07,957 [myid:] - INFO  [main:Environment@98] - Client environment:os.arch=amd64
2020-11-13 14:15:07,957 [myid:] - INFO  [main:Environment@98] - Client environment:os.version=10.0
2020-11-13 14:15:07,958 [myid:] - INFO  [main:Environment@98] - Client environment:user.name=Administrator
2020-11-13 14:15:07,958 [myid:] - INFO  [main:Environment@98] - Client environment:user.home=C:\Users\Administrator
2020-11-13 14:15:07,959 [myid:] - INFO  [main:Environment@98] - Client environment:user.dir=D:\zookeeper\apache-zookeeper-3.6.2-bin\bin
2020-11-13 14:15:07,959 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.free=236MB
2020-11-13 14:15:07,960 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.max=3641MB
2020-11-13 14:15:07,961 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.total=245MB
2020-11-13 14:15:07,966 [myid:] - INFO  [main:ZooKeeper@1006] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@41a4555e
2020-11-13 14:15:07,970 [myid:] - INFO  [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2020-11-13 14:15:08,050 [myid:] - INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2020-11-13 14:15:08,056 [myid:] - INFO  [main:ClientCnxn@1716] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2020-11-13 14:15:08,061 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1167] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181.
2020-11-13 14:15:08,061 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1169] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2020-11-13 14:15:08,063 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@999] - Socket connection established, initiating session, client: /127.0.0.1:56145, server: 127.0.0.1/127.0.0.1:2181
JLine support is enabled
2020-11-13 14:15:08,077 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1433] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, session id = 0x10095960df40000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0]

2、在客户端使用ls命令来查看当前Zookeeper中所包含的内容:

  • 命令:ls /
[zk: 127.0.0.1:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 1]

3、创建一个新的znode节点“zk"以及与它关联的字符串

  • 命令:create zk/ myData
[zk: 127.0.0.1:2181(CONNECTED) 1] create /zk myData
Created /zk
[zk: 127.0.0.1:2181(CONNECTED) 2] ls /
[zk, zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 3]

4、获取znode节点"zk"

  • 命令:get /zk
[zk: 127.0.0.1:2181(CONNECTED) 3] get /zk
myData
[zk: 127.0.0.1:2181(CONNECTED) 4]

5、删除znode节点"zk"

  • 命令:delete /zk
[zk: 127.0.0.1:2181(CONNECTED) 4] delete /zk
[zk: 127.0.0.1:2181(CONNECTED) 5]

6、退出客户端

  • 命令:quit
[zk: 127.0.0.1:2181(CONNECTED) 5] quit

WATCHER::

WatchedEvent state:Closed type:None path:null
2020-11-13 14:27:42,998 [myid:] - INFO  [main:ZooKeeper@1619] - Session: 0x10095960df40000 closed
2020-11-13 14:27:42,998 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@577] - EventThread shut down for session: 0x10095960df40000
2020-11-13 14:27:43,000 [myid:] - ERROR [main:ServiceUtils@42] - Exiting JVM with code 0
D:\zookeeper\apache-zookeeper-3.6.2-bin\bin>

作者:CodingPioneer
来源链接:https://blog.csdn.net/zlbdmm/article/details/109669049

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。


本文链接:https://www.javaclub.cn/server/41660.html

标签: ZooKeeper
分享给朋友:

“Zookeeper下载与安装教程(for windows)” 的相关文章

小白入门指南|zookeeper快速入门

zookeeper入门 概述 开源的、分布式的,为分布式应用提供的apache项目 工作机制 zookeeper从设计模式的角度来理解:是一个基于观察者模式设计的分布式服务管理框架,他负责管理存储和管理...

Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例

Springboot 整合 Dubbo/ZooKeeper 详解 SOA 案例

摘要: 原创出处:www.bysocket.com 泥瓦匠BYSocket 希望转载,保留摘要,谢谢!...

安装zookeeper及kafka集群

安装zookeeper及kafka集群

安装zookeeper及kafka集群 搭建zookeeper 不废话直接开始,请提前准备好镜像或者拉取新版本镜像 # 拉取镜像 docker pull wurstmeister/zookeeper docker pull wurstm...

kafka和zookeeper的最详细安装步骤和介绍

kafka和zookeeper的最详细安装步骤和介绍

kafka和zookeeper的详细安装步骤和介绍 1、异步通信 1.1. 观察者模式 观察者模式,又叫发布-订阅模式 定义对象间一种一对多的依赖关系,使得每当一个对象改变状态,则所有依赖于它的对象都会得到通知并自动更新。 一个对象(目标对象)的状态...

SpringMVC、Zookeeper、Dubbo使用

SpringMVC、Zookeeper、Dubbo使用

互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,Dubbo是一个分布式服务框架,在这种情况下诞生的。现在核心业务抽取出来,作为独立的服务,使前端应用能更快速和稳定的响应。 第一:介绍Dubbo背景 ...

Windows上安装zookeeper+kafka

Windows上安装zookeeper+kafka

准备zookeeper和kafka安装包 zookeeper安装包下载地址:https://archive.apache.org/dist/zookeeper/ (本文选择apache-zookeeper-3.5.8-bin.tar.gz) k...

kafka连接zookeeper配置搭建环境、安装和启动,Windows环境下

kafka连接zookeeper配置搭建环境、安装和启动,Windows环境下

kafka,分布式集群架构下,高性能的流式事件数据(主要是消息)集成、发布(生产)和订阅(分发、消费)组件(中间件)。 kafka依赖zooeeper(数据后端),这里有Windows下安装配置启动zookeeper的 文章(1): Windows 10环境zooke...

消息中间件kafka安装启动自带配置好的Zookeeper

消息中间件kafka安装启动自带配置好的Zookeeper

前言 这里简单做一个入门小白的消息中间件的介绍,以后会更新。Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作流数据。 这种动作(网页浏览,搜索和其他用户的行动)是在现代网络上的许多社会功能的一个关键因素。 这...

Docker安装Zookeeper和Kafka、Docker Compose 编排、Docker Portainer 容器

1、Docker 安装 ①安装必要的一些系统工具 输入Linux指令:sudo yum install -y yum-utils ②添加软件源信息 输入Linux指令:sudo yum-config-manager --add-repo http://mi...

五分钟搞定:Centos中Kafka和Zookeeper的快速安装教程

[提前声明] 文章由作者:张耀峰 结合自己生产中的使用经验整理,最终形成简单易懂的文章 写作不易,转载请注明,谢谢! 代码案例地址: ?https://github.com/Mydreamandreality/sparkResearch K...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。