`
IT_way
  • 浏览: 67797 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论
阅读更多
ZooKeeper是一种为分布式应用所设计的高可用、高性能且一致的开源协调服务,它提供了一项基本服务:分布式锁服务。为可靠的分布式服务提供了基础
本人安装版本:zookeeper-3.4.9。其他版本的,上apache官网下载。
zookeeper的安装比较简单
解压后目录



第一步 创建zoo.cfg
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=../data
# the port at which the clients will connect
clientPort=2171
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60


tickTime
时长单位为毫秒,为zk使用的基本时间度量单位。例如,1 * tickTime是客户端与zk服务端的心跳时间,2 * tickTime是客户端会话的超时时间。
tickTime的默认值为2000毫秒,更低的tickTime值可以更快地发现超时问题,但也会导致更高的网络流量(心跳消息)和更高的CPU使用率(会话的跟踪处理)。
clientPort
zk服务进程监听的TCP端口,默认情况下,服务端会监听2181端口。
dataDir
无默认配置,必须配置,用于配置存储快照文件的目录。如果没有配置dataLogDir,那么事务日志也会存储在此目录。
第三步 加入集群
zoo.cfg内容增加集群主机内容。
server.x中x为主机集群中唯一的标识
server.1=192.168.42.25:2871:2872
server.2=192.168.42.26:2871:2872
server.3=192.168.42.102:2871:2872

2871为leader与follower通信端口;2872为参与竞选leader的通信端口
第四步 创建myid文件
路径为配置../data。创建myid文件。填入主机对应的server.x的x值。
启动
./zkServer.sh start 后台进行运行
./zkServer.sh start-foreground 前台运行,便于查看输入日志
客户端连接
bin/zkCli.sh 连接本机服务
bin/zkCli.sh -server 192.168.0.1:2171
连接不同的主机服务。多个主机用英文逗号隔开
日志文件输出到logs文件夹
bin文件夹中,zkEnv.sh文件,修改内容

参考文献
http://blog.csdn.net/lihao21/article/details/51778255
http://blog.csdn.net/shirdrn/article/details/7183503
http://blog.csdn.net/hengyunabc/article/details/19006911
https://www.cnblogs.com/wuxl360/p/5817471.html
  • 大小: 17.8 KB
  • 大小: 5.7 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics