zookeeper安装

一、简介

首先,我们来看下上面是zookeeper?

根据官方的说明:zookeeper是一个分布式的应用程序协调服务(中心)。通俗点来讲,就是调度中心。具体原文如下:

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them ,which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.

有兴趣可以直接访问:【zookeeper官网】进行查看更多信息。

二、Zookeeper环境搭建
【1】准备工作
1、下载安装包,具体地址见官网。
2、安装虚拟机或cent os等操作系统。
【2】 安装
1、上传安装包至自定义路径,并使用命令解压到某一路径(tar -zxvf zookeeper-3.4.6.tar.gz)
2、切换到解压后目录,找到conf目录,并拷贝zoo_sample.cfg文件为zoo.cfg
3、修改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 anacknowledgement
 
syncLimit=5
 
# the directory where the snapshot isstored. //镜像数据位置
 
dataDir=D:\\data\\zookeeper
 
#日志位置
 
dataLogDir=D:\\logs\\zookeeper
 
# the port at which the clients willconnect 客户端连接的端口
 
clientPort=2181
4、如果是集群环境,则需要添加集群地址的配置,具体如下:
#这个是zookeeper集群环境的节点配置,前面是节点名后面是ip或者hostname
server.1=data1:2888:3888
server.2=data2:2888:3888
server.3=data3:2888:3888
然后在对应的data文件夹下(如上面的 dataDir=D:\\data\\zookeeper )创建文件,myid(即文本文件,不管后缀名)。文件内容为当前文件所在的节点编号。
需要注意的是:
    a、zoo.cfg每个集群节点机器都需要,还有myid文件;
    b、检查ip是否正确。
注意:centos7系统可以使用下面的命令永久改变主机名。
1)查看主机名
hostnamectl status
2)修改主机名
sudo hostnamectl set-hostname newhostname
5、异常处理
(1)INFO zookeeper.ZooKeeper: Session: 0x0 closed
可能原因:
        1、zookeeper没有启动。
        2、zookeeper有“选举领导者”机制,当 失效节点占比过半 时,将停止工作。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值