CentOS下安装zookeeper

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS下安装zookeeper相关的知识,希望对你有一定的参考价值。

Linux下安装Zookeeper集群步骤

(1) 下载zookeeper安装包

  地址:http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

(2) 解压安装包并放置在对应的路径下

  解压对应文件到对应的路径下,本文将zookeeper解压到/soft/zk路径下,并在zk路径下建立 dataDir与dataLogDir路径

  cd /soft/zk

  tar -xvf zookeeper-xxx.tar.gz

  mkdir dataDir

  mkdir dataLogDir

 

(3) 配置zookeeper的配置文件

  对zookeeper进行配置

  cd /soft/zk/zookeeper-xxx/conf

  cp zoo-sample.cfg zoo.cfg

  vim 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=/soft/zk/dataDir dataLogDir=/soft/zk/dataLogDir # the port at which the clients will connect clientPort=2181 server.1=192.168.1.111:2888:3888 server.2=192.168.1.112:2888:3888 server.3=192.168.1.113:2888:3888

这里对zookeeper服务器进行配置,这里需要将myid与对应的服务器编号对应

 

(4) 设置zookeeper对应的myid文件

  cd /soft/zk/dataDir

  vim myid

  将服务器编号放入

 

(5) 启动zookeeper服务

  cd /soft/zk/zookeeper-xxx/bin

  sh zkServer.sh start

  启动服务,注意查看zookeeper.out这个日志输出,可以看到问题点

 

(6) 验证zookeeper是否正常启动

  cd /soft/zk/zookeeper-xxx/bin

  sh zkServer.sh status

  sh zkCli.sh -server 192.168.1.111:2181

 

(7) 查询zookeeper服务器对应的主从关系状态

  cd /soft/zk/zookeeper-xxx/bin

  sh zkServer.sh status

以上是关于CentOS下安装zookeeper的主要内容,如果未能解决你的问题,请参考以下文章

centos下安装ZooKeeper

centos 7下安装配置zookeeper

linux centos下安装zookeeper(单机)

Zookeeper集群安装(CentOS 7环境下)

CentOS下的ZooKeeper集群搭建

centos7安装与配置zookeeper