zookeeper下载安装配置

it2026-08-20  5

集群配置前提:Java环境

下载

zookeeper-3.4.13

链接:https://pan.baidu.com/s/1XWIEo_kEmNQx7hlcQ31OSw  提取码:d5rs 

安装

在/usr/local中新建zookeeper目录

下载的安装包放在该目录下

解压

tar -zxvf /usr/local/zookeeper/zookeeper-3.4.13.tar.gz

解压后目录如下:

配置

1、修改conf下的zoo_sample.cfg 为zoo.cfg

2、在根目录下创建logs和data目录

修改后配置如下

# 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=/usr/local/zookeeper/zookeeper-3.4.13/data # 日志存放的位置 dataLogDir=/usr/local/zookeeper/zookeeper-3.4.13/logs # 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.purgeInterval=1 # 集群的配置,后面为你的 ip,后面有节点依次往下面排 server.1=192.168.1.11:2888:3888 server.2=192.168.1.17:2888:3888 server.3=192.168.1.18:2888:3888

注意ip换成你自己的IP

3、修改日志文件

Zookeeper 默认会将控制台信息输出到启动路径下的 zookeeper.out 中,通过如下方法,可以让 Zookeeper 输出按尺寸切分的日志文件: 修改 conf/log4j.properties 文件,将 zookeeper.root.logger=INFO, CONSOLE 改为 zookeeper.root.logger=INFO, ROLLINGFILE 修改bin/zkEnv.sh文件,将 ZOO_LOG4J_PROP="INFO,CONSOLE" 改为 ZOO_LOG4J_PROP="INFO,ROLLINGFILE"

其他服务器也按照这样的格式修改

4、创建myid文件

cd /usr/local/zookeeper/zookeeper-3.4.13/data

创建myid文件

文件内容如下

1 #上面的zoo.cfg中文件的server中的数字是几就在该服务上面配置几

5、启动服务

切换到bin目录下

./zkServer.sh start #启动

./zkServer.sh status #查看状态

./zkServer.sh stop #停止

6、启动成功

7、验证集群可用性

我这里选用3台服务器,会通过选举出来leader,暂停leader后,会重新选举,即是代表启动成功

 

至此zookeeper集群搭建完毕,具体配置文件信息自行百度

最新回复(0)