Docker快速安装Zookeeper的详细教程

时间:2022-01-16 05:23:39

docker快速安装zookeeper

换了公司后很久没用过zookeeper,最近因为在搞elastic-job需要用到,这里简单记录下用docker搭建过程,下一篇会讲解怎么快速搭建集群。这里不会细讲如何搭建docker,如果想了解docker的朋友可以查看我之前写的docker系列文章。

搜索zookeeper镜像

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
evans-macbook-pro:tool evan$ docker search zookeeper
name                               description                                     stars     official   automated
zookeeper                          apache zookeeper is an open-source server wh…   1099      [ok]      
jplock/zookeeper                   builds a docker image for zookeeper version …   165                  [ok]
wurstmeister/zookeeper                                                             149                  [ok]
mesoscloud/zookeeper               zookeeper                                       73                   [ok]
bitnami/zookeeper                  zookeeper is a centralized service for distr…   60                   [ok]
digitalwonderland/zookeeper        latest zookeeper - clusterable                  23                   [ok]
mbabineau/zookeeper-exhibitor                                                      23                   [ok]
tobilg/zookeeper-webui             docker image for using `zk-web` as zookeeper…   15                   [ok]
debezium/zookeeper                 zookeeper image required when running the de…   14                   [ok]
confluent/zookeeper                [deprecated - please use confluentinc/cp-zoo…   13                   [ok]
31z4/zookeeper                     dockerized apache zookeeper.                    9                    [ok]
thefactory/zookeeper-exhibitor     exhibitor-managed zookeeper with s3 backups …   6                    [ok]
engapa/zookeeper                   zookeeper image optimised for being used int…   3                   
emccorp/zookeeper                  zookeeper                                       2                   
harisekhon/zookeeper               apache zookeeper (tags 3.3 - 3.4)               2                    [ok]
paulbrown/zookeeper                zookeeper on kubernetes (petset)                1                    [ok]
openshift/zookeeper-346-fedora20   zookeeper 3.4.6 with replication support        1                   
perrykim/zookeeper                 k8s - zookeeper  ( forked k8s contrib )         1                    [ok]
josdotso/zookeeper-exporter        ref: https://github.com/carlpett/zookeeper_e…   1                    [ok]
duffqiu/zookeeper-cli                                                              1                    [ok]
pravega/zookeeper-operator         kubernetes operator for zookeeper               0                   
phenompeople/zookeeper             apache zookeeper is an open-source server wh…   0                    [ok]
dabealu/zookeeper-exporter         zookeeper exporter for prometheus               0                    [ok]
midonet/zookeeper                  dockerfile for a zookeeper server.              0                    [ok]
humio/zookeeper-dev                zookeeper build with zulu jvm.

拉取官方zookeeper

默认拉取最新版本

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
evans-macbook-pro:tool evan$ docker pull zookeeper
using default tag: latest
latest: pulling from library/zookeeper
b4d181a07f80: pull complete
3ee45ae97306: pull complete
567d410fadc4: pull complete
891cdfaa81b9: pull complete
7d811fb3c718: pull complete
259c7b233169: pull complete
19a00500c36e: pull complete
907b63c43842: pull complete
digest: sha256:d5965c84bbfc33f9a718d9eedec0137dd91e2298e213379549e75ebb0fa49d51
status: downloaded newer image for zookeeper:latest
docker.io/library/zookeeper:latest

查询本地镜像

?
1
2
3
4
5
6
7
8
evans-macbook-pro:tool evan$ docker image ls
repository            tag       image id       created         size
zookeeper             latest    50d238989423   33 hours ago    269mb
mysql                 latest    c0cdc95609f1   6 weeks ago     556mb
jenkins/jenkins       latest    22c34b2deb6c   15 months ago   619mb
postgres              latest    cf879a45faaa   17 months ago   394mb
evan/centos           dev       631b0bcb4bcc   18 months ago   191mb
truevoly/oracle-12c   latest    21789d4d876f   2 years ago     5.7gb

运行zookeeper

指定端口为2181,容器名称为zookeeper

?
1
2
evans-macbook-pro:tool evan$ docker run -d -p 2181:2181 --name zookeeper --restart always 50d238989423
548d103dabaa3c453f48a55f8dfeb3d241a60ad27fe0f11a114534ae5464b3fe

查看zookeeper容器id

?
1
2
3
evans-macbook-pro:tool evan$ docker ps
container id   image          command                  created         status         ports                                                                     names
548d103dabaa   50d238989423   "/docker-entrypoint.…"   3 minutes ago   up 3 minutes   2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, :::2181->2181/tcp, 8080/tcp   zookeeper

通过容器id进入zookeeper

?
1
2
evans-macbook-pro:tool evan$ docker exec -it 548d103dabaa bash
root@548d103dabaa:/apache-zookeeper-3.7.0-bin#

执行zookeeper启动命令

?
1
2
3
4
5
6
root@548d103dabaa:/apache-zookeeper-3.7.0-bin# ./bin/zkcli.sh
connecting to localhost:2181
2021-06-27 15:15:06,993 [myid:] - info  [main:environment@98] - client environment:zookeeper.version=3.7.0-e3704b390a6697bfdf4b0bef79e3da7a4f6bac4b, built on 2021-03-17 09:46 utc
 ##...省略...
 watchedevent state:syncconnected type:none path:null
[zk: localhost:2181(connected) 0]

下载zookeeper可视化控制台

这里我随便在github下了一个 ,供大家参考

https://github.com/hellosix/zookeeper-manager/archive/refs/heads/master.zip

运行zookeeper-manager代码

导入idea,直接启动zookeepermanagerapplication,默认端口是8081

Docker快速安装Zookeeper的详细教程

连接zookeeper服务

这里添加一个新的服务,输入127.0.0.1:2181

Docker快速安装Zookeeper的详细教程

到此这篇关于docker快速安装zookeeper的文章就介绍到这了,更多相关docker安装zookeeper内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/Evan_Leung/article/details/118291697