linux 安装zookeeper

本文介绍如何安装配置ZooKeeper 3.4.6版本,包括下载安装包、配置文件zoo.cfg的设置、创建必要的数据与日志目录,以及启动、查看状态、停止和重启服务的命令。同时提供了设置ZooKeeper开机自启的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自行下载安装包 zookeeper-3.4.6.tar.gz

wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

安装步骤:

1.解压 zookeeper-3.4.6.tar.gz /root 目录下

2.在目录 /root/zookeeper-3.4.6.tar.gz/conf 中新增文件 zoo.cfg

3.创建目录 /root/zookeeper-3.4.6/data

4.创建目录 /root/zookeeper-3.4.6/logs

5.执行启动命令 sh zkServer.sh start

 

ZooKeeper服务命令:

     在准备好相应的配置之后,可以直接通过zkServer.sh 这个脚本进行服务的相关操作

  • 1. 启动ZK服务:       sh bin/zkServer.sh start
  • 2. 查看ZK服务状态: sh bin/zkServer.sh status
  • 3. 停止ZK服务:       sh bin/zkServer.sh stop
  • 4. 重启ZK服务:       sh bin/zkServer.sh restart

 

设置开机启动

编辑文件: vi /etc/rc.local

追加内容: /root/zookeeper-3.4.6/bin/zkServer.sh start

提升权限:chmod +x /etc/rc.local

保存文件结束

 

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=/root/zookeeper-3.4.6/data
dataLogDir=/root/zookeeper-3.4.6/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=2
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=1
#2888,3888 are election port
#server.1=192.168.0.101:2888:3888
#server.2=192.168.0.102:2888:3888
#server.3=192.168.0.103:2888:3888

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值