Skip to content

Zookeeper知识体系

Centos7安装与配置Zookeeper

Zookeeper下载地址:http://mirror.bit.edu.cn/apache/zookeeper/

# 使用yum安装java环境
yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 -y

# 下载并解压Zookeeper,并移动到合理到位置
tar -xf apache-zookeeper-3.5.5-bin.tar.gz
mv apache-zookeeper-3.5.5-bin /opt/zookeeper3.5.5

# 配置系统环境变量
echo "export ZOOKEEPER_HOME=/opt/zookeeper3.5.5" >> /etc/profile
echo "export PATH=$PATH:$ZOOKEEPER_HOME/bin" >> /etc/profile
source /etc/profile

配置Zookeeper

# 复制配置文件
cp /opt/zookeeper3.5.5/conf/zoo_sample.cfg /opt/zookeeper3.5.5/conf/zoo.cfg

# 修改配置文件
vim /opt/zookeeper3.5.5/conf/zoo.cfg

# tickTime=2000
# initLimit=10
# syncLimit=5
# dataDir=/tmp/zookeeper
# clientPort=2181

启动Zookeeper

zkServer.sh start

Zookeeper客户端

# 启动客户端
zkCli.sh

# 以下操作在客户端交互窗口中执行
h:查看帮助
ls /:查看根目录节点
stat /:查看根节点状态
get /:查看根节点数据和详情
quit:退出