win10下安装并启动zookeeper
Posted wuxun1997
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了win10下安装并启动zookeeper相关的知识,希望对你有一定的参考价值。
下载直接到zk的官网(zookeeper.apache.org)即可,点击右边的Releases,在Download下再点Download进入镜像下载页面,在给出的链接列表里选择一个镜像地址,进去后选择版本(这里最新的是3.4.10)下载压缩包。
解压到本地(这里是D盘)后,需要修改下配置文件名,进入conf目录,将zoo_sample.cfg改为zoo.cfg。如果仅将zk作为单点来用,那么进入bin目录双击zkServer.cmd启动服务端,出现命令行窗口:
D:Devzookeeper-3.4.10in>call "D:DevJavajdk1.8.0_102"injava "-Dzookeeper.log.dir=D:Devzookeeper-3.4.10in.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "D:Devzookeeper-3.4.10in..uildclasses;D:Devzookeeper-3.4.10in..uildlib*;D:Devzookeeper-3.4.10in..*;D:Devzookeeper-3.4.10in..lib*;D:Devzookeeper-3.4.10in..conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:Devzookeeper-3.4.10in..confzoo.cfg" 2018-09-11 11:19:28,567 [myid:] - INFO [main:[email protected]134] - Reading configuration from: D:Devzookeeper-3.4.10in..confzoo.cfg 2018-09-11 11:19:28,600 [myid:] - INFO [main:[email protected]78] - autopurge.snapRetainCount set to 3 2018-09-11 11:19:28,600 [myid:] - INFO [main:[email protected]79] - autopurge.purgeInterval set to 0 2018-09-11 11:19:28,600 [myid:] - INFO [main:[email protected]101] - Purge task is not scheduled. 2018-09-11 11:19:28,602 [myid:] - WARN [main:[email protected]113] - Either no config or no quorum defined in config, running in standalone mode 2018-09-11 11:19:28,767 [myid:] - INFO [main:[email protected]134] - Reading configuration from: D:Devzookeeper-3.4.10in..confzoo.cfg 2018-09-11 11:19:28,768 [myid:] - INFO [main:[email protected]96] - Starting server 2018-09-11 11:19:28,800 [myid:] - INFO [main:[email protected]100] - Server environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT 2018-09-11 11:19:28,800 [myid:] - INFO [main:[email protected]100] - Server environment:host.name=windows10.microdone.cn 2018-09-11 11:19:28,801 [myid:] - INFO [main:[email protected]100] - Server environment:java.version=1.8.0_102 2018-09-11 11:19:28,801 [myid:] - INFO [main:[email protected]100] - Server environment:java.vendor=Oracle Corporation 2018-09-11 11:19:28,801 [myid:] - INFO [main:[email protected]100] - Server environment:java.home=D:DevJavajdk1.8.0_102jre 2018-09-11 11:19:28,802 [myid:] - INFO [main:[email protected]100] - Server environment:java.class.path=D:Devzookeeper-3.4.10in..uildclasses;D:Devzookeeper-3.4.10in..uildlib*;D:Devzookeeper-3.4.10in..zookeeper-3.4.10.jar;D:Devzookeeper-3.4.10in..libjline-0.9.94.jar;D:Devzookeeper-3.4.10in..liblog4j-1.2.16.jar;D:Devzookeeper-3.4.10in..lib etty-3.10.5.Final.jar;D:Devzookeeper-3.4.10in..libslf4j-api-1.6.1.jar;D:Devzookeeper-3.4.10in..libslf4j-log4j12-1.6.1.jar;D:Devzookeeper-3.4.10in..conf 2018-09-11 11:19:28,802 [myid:] - INFO [main:[email protected]100] - Server environment:java.library.path=D:DevJavajdk1.8.0_102in;C:WINDOWSSunJavain;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WindowsCCM;D:UtilityTortoiseSVNin;D:UtilityPuTTY;D:DevJavajdk1.8.0_102in;D:Devapache-maven-3.3.9in;D:Devapache-tomcat-9.0.0.M26in;D:Devoracleproduct11.2.0dbhome_1in;C:ProgramDataOracleJavajavapath;D:Devoracleinstantclient_12_2;D:Dev odejs;C:Program FilesmysqlMySQL Utilities 1.6;D:DevGitcmd;C:WINDOWSSystem32OpenSSH;C:Program Files (x86)Windows Kits8.1Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:UserswulfAppDataLocalMicrosoftWindowsApps;C:UserswulfAppDataRoaming pm;;D:UtilityFiddler;%USERPROFILE%AppDataLocalMicrosoftWindowsApps;. 2018-09-11 11:19:28,802 [myid:] - INFO [main:[email protected]100] - Server environment:java.io.tmpdir=C:UserswulfAppDataLocalTemp2018-09-11 11:19:28,802 [myid:] - INFO [main:[email protected]100] - Server environment:java.compiler=<NA> 2018-09-11 11:19:28,803 [myid:] - INFO [main:[email protected]100] - Server environment:os.name=Windows 10 2018-09-11 11:19:28,803 [myid:] - INFO [main:[email protected]100] - Server environment:os.arch=amd64 2018-09-11 11:19:28,804 [myid:] - INFO [main:[email protected]100] - Server environment:os.version=10.0 2018-09-11 11:19:28,805 [myid:] - INFO [main:[email protected]100] - Server environment:user.name=wulf 2018-09-11 11:19:28,805 [myid:] - INFO [main:[email protected]100] - Server environment:user.home=C:Userswulf 2018-09-11 11:19:28,806 [myid:] - INFO [main:[email protected]100] - Server environment:user.dir=D:Devzookeeper-3.4.10in 2018-09-11 11:19:28,816 [myid:] - INFO [main:[email protected]829] - tickTime set to 2000 2018-09-11 11:19:28,816 [myid:] - INFO [main:[email protected]838] - minSessionTimeout set to -1 2018-09-11 11:19:28,817 [myid:] - INFO [main:[email protected]847] - maxSessionTimeout set to -1 2018-09-11 11:19:29,070 [myid:] - INFO [main:[email protected]89] - binding to port 0.0.0.0/0.0.0.0:2181
再双击zkCli.cmd启动客户端:
Connecting to localhost:2181 2018-09-11 11:19:47,802 [myid:] - INFO [main:[email protected]100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT 2018-09-11 11:19:47,805 [myid:] - INFO [main:[email protected]100] - Client environment:host.name=windows10.microdone.cn 2018-09-11 11:19:47,805 [myid:] - INFO [main:[email protected]100] - Client environment:java.version=1.8.0_102 2018-09-11 11:19:47,808 [myid:] - INFO [main:[email protected]100] - Client environment:java.vendor=Oracle Corporation 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:java.home=D:DevJavajdk1.8.0_102jre 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:java.class.path=D:Devzookeeper-3.4.10in..uildclasses;D:Devzookeeper-3.4.10in..uildlib*;D:Devzookeeper-3.4.10in..zookeeper-3.4.10.jar;D:Devzookeeper-3.4.10in..libjline-0.9.94.jar;D:Devzookeeper-3.4.10in..liblog4j-1.2.16.jar;D:Devzookeeper-3.4.10in..lib etty-3.10.5.Final.jar;D:Devzookeeper-3.4.10in..libslf4j-api-1.6.1.jar;D:Devzookeeper-3.4.10in..libslf4j-log4j12-1.6.1.jar;D:Devzookeeper-3.4.10in..conf 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:java.library.path=D:DevJavajdk1.8.0_102in;C:WINDOWSSunJavain;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WindowsCCM;D:UtilityTortoiseSVNin;D:UtilityPuTTY;D:DevJavajdk1.8.0_102in;D:Devapache-maven-3.3.9in;D:Devapache-tomcat-9.0.0.M26in;D:Devoracleproduct11.2.0dbhome_1in;C:ProgramDataOracleJavajavapath;D:Devoracleinstantclient_12_2;D:Dev odejs;C:Program FilesMySQLMySQL Utilities 1.6;D:DevGitcmd;C:WINDOWSSystem32OpenSSH;C:Program Files (x86)Windows Kits8.1Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:UserswulfAppDataLocalMicrosoftWindowsApps;C:UserswulfAppDataRoaming pm;;D:UtilityFiddler;%USERPROFILE%AppDataLocalMicrosoftWindowsApps;. 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:java.io.tmpdir=C:UserswulfAppDataLocalTemp2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:java.compiler=<NA> 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:os.name=Windows 10 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:os.arch=amd64 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:os.version=10.0 2018-09-11 11:19:47,809 [myid:] - INFO [main:[email protected]100] - Client environment:user.name=wulf 2018-09-11 11:19:47,810 [myid:] - INFO [main:[email protected]100] - Client environment:user.home=C:Userswulf 2018-09-11 11:19:47,810 [myid:] - INFO [main:[email protected]100] - Client environment:user.dir=D:Devzookeeper-3.4.10in 2018-09-11 11:19:47,811 [myid:] - INFO [main:[email protected]438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=[email protected] Welcome to ZooKeeper! 2018-09-11 11:19:48,062 [myid:] - INFO [main-SendThread(0:0:0:0:0:0:0:1:2181):[email protected]1032] - Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) 2018-09-11 11:19:48,065 [myid:] - INFO [main-SendThread(0:0:0:0:0:0:0:1:2181):[email protected]876] - Socket connection established to 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181, initiating session JLine support is enabled [zk: localhost:2181(CONNECTING) 0] 2018-09-11 11:19:48,090 [myid:] - INFO [main-SendThread(0:0:0:0:0:0:0:1:2181):[email protected]1299] - Session establishment complete on server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181, sessionid = 0x165c6a41e3a0000, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null
这时就可以开始在客户端敲命令了:
[zk: localhost:2181(CONNECTED) 2] ls / [zookeeper] [zk: localhost:2181(CONNECTED) 3] create /zk hello,world! Created /zk [zk: localhost:2181(CONNECTED) 4] ls / [zk, zookeeper] [zk: localhost:2181(CONNECTED) 5] get /zk hello,world! cZxid = 0x2 ctime = Tue Sep 11 11:22:48 CST 2018 mZxid = 0x2 mtime = Tue Sep 11 11:22:48 CST 2018 pZxid = 0x2 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 12 numChildren = 0
服务端也会打印客户端过来的请求:
2018-09-11 11:19:48,064 [myid:] - INFO [NioserverCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]192] - Accepted socket connection from /0:0:0:0:0:0:0:1:57459 2018-09-11 11:19:48,073 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:[email protected]942] - Client attempting to establish new session at /0:0:0:0:0:0:0:1:57459 2018-09-11 11:19:48,076 [myid:] - INFO [SyncThread:0:[email protected]203] - Creating new log file: log.1 2018-09-11 11:19:48,088 [myid:] - INFO [SyncThread:0:[email protected]687] - Established session 0x165c6a41e3a0000 with negotiated timeout 30000 for client /0:0:0:0:0:0:0:1:57459
以上是关于win10下安装并启动zookeeper的主要内容,如果未能解决你的问题,请参考以下文章