centos安装zookeeper,并集群配置

Posted syscn

tags:

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

所有机器操作都一样!

注:zookeeper配置集群时 需把防火墙关掉 或者暴露配置文件里配置的端口,

并且在dataDir目录下要有myid文件

 

1 下载

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

 

2 解压

tar -zxvf  zookeeper-3.4.10.tar.gz

 

3 修改配置文件

复制配置文件 zoo_sample.cfg 到zoo.cfg

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=/home/log/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# 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.purgeInterv
server.0=192.168.174.128:2888:3888
server.1=192.168.174.129:2888:3888

 

4  在  dataDir=/home/log/zookeeper  目录下新建 myid 文件

写入一个字符 0

保存。

 

5 启动 ./zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /home/service/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 

6 查看启动状态 ./zkServer.sh status

  

ZooKeeper JMX enabled by default
Using config: /home/service/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader

 

 

 

 

 zookeeper命令

./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}

start 启动

start-foreground 有启动过程的启动

stop 停止

restart 重启

status 查看启动状态

 





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

Zookeeper集群搭建记录 | 云计算[CentOS7] | Zookeeper集群搭建

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

CentOS 6.9安装配置ZooKeeper集群

zookeeper集群配置

centos7配置zookeeper本地模式与集群模式的详细教程

CentOS 7 安装 Zookeeper + Kafka 集群