win10安裝Zookeeper3.4.12
阿新 • • 發佈:2018-12-04
war ota oba win10安裝 www. data home win10 ann
目錄
- 安裝:
- 下載:
- 配置環境變量:
- 目錄說明:
- 配置文件說明:
- 啟動:
- 啟動服務端:
- 查看:
- 啟動客戶端:
- 操作命令:
- ls:
- create:
- get:
- set:
- 參考:
為了方便在本地開發環境進行調試,希望在win10環境中安裝一個zookeeper
安裝:
下載:
下載最新的stable版
zookeeper-3.4.12.tar.gz
配置環境變量:
ZOOKEEPER_HOME=D:\Program Files\zookeeper-3.4.12
PATH=%ZOOKEEPER_HOME%\bin
目錄說明:
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 Files\zookeeper-3.4.12\bin $ zkServer.cmd call "D:\Program Files\Java\jdk1.8.0"\bin\java "-Dzookeeper.log.dir=D:\Program Files\zookeeper-3.4.12\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "D:\Program Files\zookeeper-3.4.12\bin\..\build\classes;D:\Program Files\zookeeper-3.4.12\bin\..\build\lib\*;D:\Program Files\zookeeper-3.4.12\bin\..\*;D:\Program Files\zookeeper-3.4.12\bin\..\lib\*;D:\Program Files\zookeeper-3.4.12\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:\Program Files\zookeeper-3.4.12\bin\..\conf\zoo.cfg" 2018-12-04 11:14:28,112 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: D:\Program Files\zookeeper-3.4.12\bin\..\conf\zoo.cfg 2018-12-04 11:14:28,127 [myid:] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3 2018-12-04 11:14:28,127 [myid:] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0 2018-12-04 11:14:28,128 [myid:] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled. 2018-12-04 11:14:28,130 [myid:] - WARN [main:QuorumPeerMain@116] - Either no config or no quorum defined in config, running in standalone mode 2018-12-04 11:14:28,210 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: D:\Program Files\zookeeper-3.4.12\bin\..\conf\zoo.cfg 2018-12-04 11:14:28,211 [myid:] - INFO [main:ZooKeeperServerMain@98] - Starting server 2018-12-04 11:14:37,250 [myid:] - INFO [main:Environment@100] - 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:Environment@100] - Server environment:host.name=hongda 2018-12-04 11:14:37,251 [myid:] - INFO [main:Environment@100] - Server environment:java.version=1.8.0_181 2018-12-04 11:14:37,251 [myid:] - INFO [main:Environment@100] - Server environment:java.vendor=Oracle Corporation 2018-12-04 11:14:37,251 [myid:] - INFO [main:Environment@100] - Server environment:java.home=D:\Program Files\Java\jdk1.8.0\jre 2018-12-04 11:14:37,252 [myid:] - INFO [main:Environment@100] - Server environment:java.class.path=D:\Program Files\zookeeper-3.4.12\bin\..\build\classes;D:\Program Files\zookeeper-3.4.12\bin\..\build\lib\*;D:\Program Files\zookeeper-3.4.12\bin\..\zookeeper-3.4.12.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\audience-annotations-0.5.0.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\jline-0.9.94.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\log4j-1.2.17.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\netty-3.10.6.Final.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\slf4j-api-1.7.25.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\slf4j-log4j12-1.7.25.jar;D:\Program Files\zookeeper-3.4.12\bin\..\conf 2018-12-04 11:14:37,253 [myid:] - INFO [main:Environment@100] - Server environment:java.library.path=D:\Program Files\Java\jdk1.8.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Program Files\cmder\bin;D:\Program Files\cmder\vendor\conemu-maximus5\ConEmu\Scripts;D:\Program Files\cmder\vendor\conemu-maximus5;D:\Program Files\cmder\vendor\conemu-maximus5\ConEmu;D:\Program Files\nodejs\node_global;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;%ANDROID_HOME%;%ANDROID_HOME%\tools;%ANDROID_HOME%\build-tools;%ANDROID_HOME%\platform-tools;D:\Program Files\Tomcat8\bin;D:\Program Files\Java\jdk1.8.0\bin;D:\Program Files\Java\jdk1.8.0\jre\bin;D:\Program Files\MySQL\bin;D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle\bin;D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\maven\bin;D:\Program Files\cmder;D:\Program Files\nodejs;D:\Program Files\curl\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Microsoft VS Code\bin;D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle\bin;D:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;D:\Program Files\Python\Python36\Scripts\;D:\Program Files\Python\Python36\;C:\Users\qhong\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Microsoft VS Code\bin;C:\Program Files\Bandizip\;C:\Users\qhong\AppData\Local\Pandoc\;C:\Program Files\smartmontools\bin;C:\Users\qhong\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Git\mingw64;D:\Program Files\Git\usr\bin;. 2018-12-04 11:14:37,257 [myid:] - INFO [main:Environment@100] - Server environment:java.io.tmpdir=C:\Users\qhong\AppData\Local\Temp2018-12-04 11:14:37,258 [myid:] - INFO [main:Environment@100] - Server environment:java.compiler=<NA> 2018-12-04 11:14:37,259 [myid:] - INFO [main:Environment@100] - Server environment:os.name=Windows 10 2018-12-04 11:14:37,260 [myid:] - INFO [main:Environment@100] - Server environment:os.arch=amd64 2018-12-04 11:14:37,260 [myid:] - INFO [main:Environment@100] - Server environment:os.version=10.0 2018-12-04 11:14:37,260 [myid:] - INFO [main:Environment@100] - Server environment:user.name=qhong 2018-12-04 11:14:37,261 [myid:] - INFO [main:Environment@100] - Server environment:user.home=C:\Users\qhong 2018-12-04 11:14:37,261 [myid:] - INFO [main:Environment@100] - Server environment:user.dir=D:\Program Files\zookeeper-3.4.12\bin 2018-12-04 11:14:37,277 [myid:] - INFO [main:ZooKeeperServer@835] - tickTime set to 2000 2018-12-04 11:14:37,278 [myid:] - INFO [main:ZooKeeperServer@844] - minSessionTimeout set to -1 2018-12-04 11:14:37,278 [myid:] - INFO [main:ZooKeeperServer@853] - maxSessionTimeout set to -1 2018-12-04 11:14:38,473 [myid:] - INFO [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory 2018-12-04 11:14:38,477 [myid:] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
查看:
D:\Development\payment-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:\Development\payment-server (master -> origin)
$ tasklist | findstr "19912"
java.exe 19912 Console 1 44,660 K
啟動客戶端:
D:\Program Files\zookeeper-3.4.12\bin
$ 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:Environment@100] - 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:Environment@100] - Client environment:host.name=hongda
2018-12-04 11:29:00,779 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_181
2018-12-04 11:29:00,781 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-12-04 11:29:00,782 [myid:] - INFO [main:Environment@100] - Client environment:java.home=D:\Program Files\Java\jdk1.8.0\jre
2018-12-04 11:29:00,782 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=D:\Program Files\zookeeper-3.4.12\bin\..\build\classes;D:\Program Files\zookeeper-3.4.12\bin\..\build\lib\*;D:\Program Files\zookeeper-3.4.12\bin\..\zookeeper-3.4.12.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\audience-annotations-0.5.0.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\jline-0.9.94.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\log4j-1.2.17.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\netty-3.10.6.Final.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\slf4j-api-1.7.25.jar;D:\Program Files\zookeeper-3.4.12\bin\..\lib\slf4j-log4j12-1.7.25.jar;D:\Program Files\zookeeper-3.4.12\bin\..\conf
2018-12-04 11:29:00,783 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=D:\Program Files\Java\jdk1.8.0\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Program Files\cmder\bin;D:\Program Files\cmder\vendor\conemu-maximus5\ConEmu\Scripts;D:\Program Files\cmder\vendor\conemu-maximus5;D:\Program Files\cmder\vendor\conemu-maximus5\ConEmu;D:\Program Files\nodejs\node_global;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;%ANDROID_HOME%;%ANDROID_HOME%\tools;%ANDROID_HOME%\build-tools;%ANDROID_HOME%\platform-tools;D:\Program Files\Tomcat8\bin;D:\Program Files\Java\jdk1.8.0\bin;D:\Program Files\Java\jdk1.8.0\jre\bin;D:\Program Files\MySQL\bin;D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle\bin;D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\maven\bin;D:\Program Files\cmder;D:\Program Files\nodejs;D:\Program Files\curl\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\Microsoft VS Code\bin;D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle\bin;D:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;D:\Program Files\Python\Python36\Scripts\;D:\Program Files\Python\Python36\;C:\Users\qhong\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Microsoft VS Code\bin;C:\Program Files\Bandizip\;C:\Users\qhong\AppData\Local\Pandoc\;C:\Program Files\smartmontools\bin;C:\Users\qhong\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Git\mingw64;D:\Program Files\Git\usr\bin;.
2018-12-04 11:29:00,787 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=C:\Users\qhong\AppData\Local\Temp2018-12-04 11:29:00,788 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA>
2018-12-04 11:29:00,788 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Windows 10
2018-12-04 11:29:00,788 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64
2018-12-04 11:29:00,789 [myid:] - INFO [main:Environment@100] - Client environment:os.version=10.0
2018-12-04 11:29:00,789 [myid:] - INFO [main:Environment@100] - Client environment:user.name=qhong
2018-12-04 11:29:00,789 [myid:] - INFO [main:Environment@100] - Client environment:user.home=C:\Users\qhong
2018-12-04 11:29:00,789 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=D:\Program Files\zookeeper-3.4.12\bin
2018-12-04 11:29:00,792 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@67424e82
Welcome to ZooKeeper!
2018-12-04 11:29:02,164 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1028] - 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):ClientCnxn$SendThread@878] - 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):ClientCnxn$SendThread@1302] - 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