Centos7环境下安装ZooKeeper单例模式

软件环境

操作系统: CentOS Linux release 7.9.2009

ZooKeeper: ZooKeeper v3.7.0

  编写博客的时间为2022年1月,此时ZooKeeper的最新的发布版本为3.7.0。

查找ZooKeeper最新版本

  打开ZooKeeper发布页(https://zookeeper.apache.org/releases.html),找到最近的正式版。

Centos7环境下安装ZooKeeper单例模式_zookeeper

releases.html

准备软件

基于wget下载

wget --no-check-certificate https://dlcdn.apache.org/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz

  由于没使用国内镜像链接进行下载,所以下载速度比较慢,可以采用其他方法自行下载。

解压tar.gz包

tar -zxvf apache-zookeeper-3.7.0-bin.tar.gz

部署单例模式

  本案例以最简单的单例模式为例。

cd apache-zookeeper-3.7.0-bin

使用默认配置

cp ./conf/zoo_sample.cfg ./conf/zoo.cfg

启动ZooKeeper

bin/zkServer.sh start

输出如下:

ZooKeeper JMX enabled by default
Using config: /root/desktop/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查看ZooKeeper状态

bin/zkServer.sh status

输出如下:

ZooKeeper JMX enabled by default
Using config: /root/desktop/apache-zookeeper-3.7.0-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone

使用ZkCli进行访问

bin/zkCli.sh -server 127.0.0.1:2181

网络配置

防火墙开放2181端口

firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --reload

可视化工具

ZooInspector

下载链接

https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip

启动软件

java -jar zookeeper-dev-ZooInspector.jar