zookeeper 官网:http://zookeeper.apache.org/ 现在最新版本是 3.4.6 ,但是这个版本我没有运行起来,可能是那配置出现问题了,现在我用的是3.4.5 http://apache.fayea.com/apache-mirror/zookeeper/zookeeper-3.4.5/

环境:windows 8.1 、zookeeper3.4.5

现在要做的是 单机伪集群(木有办法 没有那么多机器啊)

  1. 修改配置文件,在conf中

    将zoo_sample.cfg文件复制一个重命名为zoo.cfg

  2. 修改zoo.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=/tmp/zookeeper
# 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

修改后:

# 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=E:/zookeepercluster/servcer001/data
dataLogDir=E:/zookeepercluster/servcer001/logs
# 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.1=localhost:8881:7771
server.2=localhost:8882:7772
#server.3=192.168.192.7:8883:7773
#server.4=192.168.192.7:8884:7774
#server.5=192.168.192.7:8885:7775

主要是在下边添加几个服务器的ip地址,因为我的都是本机,所以我这都是一样的地址。

参数解释:

  • tickTime:发送心跳的间隔时间,单位:毫秒

  • dataDir:zookeeper保存数据的目录。

  • clientPort:客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。

  • initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper 服务器的客户端,而是 Zookeeper 服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 5个心跳的时间(也就是 tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是 5*2000=10 秒

  • syncLimit:这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒

  • server.A=B:C:D:其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper 实例通信端口号不能一样,所以要给它们分配不同的端口号。

3. 在data下面创建一个myid文件,内容为1

这个内容对应的是这个zookeeper的顺序,第一个zookeeper就是1,第二个zookeeper就是2,没有先后顺序,只是不能重复。

这个最好是和 server.x 中的x对应

依次修改配置文件 简历server02,server03,server04节点 目录结构如下:

├── server001

│   ├── data

│   ├── logs

│   └── zookeeper-3.4.5

├── server002

│   ├── data

│   ├── logs

│   └── zookeeper-3.4.5

├── server003

│   ├── data

│   ├── logs

│   └── zookeeper-3.4.5

├── server004

│   ├── data

│   ├── logs

│   └── zookeeper-3.4.5

└── server005

├── data

├── logs

└── zookeeper-3.4.5

这样就配置好了,windows下的单机伪集群。

下面就是启动了:

进入bin下双击 :zkServer.cmd

报这个错误是因为还有节点没有启动起来,都启动了就会不报错了

运行 zkServer.cmd status 可以查看节点的角色  是leader 还是follower

这样一个伪集群就成功了,如果有不对的地方希望大家批评指正,ORZ。

参考文章:

http://www.cnblogs.com/haippy/archive/2012/07/19/2599989.html

http://zookeeper.apache.org/

http://zookeeper.apache.org/doc/current/zookeeperStarted.html

http://zookeeper.apache.org/doc/current/index.html

http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/

https://my.oschina.net/closeday/blog/297225

https://my.oschina.net/closeday/blog/297225相关推荐

  1. Redmine-4.1.1 异步邮件通知如何配置(使用smtp方式,支持TLS):https://my.oschina.net/SamXIAO/blog/4973213

    https://www.redmine.org/issues/30068 https://my.oschina.net/SamXIAO/blog/4973213

  2. solr:关于dismax的使用情况(转:https://my.oschina.net/momohuang/blog/145379)

    首先说说 dismax这个功能,它是基于lucene的DisjunctionMaxQuery去 扩展的,就是说,实际上用到的就是DisjunctionMaxQuery的这个查询类.查询api,可以知道 ...

  3. 异常:fatal: unable to access 'https://git.oschina.net/pcmpcs/library.git/': Could not resolve host...

    git  fork项目时出现的异常. 原因: 我以前用的是ssh地址做的远程通信地址,而这次是用的是https,因为很久没用,所以忘记了以前是用ssh的了. 解决方案一:复制ssh协议的地址,然后再关 ...

  4. 在线代码格式化网址:https://tool.oschina.net/codeformat/xml

    当遇到问题需要我们排查查日志的时候,会遇到日志打印混乱的情况 这时梳理会很困难,需要在线"洗日志",将其格式化成各种格式 网址:https://tool.oschina.net/c ...

  5. AngularJS中service,factory,provider的区别(转载:http://my.oschina.net/tanweijie/blog/295067)...

    目录[-] 一.service引导 二.service 1.factory() ‍2.service()‍ ‍3.provider()‍‍ 一.service引导 刚开始学习Angular的时候,经常 ...

  6. 漫谈C语言及如何学习C语言--http://my.oschina.net/apeng/blog/137911

    目录:[ - ] 为什么要学习C语言? C语言学习方法 1,参考书籍 2,动手实验环境搭建 3,网络资源 附录 一些有用的C语言网络资源: 一些值得关注及研究的C语言相关项目: 一些C语言编程时可以使 ...

  7. PHP闭包(Closure)初探(转载 http://my.oschina.net/melonol/blog/126694?p=2#comments)

    匿名函数 提到闭包就不得不想起匿名函数,也叫闭包函数(closures),貌似PHP闭包实现主要就是靠它.声明一个匿名函数是这样: ? 1 2 3 $func = function() {       ...

  8. Ubuntu下装QQ2014(http://my.oschina.net/oscfox/blog/315951)

    QQ登陆界面: QQ登陆之后: 1.首先我们需要下载一个 deb的 Wine QQ安装包 qq2014官方下载:http://www.longene.org/download/WineQQ2013SP ...

  9. 工欲利其器: sqlyog 智能执行功能详解.(http://my.oschina.net/phpnew/blog/151194)

    优秀的sqlyog, 我深深地感到不安及自责, 盗版用户多年, 多少有点感觉过意不去, 希望富二代们能够支持正版吧. 最近osc还在讨论什么是php大牛, 以前看过帖子, 说得非常贴切. phper, ...

最新文章

  1. 从YARN迁移到k8s,滴滴机器学习平台二次开发是这样做的
  2. 【Android 启动过程】Activity 启动源码分析 ( AMS -> ActivityThread、AMS 线程阶段 二 )
  3. Java(CS)请求分流
  4. 荣耀X8碎屏2020-05-14
  5. datalistcp.class.php,Web_PHP_DedeCMS_datalistcp.class.php 动态分页类使用案例;
  6. oracle 5种索引方式,MySQL使用索引的几种方式
  7. YBTOJ:前缀数组(KMP)
  8. HDU 6188 Duizi and Shunzi
  9. 三次握手和四次挥手图解_详解 TCP 连接的“三次握手”与“四次挥手”
  10. linux查看磁盘io性能
  11. Ceilometer - Install the API behind mod_wsgi
  12. Java设计模式系列之迭代器模式
  13. unity3d的下载与安装
  14. 「新手指南」如何在Mac上格式化U盘和移动硬盘?
  15. 6目摄像头照片球面投影变换拼接全景图片
  16. 以史为镜——台积电发展史
  17. python创建一个列表、依次存放每个月对应的天数_python计算天数
  18. HT单片机笔记1-时钟配置(2022/2/20)
  19. 安川机器人编程指令含义
  20. 技嘉GA-B85-HD3(2.0)加装NVME固态硬盘

热门文章

  1. 英语老师不想让你知道的一些网站 , 想学英语的就进
  2. Docker学习文档(个人向)
  3. 服务器租用和服务器托管有什么区别
  4. JS初学小练(兔子繁殖问题)
  5. IT国内外的免费学习网站
  6. 原命题等价于逆否命题。用于理解素数判断6X法
  7. c++网络开发必备dll---ssleay32.dll和libeay32.dll
  8. collector是什么意思中文翻译_collector是什么意思_ collector的翻译_音标_读音_用法_例句_爱词霸在线词典...
  9. 【读后感】让创新野蛮生长
  10. 使用oyente智能检测工具总结