码迷,mamicode.com
首页 > Windows程序 > 详细

ZooKeeper:win7上安装单机及伪分布式安装

时间:2017-09-09 22:28:15      阅读:490      评论:0      收藏:0      [点我收藏+]

标签:height   example   apach   min   auth   val   多个   auto   技术   

  zookeeper是一个为分布式应用所设计的分布式的、开源的调度服务,它主要用来解决分布式应用中经常遇到的一些数据管理问题,简化分布式应用,协调及其管理的难度,提高性能的分布式服务。

  本章的目的:如何安装zookeeper(在win7环境下),zookeeper下载https://mirrors.cnnic.cn/apache/zookeeper/。这里下载的版本是3.4.8.  

  zoomkeeper本身是可以单节点模式安装运行,不过一般为了确保zookeeper的稳定性和可用性,都会采用分布式部署,也进而保证了分布式应用的可靠性。它在分布式zookepper集群中,会基于选举算法来实现一个leader,多个follower。

  参考文章:http://blog.csdn.net/lovesummerforever/article/details/48975703

  • 单节点安装及配置:

1)下载zookeeper-3.4.8.tar.gz,并解压到目录:D:\Work\zookeeper\zookeeper-3.4.8下

技术分享

2)进入conf目录下把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:\\Work\\zookeeper\\data
# log config
dataLogDir=D:\\Work\\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

3)启动zookeeper服务:

进入目录:D:\Work\zookeeper\zookeeper-3.4.8\bin,执行zkServer.cmd,这样就启动了zookeeper服务了。

--启动打印信息
D:\Work\zookeeper\zookeeper-3.4.8\bin>zkServer.cmd

D:\Work\zookeeper\zookeeper-3.4.8\bin>call "D:\Program Files\Java\jdk1.8.0_111"\bin\java "-Dzookeeper.log.dir=D:\Work\zookeeper\zookeeper-3.4.8\bin\.." "-Dzookeeper.root.logger=INFO,CONSOLE" -cp "D:\Work\zookeeper\zookeeper-3.4.8\bin\..\build\classes;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\build\lib\*;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\*;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\lib\*;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "D:\Work\zookeeper\zookeeper-3.4.8\bin\..\conf\zoo.cfg"
2017-09-09 21:02:58,180 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: D:\Work\zookeeper\zookeeper-3.4.8\bin\..\conf\zoo.cfg
2017-09-09 21:02:58,204 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2017-09-09 21:02:58,205 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 0
2017-09-09 21:02:58,205 [myid:] - INFO  [main:DatadirCleanupManager@101] - Purge task is not scheduled.
2017-09-09 21:02:58,211 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2017-09-09 21:02:58,445 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: D:\Work\zookeeper\zookeeper-3.4.8\bin\..\conf\zoo.cfg
2017-09-09 21:02:58,446 [myid:] - INFO  [main:ZooKeeperServerMain@95] - Starting server
2017-09-09 21:02:58,769 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.8--1, built on 02/06/2016 03:18 GMT
2017-09-09 21:02:58,772 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=192.168.233.1
2017-09-09 21:02:58,777 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.8.0_111
2017-09-09 21:02:58,778 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2017-09-09 21:02:58,780 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=D:\Program Files\Java\jdk1.8.0_111\jre
2017-09-09 21:02:58,782 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=D:\Work\zookeeper\zookeeper-3.4.8\bin\..\build\classes;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\build\lib\*;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\zookeeper-3.4.8.jar;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\lib\jline-0.9.94.jar;D:\Work\zookeeper\zookeeper-3.4.8\bin\..\lib\log4j-1.2.16.jar;。。。2017-09-09 21:02:58,784 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=D:\Program Files\Java\jdk1.8.0_111\bin;D:\Program Files\Java\jdk1.8.0_111\bin;D:\Program Files\Java\jdk1.8.0_111\jre\bin;
.
2017-09-09 21:02:58,789 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp2017-09-09 21:02:58,791 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2017-09-09 21:02:58,800 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Windows 7
2017-09-09 21:02:58,801 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2017-09-09 21:02:58,804 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=6.1
2017-09-09 21:02:58,811 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=Administrator
2017-09-09 21:02:58,813 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=C:\Users\Administrator
2017-09-09 21:02:58,816 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=D:\Work\zookeeper\zookeeper-3.4.8\bin
2017-09-09 21:02:58,849 [myid:] - INFO  [main:ZooKeeperServer@787] - tickTime set to 2000
2017-09-09 21:02:58,851 [myid:] - INFO  [main:ZooKeeperServer@796] - minSessionTimeout set to -1
2017-09-09 21:02:58,852 [myid:] - INFO  [main:ZooKeeperServer@805] - maxSessionTimeout set to -1
2017-09-09 21:03:00,548 [myid:] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181


--当客户端启动后,就立即打印出来以下信息:
2017-09-09 21:05:23,463 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:33988
2017-09-09 21:05:23,483 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@900] - Client attempting to establish new session at /127.0.0.1:33988
2017-09-09 21:05:23,496 [myid:] - INFO  [SyncThread:0:FileTxnLog@199] - Creating new log file: log.1
2017-09-09 21:05:23,542 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@645] - Established session 0x15e66bc75ec0000 with negotiated timeout 30000 for client /127.0.0.1:33988

4)启动客户端

进入目录:D:\Work\zookeeper\zookeeper-3.4.8\bin,执行zkCli.cmd -server 127.0.0.1:2181,这样就启动了zookeeper服务了。

D:\Work\zookeeper\zookeeper-3.4.8\bin>zkCli.cmd -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2017-09-09 21:05:21,934 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.8--1, built on 02/06/2016 03:18 GMT
2017-09-09 21:05:21,942 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=192.168.233.1
2017-09-09 21:05:21,943 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_111
2017-09-09 21:05:21,947 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2017-09-09 21:05:21,948 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=D:\Program Files\Java\jdk1.8.0_111\jre
2017-09-09 21:05:21,949 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=D:\Work\zookeeper\zookeeper-3.4.8\bin\..\build\classes;D:\Work\zookeeper\zookeeper-3.4.8\bin\..。。。。;
.
2017-09-09 21:05:21,960 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp2017-09-09 21:05:21,963 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2017-09-09 21:05:21,965 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Windows 7
2017-09-09 21:05:21,967 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2017-09-09 21:05:21,969 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=6.1
2017-09-09 21:05:21,973 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=Administrator
2017-09-09 21:05:21,975 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=C:\Users\Administrator
2017-09-09 21:05:21,977 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=D:\Work\zookeeper\zookeeper-3.4.8\bin
2017-09-09 21:05:21,983 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@7aec35a
Welcome to ZooKeeper!
2017-09-09 21:05:23,459 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2017-09-09 21:05:23,464 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@876] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
JLine support is enabled
[zk: 127.0.0.1:2181(CONNECTING) 0] 2017-09-09 21:05:23,548 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1299] - Session establishmentcomplete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x15e66bc75ec0000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

这样就安装完成了单节点zookeeper服务。

 

ZooKeeper:win7上安装单机及伪分布式安装

标签:height   example   apach   min   auth   val   多个   auto   技术   

原文地址:http://www.cnblogs.com/yy3b2007com/p/7499410.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!