zookeeper安装
时间: 2023-10-31 11:57:24 浏览: 102
以下是Zookeeper的安装步骤:
1. 下载Zookeeper
在Zookeeper官网上下载最新的Zookeeper压缩包,或者从镜像站点下载。下载地址:https://zookeeper.apache.org/releases.html
2. 解压Zookeeper
将下载的Zookeeper压缩包解压到指定目录,例如 /opt/zookeeper
```
tar -zxvf zookeeper-3.6.2.tar.gz -C /opt/zookeeper
```
3. 配置Zookeeper
进入Zookeeper的conf目录,复制一份默认配置文件zoo_sample.cfg,并将其重命名为zoo.cfg。
```
cd /opt/zookeeper/conf
cp zoo_sample.cfg zoo.cfg
```
编辑zoo.cfg文件,修改以下配置:
```
dataDir=/opt/zookeeper/data
clientPort=2181
```
其中,dataDir表示Zookeeper的数据存储目录,clientPort表示客户端连接Zookeeper的端口,默认为2181。
4. 启动Zookeeper
进入Zookeeper的bin目录,启动Zookeeper。
```
cd /opt/zookeeper/bin
./zkServer.sh start
```
如果出现以下提示,则表示Zookeeper启动成功。
```
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
```
5. 停止Zookeeper
进入Zookeeper的bin目录,停止Zookeeper。
```
cd /opt/zookeeper/bin
./zkServer.sh stop
```
如果出现以下提示,则表示Zookeeper已经停止。
```
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
```
阅读全文