zookeeper集群搭建设置
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
现在要做的是 单机伪集群(木有办法 没有那么多机器啊)
修改配置文件,在conf中
将zoo_sample.cfg文件复制一个重命名为zoo.cfg
修改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/doc/current/zookeeperStarted.html
http://zookeeper.apache.org/doc/current/index.html
http://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/
zookeeper集群搭建设置的更多相关文章
- kafka学习(二)-zookeeper集群搭建
zookeeper概念 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名 服务等.Zookeeper是h ...
- 分布式协调服务Zookeeper集群搭建
分布式协调服务Zookeeper集群搭建 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装jdk环境 1>.操作环境 [root@node101.yinzhengjie ...
- Kafka学习之(五)搭建kafka集群之Zookeeper集群搭建
Zookeeper是一种在分布式系统中被广泛用来作为:分布式状态管理.分布式协调管理.分布式配置管理.和分布式锁服务的集群.kafka增加和减少服务器都会在Zookeeper节点上触发相应的事件kaf ...
- zookeeper集群搭建及Leader选举算法源码解析
第一章.zookeeper概述 一.zookeeper 简介 zookeeper 是一个开源的分布式应用程序协调服务器,是 Hadoop 的重要组件. zooKeeper 是一个分布式的,开放源码的分 ...
- Zookeeper(二) zookeeper集群搭建 与使用
一.zookeeper集群搭建 鉴于 zookeeper 本身的特点,服务器集群的节点数推荐设置为奇数台.我这里我规划为三台, 为别为 hadoop01,hadoop02,hadoop03 1. ...
- ZooKeeper集群搭建过程
ZooKeeper集群搭建过程 提纲 1.ZooKeeper简介 2.ZooKeeper的下载和安装 3.部署3个节点的ZK伪分布式集群 3.1.解压ZooKeeper安装包 3.2.为每个节点建立d ...
- 【图文详解】Zookeeper集群搭建(CentOs6.3)
Zookeeper简介: Zookeeper是一个分布式协调服务,就是为用户的分布式应用程序提供协调服务的. A.zookeeper是为别的分布式程序服务的 B.Zookeeper本身就是一个分布式程 ...
- java 学习笔记(三)ZooKeeper集群搭建实例,以及集成dubbo时的配置 (转)
ZooKeeper集群搭建实例,以及集成dubbo时的配置 zookeeper是什么: Zookeeper,一种分布式应用的协作服务,是Google的Chubby一个开源的实现,是Hadoop的分布式 ...
- zookeeper 集群搭建 转
通过 VMware ,我们安装了三台虚拟机,用来搭建 zookeeper 集群,虚拟机网络地址如下: hostname ipaddress ...
随机推荐
- GridView.GridLines 属性
GridLines.None 不显示网格线. GridLines.Horizontal 仅显示水平网格线. GridLines.Vertical 仅显示垂直网格线. GridLines.Both 同时 ...
- eclipse使用技巧---使用正则表达式查找替换
1,Eclipse ctrl+f 打开查找框2,选中 Regular expressions (正则表达式) 去掉/* */(eclipse) /\*(.|[\r\n])*?\*/去掉/ ...
- Hibernate学习之hibernate执行顺序
Hibernate 执行的顺序如下: (1) 生成一个事务的对象,并标记当前的 Session 处于事务状态(注:此时并未启动数据库级事务). (2) 应用使用 s.save 保存对象,这个时候 ...
- linux杂记(十四)CAJ文档阅读方法
关于Linux下看CAJ文档的方法 前言:由于大四狗要写各种各样的综述,看各种论文,关于知网为何没有PDF下载,关于为何知网没有CAJ阅读器for linux的种种蛋疼问题,都不要问我. 说回正题,网 ...
- JS 操作日期
var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-???? ...
- 批量修改文件名java
package test0715; import java.io.File; public class FileRename {public static void main(String[] arg ...
- codeforces 632E. Thief in a Shop fft
题目链接 E. Thief in a Shop time limit per test 5 seconds memory limit per test 512 megabytes input stan ...
- fiddler--firefiox代理
修改端口:修改后重启才能生效
- 组合框里添加复选框的方法(使用勾选的假象,用图片代替而已,并非QT原生支持)
组合框可以看作是列表框和文本框的组合,因其占据的空间少,使用操作方便,常被界面设计人员用于界面开发设计中,在有限个输入的条件下,组合框常用来代替文本框,这样从用户使用角度来看,更趋人性化,所见即所得. ...
- codeforces #260 DIV 2 C题Boredom(DP)
题目地址:http://codeforces.com/contest/456/problem/C 脑残了. .DP仅仅DP到了n. . 应该DP到10w+的. . 代码例如以下: #include & ...