CentOS下单机安装配置ZooKeeper

下载安装ZooKeeper

官方网站:http://zookeeper.apache.org/
清华镜像:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper

1
2
3
4
# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.5.6/apache-zookeeper-3.5.6-bin.tar.gz
# tar -xf apache-zookeeper-3.5.6-bin.tar.gz -C /usr/local/ //解压
# mv /usr/local/apache-zookeeper-3.5.6-bin /usr/local/zookeeper
# mkdir /data/zookeeper //创建数据存储路径

修改配置文件

1
2
3
4
5
# cd /usr/local/zookeeper/conf/
# cp zoo_sample.cfg zoo.cfg
# vim zoo.cfg
dataDir=/data/zookeeper
clientPort=2188

添加环境配置

1
2
3
4
5
# vim /etc/profile
export ZOOKEEPER_HOME=/usr/local/zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
# source /etc/profile

ZooKeeper启动常用命令

1、启动 zookeeper 服务:

1
2
3
4
# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

2、查询 zookeeper 状态:

1
2
3
4
5
# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone

3、关闭 zookeeper 服务:

1
zkServer.sh stop

4、重启 zookeeper 服务:

1
# zkServer.sh restart

5、开机启动配置

开机启动使用zookeeper的用户启动命令(正式环境不建议使用root,这里使用的是一个zookeeper的用户启动)

1
su - zookeeper -c '/usr/local/zookeeper/bin/zkServer.sh start'

Dubbo配置

1
<dubbo:registry address="zookeeper://xxx.xxx.xxx.xxx:2188?backup=aaa.aaa.aaa.aaa:2188,bbb.bbb.bbb.bbb:2188"/>

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :