1、什么时Zookeeper
ZooKeeper:分布式服务框架 Zookeeper -- 管理分布式环境中的数据。
2、安装
1》官网下载压缩包并解压zookeeper-3.4.14.zip
2》在zookeeper-3.4.14的Home目录新建data、log文件夹
3》进入conf目录,复制其中的zoo_sample.cfg文件到同级目录,重命名为zoo.cfg(Zookeeper 在启动时会找这个文件作为默认配置文件)。修改其中的dataDir、dataLogDir
...
# example sakes.
dataDir=F:\\ebook\\Dubbo\\zookeeper-3.4.14\\data
dataLogDir=F:\\ebook\\Dubbo\\zookeeper-3.4.14\\log
# the port at which the clients will connect
...
3、启动测试
Microsoft Windows [版本 10.0.17763.737] (c) 2018 Microsoft Corporation。保留所有权利。 F:\ebook\Dubbo\zookeeper-3.4.14\bin>zkServer.cmd F:\ebook\Dubbo\zookeeper-3.4.14\bin>call "C:\Program Files\Java\jdk1.8.0_65"\bin\java "-Dzookeeper.log.dir=F:\ebook\Dubbo\zookeeper-3.4.14\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\build\classes;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\build\lib\*;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\*;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\*;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\conf\zoo.cfg" 2019-09-23 23:21:11,967 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\conf\zoo.cfg 2019-09-23 23:21:11,983 [myid:] - INFO [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3 2019-09-23 23:21:11,983 [myid:] - INFO [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0 2019-09-23 23:21:11,983 [myid:] - INFO [main:DatadirCleanupManager@101] - Purge task is not scheduled. 2019-09-23 23:21:11,983 [myid:] - WARN [main:QuorumPeerMain@116] - Either no config or no quorum defined in config, running in standalone mode 2019-09-23 23:21:12,057 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\conf\zoo.cfg 2019-09-23 23:21:12,057 [myid:] - INFO [main:ZooKeeperServerMain@98] - Starting server 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:zookeeper.version=3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:host.name=DESKTOP-V80IF6T 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:java.version=1.8.0_65 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:java.vendor=Oracle Corporation 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:java.home=C:\Program Files\Java\jdk1.8.0_65\jre 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:java.class.path=F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\build\classes;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\build\lib\*;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\zookeeper-3.4.14.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\audience-annotations-0.5.0.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\jline-0.9.94.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\log4j-1.2.17.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\netty-3.10.6.Final.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\slf4j-api-1.7.25.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\slf4j-log4j12-1.7.25.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\conf 2019-09-23 23:21:12,073 [myid:] - INFO [main:Environment@100] - Server environment:java.library.path=C:\Program Files\Java\jdk1.8.0_65\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Program Files\Java\jdk1.8.0_65\bin;D:\fyliu\softwares\apache-maven-3.6.1\bin;D:\fyliu\softwares\apache-ant-1.9.4\bin;;. 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:java.io.tmpdir=C:\Users\lfy\AppData\Local\Temp\ 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:java.compiler=2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:os.name=Windows 10 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:os.arch=amd64 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:os.version=10.0 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:user.name=lfy 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:user.home=C:\Users\lfy 2019-09-23 23:21:12,088 [myid:] - INFO [main:Environment@100] - Server environment:user.dir=F:\ebook\Dubbo\zookeeper-3.4.14\bin 2019-09-23 23:21:12,088 [myid:] - INFO [main:ZooKeeperServer@836] - tickTime set to 2000 2019-09-23 23:21:12,088 [myid:] - INFO [main:ZooKeeperServer@845] - minSessionTimeout set to -1 2019-09-23 23:21:12,088 [myid:] - INFO [main:ZooKeeperServer@854] - maxSessionTimeout set to -1 2019-09-23 23:21:12,135 [myid:] - INFO [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory 2019-09-23 23:21:12,135 [myid:] - INFO [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
Microsoft Windows [版本 10.0.17763.737] (c) 2018 Microsoft Corporation。保留所有权利。 C:\Users\lfy>jps -l -v 14868 exit -Xms128m -Xmx1008m -XX:ReservedCodeCacheSize=240m -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -XX:CICompilerCount=2 -Dsun.io.useCanonPrefixCache=false -Djava.net.preferIPv4Stack=true -Djdk.http.auth.tunneling.disabledSchemes="" -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Djdk.attach.allowAttachSelf -Dkotlinx.coroutines.debug=off -Djdk.module.illegalAccess.silent=true -Djb.vmOptionsFile=C:\Users\lfy\.IntelliJIdea2019.2\config\idea64.exe.vmoptions -Djava.library.path=D:\fyliu\softwares\ideaIU-2019.2.2.win\jbr\\bin;D:\fyliu\softwares\ideaIU-2019.2.2.win\jbr\\bin\server -Didea.jre.check=true -Dide.native.launcher=true -Didea.paths.selector=IntelliJIdea2019.2 -XX:ErrorFile=C:\Users\lfy\java_error_in_idea_%p.log -XX:HeapDumpPath=C:\Users\lfy\java_error_in_idea.hprof 12824 sun.tools.jps.Jps -Dapplication.home=C:\Program Files\Java\jdk1.8.0_65 -Xms8m 12332 org.jetbrains.idea.maven.server.RemoteMavenServer36 -Djava.awt.headless=true -Dmaven.defaultProjectBuilder.disableGlobalModelCache=true -Xmx768m -Didea.maven.embedder.version=3.6.1 -Dmaven.ext.class.path=D:\fyliu\softwares\ideaIU-2019.2.2.win\plugins\maven\lib\maven-event-listener.jar -Dfile.encoding=GBK 1932 org.apache.zookeeper.server.quorum.QuorumPeerMain -Dzookeeper.log.dir=F:\ebook\Dubbo\zookeeper-3.4.14\bin\.. -Dzookeeper.root.logger=INFO,CONSOLE C:\Users\lfy>
启动客户端连接。
Microsoft Windows [版本 10.0.17763.737] (c) 2018 Microsoft Corporation。保留所有权利。 F:\ebook\Dubbo\zookeeper-3.4.14\bin>zkCli.cmd Connecting to localhost:2181 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:host.name=DESKTOP-V80IF6T 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_65 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.home=C:\Program Files\Java\jdk1.8.0_65\jre 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\build\classes;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\build\lib\*;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\zookeeper-3.4.14.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\audience-annotations-0.5.0.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\jline-0.9.94.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\log4j-1.2.17.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\netty-3.10.6.Final.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\slf4j-api-1.7.25.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\lib\slf4j-log4j12-1.7.25.jar;F:\ebook\Dubbo\zookeeper-3.4.14\bin\..\conf 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=C:\Program Files\Java\jdk1.8.0_65\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Program Files\Java\jdk1.8.0_65\bin;D:\fyliu\softwares\apache-maven-3.6.1\bin;D:\fyliu\softwares\apache-ant-1.9.4\bin;;. 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=C:\Users\lfy\AppData\Local\Temp\ 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Windows 10 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:os.version=10.0 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:user.name=lfy 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:user.home=C:\Users\lfy 2019-09-23 23:30:02,422 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=F:\ebook\Dubbo\zookeeper-3.4.14\bin 2019-09-23 23:30:02,422 [myid:] - INFO [main:ZooKeeper@442] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@531d72ca Welcome to ZooKeeper! 2019-09-23 23:30:02,486 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1025] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) 2019-09-23 23:30:02,486 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@879] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session JLine support is enabled [zk: localhost:2181(CONNECTING) 0]