ZooKeeper 在 Windows 操作系統(tǒng)中的安裝筏养、配置與運(yùn)行

本文介紹在 Windows 操作系統(tǒng)上安裝 ZooKeeper 的方法與過(guò)程。


目錄

  • 版本說(shuō)明
  • 安裝
  • 配置
  • 運(yùn)行
  • 測(cè)試
    • 連接 ZooKeeper 服務(wù)
    • 查看幫助
    • 創(chuàng)建 znode
    • 查看所有 znode
    • 查看指定 znode 的值

版本說(shuō)明

  • Windows 10
  • ZooKeeper 3.6.0
  • JDK 8

安裝

  1. 因?yàn)?ZooKeeper 依賴 Java 環(huán)境運(yùn)行孟辑,所以首先需要下載山叮、安裝和配置 JDK(本示例使用 JDK 8)。

  2. 下載 ZooKeeper stable 版本博脑,本示例使用 3.6.0 版本憎乙,下載文件是 apache-zookeeper-3.6.0-bin.tar.gz票罐。
    注意:不要下載 Source Release 版本,否則啟動(dòng)會(huì)報(bào)錯(cuò)泞边。Source Release 版本大小只有 3MB 左右该押,且文件名中沒(méi)有 bin

  3. 將下載文件拷貝到安裝目錄下解壓縮阵谚。


配置

進(jìn)入解壓縮后根目錄的 conf 文件夾蚕礼,復(fù)制 zoo_sample.cfg 文件并粘貼在同一目錄下,將文件名稱修改為 zoo.cfg梢什,修改如下:

# 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:/Dev/ZooKeeper/data
dataLogDir=D:/Dev/ZooKeeper/log
# 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

說(shuō)明:

  • tickTime:ZooKeeper 使用的基本時(shí)間單位(毫秒)奠蹬,用于調(diào)節(jié)心跳和超時(shí),最小會(huì)話超時(shí)是兩倍 tickTime绳矩。
  • dataDir:ZooKeeper 存儲(chǔ)內(nèi)存數(shù)據(jù)庫(kù)快照罩润,除非另有說(shuō)明,否則為數(shù)據(jù)庫(kù)更新的事務(wù)日志翼馆。
  • dataLogDir:指定事務(wù)日志存儲(chǔ)路徑割以,如不設(shè)置則使用 dataDir 存儲(chǔ)事務(wù)日志。這個(gè)配置項(xiàng)有助于避免日志記錄和內(nèi)存數(shù)據(jù)庫(kù)快照之間的競(jìng)爭(zhēng)应媚。
  • clientPort:監(jiān)聽客戶端連接的端口號(hào)严沥,默認(rèn)為 2181

運(yùn)行

運(yùn)行 cmd 打開一個(gè)新的命令提示符窗口中姜,進(jìn)入 ZooKeeper 安裝根目錄下 bin 子目錄消玄,執(zhí)行以下命令啟動(dòng):

D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin>zkServer.cmd

D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin>call "D:\Dev\Java\jdk1.8.0_222"\bin\java "-Dzookeeper.log.dir=D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\logs" "-Dzookeeper.root.logger=INFO,CONSOLE" "-Dzookeeper.log.file=.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%p /t /f" -cp "D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\build\classes;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\build\lib\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\conf\zoo.cfg"
2020-04-24 17:32:31,752 [myid:] - INFO  [main:QuorumPeerConfig@173] - Reading configuration from: D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\conf\zoo.cfg
2020-04-24 17:32:31,799 [myid:] - INFO  [main:QuorumPeerConfig@459] - clientPortAddress is 0.0.0.0:2181
2020-04-24 17:32:31,799 [myid:] - INFO  [main:QuorumPeerConfig@463] - secureClientPort is not set
2020-04-24 17:32:31,799 [myid:] - INFO  [main:QuorumPeerConfig@479] - observerMasterPort is not set
2020-04-24 17:32:31,799 [myid:] - INFO  [main:QuorumPeerConfig@496] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2020-04-24 17:32:31,799 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2020-04-24 17:32:31,799 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2020-04-24 17:32:31,814 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2020-04-24 17:32:31,814 [myid:] - WARN  [main:QuorumPeerMain@138] - Either no config or no quorum defined in config, running in standalone mode
2020-04-24 17:32:31,814 [myid:] - INFO  [main:ManagedUtil@45] - Log4j found with jmx enabled.
2020-04-24 17:32:31,908 [myid:] - INFO  [main:QuorumPeerConfig@173] - Reading configuration from: D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\conf\zoo.cfg
2020-04-24 17:32:31,924 [myid:] - INFO  [main:QuorumPeerConfig@459] - clientPortAddress is 0.0.0.0:2181
2020-04-24 17:32:31,924 [myid:] - INFO  [main:QuorumPeerConfig@463] - secureClientPort is not set
2020-04-24 17:32:31,924 [myid:] - INFO  [main:QuorumPeerConfig@479] - observerMasterPort is not set
2020-04-24 17:32:31,924 [myid:] - INFO  [main:QuorumPeerConfig@496] - metricsProvider.className is org.apache.zookeeper.metrics.impl.DefaultMetricsProvider
2020-04-24 17:32:31,924 [myid:] - INFO  [main:ZooKeeperServerMain@122] - Starting server
2020-04-24 17:32:32,032 [myid:] - INFO  [main:ServerMetrics@62] - ServerMetrics initialized with provider org.apache.zookeeper.metrics.impl.DefaultMetricsProvider@63d4e2ba
2020-04-24 17:32:32,038 [myid:] - INFO  [main:FileTxnSnapLog@124] - zookeeper.snapshot.trust.empty : false
2020-04-24 17:32:32,059 [myid:] - INFO  [main:ZookeeperBanner@42] -
2020-04-24 17:32:32,060 [myid:] - INFO  [main:ZookeeperBanner@42] -   ______                  _
2020-04-24 17:32:32,063 [myid:] - INFO  [main:ZookeeperBanner@42] -  |___  /                 | |
2020-04-24 17:32:32,069 [myid:] - INFO  [main:ZookeeperBanner@42] -     / /    ___     ___   | | __   ___    ___   _ __     ___   _ __
2020-04-24 17:32:32,070 [myid:] - INFO  [main:ZookeeperBanner@42] -    / /    / _ \   / _ \  | |/ /  / _ \  / _ \ | '_ \   / _ \ | '__|
2020-04-24 17:32:32,072 [myid:] - INFO  [main:ZookeeperBanner@42] -   / /__  | (_) | | (_) | |   <  |  __/ |  __/ | |_) | |  __/ | |
2020-04-24 17:32:32,073 [myid:] - INFO  [main:ZookeeperBanner@42] -  /_____|  \___/   \___/  |_|\_\  \___|  \___| | .__/   \___| |_|
2020-04-24 17:32:32,074 [myid:] - INFO  [main:ZookeeperBanner@42] -                                               | |
2020-04-24 17:32:32,075 [myid:] - INFO  [main:ZookeeperBanner@42] -                                               |_|
2020-04-24 17:32:32,076 [myid:] - INFO  [main:ZookeeperBanner@42] -
2020-04-24 17:32:32,102 [myid:] - INFO  [main:Environment@98] - Server environment:zookeeper.version=3.6.0--b4c89dc7f6083829e18fae6e446907ae0b1f22d7, built on 02/25/2020 14:38 GMT
2020-04-24 17:32:32,103 [myid:] - INFO  [main:Environment@98] - Server environment:host.name=
2020-04-24 17:32:32,106 [myid:] - INFO  [main:Environment@98] - Server environment:java.version=1.8.0_222
2020-04-24 17:32:32,107 [myid:] - INFO  [main:Environment@98] - Server environment:java.vendor=
2020-04-24 17:32:32,109 [myid:] - INFO  [main:Environment@98] - Server environment:java.home=D:\Dev\Java\jdk1.8.0_222\jre
2020-04-24 17:32:32,110 [myid:] - INFO  [main:Environment@98] - Server environment:java.class.path=D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\build\classes;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\build\lib\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\audience-annotations-0.5.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\commons-cli-1.2.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\commons-lang-2.6.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jackson-annotations-2.9.10.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jackson-core-2.9.10.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jackson-databind-2.9.10.3.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\javax.servlet-api-3.1.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-http-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-io-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-security-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-server-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-servlet-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-util-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jline-2.11.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\json-simple-1.1.1.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\log4j-1.2.17.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\metrics-core-3.2.5.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-buffer-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-codec-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-common-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-handler-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-resolver-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-transport-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-transport-native-epoll-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-transport-native-unix-common-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient_common-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient_hotspot-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient_servlet-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\slf4j-api-1.7.25.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\slf4j-log4j12-1.7.25.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\snappy-java-1.1.7.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\zookeeper-3.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\zookeeper-jute-3.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\zookeeper-prometheus-metrics-3.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\conf
2020-04-24 17:32:32,114 [myid:] - INFO  [main:Environment@98] - Server environment:java.library.path=D:\Dev\Java\jdk1.8.0_222\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Dev\Java\jdk1.8.0_222\bin;D:\Dev\Maven\apache-maven-3.6.3\bin;D:\Dev\MySQL\mysql-8.0.19-winx64\bin;D:\Dev\TortoiseSVN\bin;C:\TestTools\TMSS;D:\Dev\Git\cmd;D:\Dev\Go\bin;C:\WINDOWS\System32\OpenSSH\;D:\Dev\GoPath\bin;D:\Dev\Flutter\flutter\bin;D:\Dev\Git\bin;D:\Dev\nodejs\;C:\Python37\Scripts\;C:\Python37\;C:\Users\...\go\bin;C:\Users\...\AppData\Local\Microsoft\WindowsApps;D:\Dev\nodejs\node_global;.
2020-04-24 17:32:32,118 [myid:] - INFO  [main:Environment@98] - Server environment:java.io.tmpdir=C:\Users\...\AppData\Local\Temp\
2020-04-24 17:32:32,121 [myid:] - INFO  [main:Environment@98] - Server environment:java.compiler=<NA>
2020-04-24 17:32:32,121 [myid:] - INFO  [main:Environment@98] - Server environment:os.name=Windows 10
2020-04-24 17:32:32,122 [myid:] - INFO  [main:Environment@98] - Server environment:os.arch=amd64
2020-04-24 17:32:32,123 [myid:] - INFO  [main:Environment@98] - Server environment:os.version=10.0
2020-04-24 17:32:32,123 [myid:] - INFO  [main:Environment@98] - Server environment:user.name=
2020-04-24 17:32:32,124 [myid:] - INFO  [main:Environment@98] - Server environment:user.home=C:\Users\...
2020-04-24 17:32:32,125 [myid:] - INFO  [main:Environment@98] - Server environment:user.dir=D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin
2020-04-24 17:32:32,125 [myid:] - INFO  [main:Environment@98] - Server environment:os.memory.free=231MB
2020-04-24 17:32:32,126 [myid:] - INFO  [main:Environment@98] - Server environment:os.memory.max=3639MB
2020-04-24 17:32:32,127 [myid:] - INFO  [main:Environment@98] - Server environment:os.memory.total=245MB
2020-04-24 17:32:32,128 [myid:] - INFO  [main:ZooKeeperServer@128] - zookeeper.enableEagerACLCheck = false
2020-04-24 17:32:32,128 [myid:] - INFO  [main:ZooKeeperServer@136] - zookeeper.digest.enabled = true
2020-04-24 17:32:32,129 [myid:] - INFO  [main:ZooKeeperServer@140] - zookeeper.closeSessionTxn.enabled = true
2020-04-24 17:32:32,132 [myid:] - INFO  [main:ZooKeeperServer@1433] - zookeeper.flushDelay=0
2020-04-24 17:32:32,140 [myid:] - INFO  [main:ZooKeeperServer@1442] - zookeeper.maxWriteQueuePollTime=0
2020-04-24 17:32:32,141 [myid:] - INFO  [main:ZooKeeperServer@1451] - zookeeper.maxBatchSize=1000
2020-04-24 17:32:32,142 [myid:] - INFO  [main:ZooKeeperServer@241] - zookeeper.intBufferStartingSizeBytes = 1024
2020-04-24 17:32:32,151 [myid:] - INFO  [main:BlueThrottle@141] - Weighed connection throttling is disabled
2020-04-24 17:32:32,154 [myid:] - INFO  [main:ZooKeeperServer@1246] - minSessionTimeout set to 4000
2020-04-24 17:32:32,154 [myid:] - INFO  [main:ZooKeeperServer@1255] - maxSessionTimeout set to 40000
2020-04-24 17:32:32,157 [myid:] - INFO  [main:ResponseCache@45] - Response cache size is initialized with value 400.
2020-04-24 17:32:32,157 [myid:] - INFO  [main:ResponseCache@45] - Response cache size is initialized with value 400.
2020-04-24 17:32:32,167 [myid:] - INFO  [main:RequestPathMetricsCollector@111] - zookeeper.pathStats.slotCapacity = 60
2020-04-24 17:32:32,167 [myid:] - INFO  [main:RequestPathMetricsCollector@112] - zookeeper.pathStats.slotDuration = 15
2020-04-24 17:32:32,168 [myid:] - INFO  [main:RequestPathMetricsCollector@113] - zookeeper.pathStats.maxDepth = 6
2020-04-24 17:32:32,169 [myid:] - INFO  [main:RequestPathMetricsCollector@114] - zookeeper.pathStats.initialDelay = 5
2020-04-24 17:32:32,170 [myid:] - INFO  [main:RequestPathMetricsCollector@115] - zookeeper.pathStats.delay = 5
2020-04-24 17:32:32,170 [myid:] - INFO  [main:RequestPathMetricsCollector@116] - zookeeper.pathStats.enabled = false
2020-04-24 17:32:32,184 [myid:] - INFO  [main:ZooKeeperServer@1470] - The max bytes for all large requests are set to 104857600
2020-04-24 17:32:32,185 [myid:] - INFO  [main:ZooKeeperServer@1484] - The large request threshold is set to -1
2020-04-24 17:32:32,186 [myid:] - INFO  [main:ZooKeeperServer@329] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 clientPortListenBacklog -1 datadir D:\Dev\ZooKeeper\log\version-2 snapdir D:\Dev\ZooKeeper\data\version-2
2020-04-24 17:32:32,221 [myid:] - INFO  [main:Log@169] - Logging initialized @852ms to org.eclipse.jetty.util.log.Slf4jLog
2020-04-24 17:32:32,405 [myid:] - WARN  [main:ContextHandler@1520] - o.e.j.s.ServletContextHandler@578486a3{/,null,UNAVAILABLE} contextPath ends with /*
2020-04-24 17:32:32,405 [myid:] - WARN  [main:ContextHandler@1531] - Empty contextPath
2020-04-24 17:32:32,431 [myid:] - INFO  [main:Server@359] - jetty-9.4.24.v20191120; built: 2019-11-20T21:37:49.771Z; git: 363d5f2df3a8a28de40604320230664b9c793c16; jvm 1.8.0_222-_JDK_V100R001C00SPC130B005-b10
2020-04-24 17:32:32,514 [myid:] - INFO  [main:DefaultSessionIdManager@333] - DefaultSessionIdManager workerName=node0
2020-04-24 17:32:32,515 [myid:] - INFO  [main:DefaultSessionIdManager@338] - No SessionScavenger set, using defaults
2020-04-24 17:32:32,524 [myid:] - INFO  [main:HouseKeeper@140] - node0 Scavenging every 600000ms
2020-04-24 17:32:32,548 [myid:] - INFO  [main:ContextHandler@825] - Started o.e.j.s.ServletContextHandler@578486a3{/,null,AVAILABLE}
2020-04-24 17:32:32,723 [myid:] - INFO  [main:AbstractConnector@330] - Started ServerConnector@239963d8{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2020-04-24 17:32:32,723 [myid:] - INFO  [main:Server@399] - Started @1361ms
2020-04-24 17:32:32,723 [myid:] - INFO  [main:JettyAdminServer@178] - Started AdminServer on address 0.0.0.0, port 8080 and command URL /commands
2020-04-24 17:32:32,739 [myid:] - INFO  [main:ServerCnxnFactory@169] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2020-04-24 17:32:32,739 [myid:] - WARN  [main:ServerCnxnFactory@309] - maxCnxns is not configured, using default value 0.
2020-04-24 17:32:32,739 [myid:] - INFO  [main:NIOServerCnxnFactory@666] - Configuring NIO connection handler with 10s sessionless connection timeout, 1 selector thread(s), 8 worker threads, and 64 kB direct buffers.
2020-04-24 17:32:32,739 [myid:] - INFO  [main:NIOServerCnxnFactory@674] - binding to port 0.0.0.0/0.0.0.0:2181
2020-04-24 17:32:32,779 [myid:] - INFO  [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watch manager
2020-04-24 17:32:32,782 [myid:] - INFO  [main:WatchManagerFactory@42] - Using org.apache.zookeeper.server.watch.WatchManager as watch manager
2020-04-24 17:32:32,784 [myid:] - INFO  [main:ZKDatabase@132] - zookeeper.snapshotSizeFactor = 0.33
2020-04-24 17:32:32,784 [myid:] - INFO  [main:ZKDatabase@152] - zookeeper.commitLogCount=500
2020-04-24 17:32:32,801 [myid:] - INFO  [main:SnapStream@61] - zookeeper.snapshot.compression.method = CHECKED
2020-04-24 17:32:32,801 [myid:] - INFO  [main:FileTxnSnapLog@470] - Snapshotting: 0x0 to D:\Dev\ZooKeeper\data\version-2\snapshot.0
2020-04-24 17:32:32,811 [myid:] - INFO  [main:ZKDatabase@289] - Snapshot loaded in 26 ms, highest zxid is 0x0, digest is 1371985504
2020-04-24 17:32:32,812 [myid:] - INFO  [main:FileTxnSnapLog@470] - Snapshotting: 0x0 to D:\Dev\ZooKeeper\data\version-2\snapshot.0
2020-04-24 17:32:32,817 [myid:] - INFO  [main:ZooKeeperServer@519] - Snapshot taken in 5 ms
2020-04-24 17:32:32,837 [myid:] - INFO  [main:RequestThrottler@74] - zookeeper.request_throttler.shutdownTimeout = 10000
2020-04-24 17:32:32,867 [myid:] - INFO  [main:ContainerManager@83] - Using checkIntervalMs=60000 maxPerMinute=10000 maxNeverUsedIntervalMs=0
2020-04-24 17:32:32,868 [myid:] - INFO  [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.

測(cè)試

連接 ZooKeeper 服務(wù)
D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin>zkCli.cmd -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2020-04-24 17:37:53,803 [myid:] - INFO  [main:Environment@98] - Client environment:zookeeper.version=3.6.0--b4c89dc7f6083829e18fae6e446907ae0b1f22d7, built on 02/25/2020 14:38 GMT
2020-04-24 17:37:53,808 [myid:] - INFO  [main:Environment@98] - Client environment:host.name=
2020-04-24 17:37:53,810 [myid:] - INFO  [main:Environment@98] - Client environment:java.version=1.8.0_222
2020-04-24 17:37:53,814 [myid:] - INFO  [main:Environment@98] - Client environment:java.vendor=
2020-04-24 17:37:53,818 [myid:] - INFO  [main:Environment@98] - Client environment:java.home=D:\Dev\Java\jdk1.8.0_222\jre
2020-04-24 17:37:53,820 [myid:] - INFO  [main:Environment@98] - Client environment:java.class.path=D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\build\classes;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\build\lib\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\*;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\audience-annotations-0.5.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\commons-cli-1.2.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\commons-lang-2.6.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jackson-annotations-2.9.10.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jackson-core-2.9.10.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jackson-databind-2.9.10.3.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\javax.servlet-api-3.1.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-http-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-io-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-security-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-server-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-servlet-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jetty-util-9.4.24.v20191120.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\jline-2.11.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\json-simple-1.1.1.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\log4j-1.2.17.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\metrics-core-3.2.5.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-buffer-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-codec-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-common-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-handler-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-resolver-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-transport-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-transport-native-epoll-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\netty-transport-native-unix-common-4.1.45.Final.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient_common-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient_hotspot-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\simpleclient_servlet-0.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\slf4j-api-1.7.25.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\slf4j-log4j12-1.7.25.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\snappy-java-1.1.7.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\zookeeper-3.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\zookeeper-jute-3.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\lib\zookeeper-prometheus-metrics-3.6.0.jar;D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin\..\conf
2020-04-24 17:37:53,821 [myid:] - INFO  [main:Environment@98] - Client environment:java.library.path=D:\Dev\Java\jdk1.8.0_222\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Dev\Java\jdk1.8.0_222\bin;D:\Dev\Maven\apache-maven-3.6.3\bin;D:\Dev\MySQL\mysql-8.0.19-winx64\bin;D:\Dev\TortoiseSVN\bin;C:\TestTools\TMSS;D:\Dev\Git\cmd;D:\Dev\Go\bin;C:\WINDOWS\System32\OpenSSH\;D:\Dev\GoPath\bin;D:\Dev\Flutter\flutter\bin;D:\Dev\Git\bin;D:\Dev\nodejs\;C:\Python37\Scripts\;C:\Python37\;C:\Users\...\go\bin;C:\Users\...\AppData\Local\Microsoft\WindowsApps;D:\Dev\nodejs\node_global;.
2020-04-24 17:37:53,822 [myid:] - INFO  [main:Environment@98] - Client environment:java.io.tmpdir=C:\Users\...\AppData\Local\Temp\
2020-04-24 17:37:53,823 [myid:] - INFO  [main:Environment@98] - Client environment:java.compiler=<NA>
2020-04-24 17:37:53,829 [myid:] - INFO  [main:Environment@98] - Client environment:os.name=Windows 10
2020-04-24 17:37:53,834 [myid:] - INFO  [main:Environment@98] - Client environment:os.arch=amd64
2020-04-24 17:37:53,835 [myid:] - INFO  [main:Environment@98] - Client environment:os.version=10.0
2020-04-24 17:37:53,836 [myid:] - INFO  [main:Environment@98] - Client environment:user.name=
2020-04-24 17:37:53,837 [myid:] - INFO  [main:Environment@98] - Client environment:user.home=C:\Users\...
2020-04-24 17:37:53,837 [myid:] - INFO  [main:Environment@98] - Client environment:user.dir=D:\Dev\ZooKeeper\apache-zookeeper-3.6.0-bin\bin
2020-04-24 17:37:53,838 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.free=236MB
2020-04-24 17:37:53,841 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.max=3639MB
2020-04-24 17:37:53,845 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.total=245MB
2020-04-24 17:37:53,857 [myid:] - INFO  [main:ZooKeeper@1005] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@7637f22
2020-04-24 17:37:53,870 [myid:] - INFO  [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2020-04-24 17:37:54,134 [myid:] - INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2020-04-24 17:37:54,147 [myid:] - INFO  [main:ClientCnxn@1703] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2020-04-24 17:37:54,161 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1154] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181.
2020-04-24 17:37:54,162 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1156] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2020-04-24 17:37:54,170 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@986] - Socket connection established, initiating session, client: /127.0.0.1:51683, server: 127.0.0.1/127.0.0.1:2181
JLine support is enabled
2020-04-24 17:37:54,240 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1420] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, session id = 0x100002de1730000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0]
查看幫助
[zk: 127.0.0.1:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
        addWatch [-m mode] path # optional mode is one of [PERSISTENT, PERSISTENT_RECURSIVE] - default is PERSISTENT_RECURSIVE
        addauth scheme auth
        close
        config [-c] [-w] [-s]
        connect host:port
        create [-s] [-e] [-c] [-t ttl] path [data] [acl]
        delete [-v version] path
        deleteall path [-b batch size]
        delquota [-n|-b] path
        get [-s] [-w] path
        getAcl [-s] path
        getAllChildrenNumber path
        getEphemerals path
        history
        listquota path
        ls [-s] [-w] [-R] path
        printwatches on|off
        quit
        reconfig [-s] [-v version] [[-file path] | [-members serverID=host:port1:port2;port3[,...]*]] | [-add serverId=host:port1:port2;port3[,...]]* [-remove serverId[,...]*]
        redo cmdno
        removewatches path [-c|-d|-a] [-l]
        set [-s] [-v version] path data
        setAcl [-s] [-v version] [-R] path acl
        setquota -n|-b val path
        stat [-w] path
        sync path
        version
創(chuàng)建 znode
[zk: 127.0.0.1:2181(CONNECTED) 2] create /zk_test test_data
Created /zk_test
查看所有 znode
[zk: 127.0.0.1:2181(CONNECTED) 3] ls /
[zk_test, zookeeper]
查看指定 znode 的值
[zk: 127.0.0.1:2181(CONNECTED) 4] get /zk_test
test_data

至此已測(cè)試 ZooKeeper 安裝啟動(dòng)成功,其余命令將在另外的文章中專門講解丢胚。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末翩瓜,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子携龟,更是在濱河造成了極大的恐慌兔跌,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,817評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件峡蟋,死亡現(xiàn)場(chǎng)離奇詭異坟桅,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)蕊蝗,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,329評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門仅乓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人蓬戚,你說(shuō)我怎么就攤上這事夸楣。” “怎么了?”我有些...
    開封第一講書人閱讀 157,354評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵裕偿,是天一觀的道長(zhǎng)洞慎。 經(jīng)常有香客問(wèn)我,道長(zhǎng)嘿棘,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,498評(píng)論 1 284
  • 正文 為了忘掉前任旭绒,我火速辦了婚禮鸟妙,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘挥吵。我一直安慰自己重父,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,600評(píng)論 6 386
  • 文/花漫 我一把揭開白布忽匈。 她就那樣靜靜地躺著房午,像睡著了一般。 火紅的嫁衣襯著肌膚如雪丹允。 梳的紋絲不亂的頭發(fā)上郭厌,一...
    開封第一講書人閱讀 49,829評(píng)論 1 290
  • 那天,我揣著相機(jī)與錄音雕蔽,去河邊找鬼折柠。 笑死,一個(gè)胖子當(dāng)著我的面吹牛批狐,可吹牛的內(nèi)容都是我干的扇售。 我是一名探鬼主播,決...
    沈念sama閱讀 38,979評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼嚣艇,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼承冰!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起食零,我...
    開封第一講書人閱讀 37,722評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤困乒,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后慌洪,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體顶燕,經(jīng)...
    沈念sama閱讀 44,189評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,519評(píng)論 2 327
  • 正文 我和宋清朗相戀三年冈爹,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了涌攻。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,654評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡频伤,死狀恐怖恳谎,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤因痛,帶...
    沈念sama閱讀 34,329評(píng)論 4 330
  • 正文 年R本政府宣布婚苹,位于F島的核電站,受9級(jí)特大地震影響鸵膏,放射性物質(zhì)發(fā)生泄漏膊升。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,940評(píng)論 3 313
  • 文/蒙蒙 一谭企、第九天 我趴在偏房一處隱蔽的房頂上張望廓译。 院中可真熱鬧,春花似錦债查、人聲如沸非区。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,762評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)征绸。三九已至,卻和暖如春俄占,著一層夾襖步出監(jiān)牢的瞬間管怠,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,993評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工颠放, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留排惨,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,382評(píng)論 2 360
  • 正文 我出身青樓碰凶,卻偏偏與公主長(zhǎng)得像暮芭,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子欲低,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,543評(píng)論 2 349

推薦閱讀更多精彩內(nèi)容