linux 安装 zookeeper

本文档详细介绍了如何在Linux环境下安装单节点Zookeeper。包括下载、解压、配置环境变量及启动等步骤,并提供了配置文件的具体参数设置。

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

安装kafka之前需要安装zk,所以就分开了...

 

linux安装单节点的zookeeper还是相对简单点儿的,先简单记录一下;

 

下载使用的版本是 zookeeper-3.4.14.tar.gz..

 

解压

到/home/soft后,

tar -zxvf zookeeper-3.4.14.tar.gz

解压,修改配置文件: cp zoo.sample.cfg 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/soft/data/zookeeper/data
dataLogDir=/home/soft/data/zookeeper/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

其实也不需要改什么东西,直接用默认的配置即可...

 

配置环境变量

vi /etc/profile

添加

export ZOOK=/home/soft/zookeeper-3.4.14
source /etc/profile

使配置生效..

进入/home/soft/zookeeper-3.4.14/bin目录下

./zkServer.sh start

启动程序....

./zkServer.sh status

查看zk状态

./zkServer.sh stop 停止zk

程序是在的

### 安装配置Zookeeper教程 #### 单机部署 在Linux环境中安装Zookeeper,首先需下载并解压对应的安装包。对于离线环境可预先下载好安装包,在线环境下则可以直接通过网络获取最新版本的软件包[^2]。 ```bash tar -xvzf apache-zookeeper-3.7.1-bin.tar.gz ``` 完成解压之后进入`apache-zookeeper-3.7.1-bin`目录下的`conf`子目录编辑`zoo_sample.cfg`文件,并将其重命名为`zoo.cfg`作为主要配置文件使用[^1]。此步骤确保了基本设置适用于当前服务器环境。 为了使Zookeeper能够正常工作还需要指定数据存储路径以及日志保存位置。通常做法是在ZooKeeper根目录下建立名为`data`和`log`的新文件夹来分别承担上述职责[^5]: ```bash mkdir data mkdir log ``` 接着更新`zoo.cfg`中的相应条目指向新创建的数据与日志目录。例如: ```properties dataDir=/path/to/zookeeper/data dataLogDir=/path/to/zookeeper/log ``` 启动服务前确认所有更改无误后执行如下命令开启本地实例: ```bash bin/zkServer.sh start ``` #### 设置环境变量(可选) 为了让系统范围内都能识别到Zookeeper命令工具,可以在全局shell初始化脚本里追加自定义环境变量声明。具体操作方式有两种:一种是向`/etc/profile.d/worker_profile.sh`添加内容;另一种则是直接编辑`/etc/profile`文件[^4]。以下是后者的一个例子: ```bash export ZK_HOME=/home/software/zookeeper-3.6.3 export PATH=$ZK_HOME/bin:$PATH ``` 最后记得让新的环境变量生效: ```bash source /etc/profile ``` #### 使用Systemctl管理(可选) 如果希望利用systemd来进行进程控制的话,则要按照官方文档指示编写适合的服务单元文件。这一步骤并非强制性的但对于长期稳定运行来说很有帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值