zookeeper在window下的搭建
生活随笔
收集整理的這篇文章主要介紹了
zookeeper在window下的搭建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
安裝zk前置條件
單機安裝
啟動日志如下:
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偽集群搭建
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:13389zookeeper1的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:13389zookeeper2的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文件內容就是各個節點的編號,zookeeper0的myid文件里面就是0,zookeeper1的myid文件里面就是1,zookeeper2的myid文件里面就是2
配置參數含義
在zoo.cfg中的配置參數的含義如下
A:其中 A 是一個數字,表示這個是服務器的編號;
B:是這個服務器的 ip 地址;
C:Leader選舉的端口;
D:Zookeeper服務器之間的通信端口。
配置zk集群需要新增的是 server.A=B:C:D 配置,其中 A 對應myid 文件里面的內容。B是集群的各個IP地址,C:D 是端口配置。
Zookeeper的一些常用命令
總結
以上是生活随笔為你收集整理的zookeeper在window下的搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Map的putAll方法踩坑实记(对象深
- 下一篇: Jmeter5.3安装(window10