目录

                1、zookeeper下载地址

                2、安装JDK

                3、安装Zookeeper

                4、启动zookeeper服务

                5、连接 zookeeper 集群


1、zookeeper下载地址

        zookeeper官网

2、安装JDK

        CentOS 7.8安装JDK

3、安装Zookeeper

CentOS 版本服务器IPzookeeper
CentOS 7.8  server01192.168.19.11apache-zookeeper-3.8.0
CentOS 7.8server02192.168.19.12apache-zookeeper-3.8.0
CentOS 7.8server03192.168.19.13apache-zookeeper-3.8.0

        使用wget直接下载zookeeper,下载完成后,使用tar命令解压 zookeeper ,通过 -C 指定zookeeper 的安装目录。

        解压完成后,在 zookeeper 根目录下创建 data 目录,存储 zookeeper 的数据文件。

[root@server01 software]# wget --no-check-certificate \
https://dlcdn.apache.org/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz

[root@server01 software]# tar -zxvf apache-zookeeper-3.8.0.tar.gz -C /usr/local/

[root@server01 software]# cd /usr/local/apache-zookeeper-3.8.0/

        重命名zookeeper的文件夹,apache-zookeeper-3.8.0-bin 重命名 为 zookeeper-3.8.0 ,进入zookeeper-3.8.0 ,在 zookeeper 根目录下面创建data 目录。

[root@server01 software]# cd /usr/local/
[root@server01 local]# ls
apache-zookeeper-3.8.0-bin  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@server01 local]# mv apache-zookeeper-3.8.0-bin/ zookeeper-3.8.0
[root@server01 local]# cd zookeeper-3.8.0/
[root@server01 zookeeper-3.8.0]# mkdir data
[root@server01 zookeeper-3.8.0]# ls

        修改zookeeper配置文件,将zoo_sample.cfg 重命名为 zoo.cfg ,修改 zoo.cfg 配置文件

[root@server01 zookeeper-3.8.0]# cd conf
[root@server01 conf]# mv conf/zoo_sample.cfg conf/zoo.cfg

        修改 zoo.cfg 文件

# zookeeper 数据存储地址
dataDir=/usr/local/zookeeper-3.8.0/data

# zookeeper 集群地址
server.1=192.168.19.11:2888:3888
server.2=192.168.19.12:2888:3888
server.3=192.168.19.13:2888:3888

# admin.server端口
admin.serverPort=8888

        在配置文件,配置 admin.serverPort,默认是8080,避免8080端口被占用,无法启动,将zookeeper的admin.server 启动端口修改成不常用的端口。

        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=/usr/local/zookeeper-3.8.0/data
# 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.
#
# https://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

admin.serverPort=8888

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

server.1=192.168.19.11:2888:3888
server.2=192.168.19.12:2888:3888
server.3=192.168.19.13:2888:3888
    在每个 zookeeper 的 data 目录下创建一个 myid 文件,内容分别是 1、2、3,对应 zoo.cfg 文件中的 server.1、server.2、server.3 三台服务器。

        每台服务器zookeeper根目录分别执行以先命令

        server1执行:

echo 1 > data/myid

        server2执行: 

echo 2 > data/myid

        server3执行: 

echo 3 > data/myid

        关闭防火墙

[root@server01 zookeeper-3.8.0]# systemctl stop firewalld
[root@server01 zookeeper-3.8.0]# systemctl status firewalld 

        防火墙的开启、关闭、禁用命令

       1. 设置开机启用防火墙:systemctl enable firewalld.service

        2. 设置开机禁用防火墙:systemctl disable firewalld.service

        3. 启动防火墙:systemctl start firewalld

        4. 关闭防火墙:systemctl stop firewalld

        5. 检查防火墙状态:systemctl status firewalld 

4、启动zookeeper服务

        启动 zookeeper :

        zkServer.sh start

        查看 zookeeper 状态:

        zkServer.sh status

        停止 zookeeper :

        zkServer.sh stop

 

5、连接 zookeeper 集群

        使用 PrettyZoo 连接 zookeeper

        PrettyZoo GitHub地址:GitHub PrettyZoo

        PrettyZoo 下载地址:Releases · vran-dev/PrettyZoo · GitHub

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐