docker安装zookeeper

Posted 卡卡罗特与琪琪相爱有了悟饭,悟天

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker安装zookeeper相关的知识,希望对你有一定的参考价值。

单机

  • docker pull zookeeper(拉取镜像)
    image
  • docker images (查看镜像)
    image
  • docker run -d -p 2181:2181 --name kaka-zookeeper --restart always 2b (启动镜像)
    image
  • docker ps(查看容器)
    image
  • docker exec -it d2 bash (进入容器)
    image
  • ./bin/zkCli.sh (启动zk客户端)
root@d2e3991366cc:/apache-zookeeper-3.7.0-bin# ./bin/zkCli.sh
Connecting to localhost:2181
2021-06-23 00:39:48,681 [myid:] - INFO  [main:Environment@98] - Client environment:zookeeper.version=3.7.0-e3704b390a6697bfdf4b0bef79e3da7a4f6bac4b, built on 2021-03-17 09:46 UTC
2021-06-23 00:39:48,688 [myid:] - INFO  [main:Environment@98] - Client environment:host.name=d2e3991366cc
2021-06-23 00:39:48,688 [myid:] - INFO  [main:Environment@98] - Client environment:java.version=11.0.11
2021-06-23 00:39:48,690 [myid:] - INFO  [main:Environment@98] - Client environment:java.vendor=Oracle Corporation
2021-06-23 00:39:48,690 [myid:] - INFO  [main:Environment@98] - Client environment:java.home=/usr/local/openjdk-11
2021-06-23 00:39:48,694 [myid:] - INFO  [main:Environment@98] - Client environment:java.class.path=/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/classes:/apache-zookeeper-3.7.0-bin/bin/../build/classes:/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/target/lib/*.jar:/apache-zookeeper-3.7.0-bin/bin/../build/lib/*.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-jute-3.7.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/zookeeper-3.7.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/snappy-java-1.1.7.7.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-log4j12-1.7.30.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/slf4j-api-1.7.30.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient_common-0.9.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/simpleclient-0.9.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-unix-common-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-native-epoll-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-transport-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-resolver-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-handler-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-common-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-codec-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/netty-buffer-4.1.59.Final.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/metrics-core-4.1.12.1.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/log4j-1.2.17.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jline-2.14.6.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-ajax-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-util-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-servlet-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-server-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-security-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-io-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jetty-http-9.4.38.v20210224.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-core-2.10.5.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/jackson-annotations-2.10.5.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/commons-cli-1.4.jar:/apache-zookeeper-3.7.0-bin/bin/../lib/audience-annotations-0.12.0.jar:/apache-zookeeper-3.7.0-bin/bin/../zookeeper-*.jar:/apache-zookeeper-3.7.0-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/conf:
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:java.compiler=<NA>
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:os.name=Linux
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:os.arch=amd64
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:os.version=3.10.0-957.21.3.el7.x86_64
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:user.name=root
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:user.home=/root
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:user.dir=/apache-zookeeper-3.7.0-bin
2021-06-23 00:39:48,695 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.free=21MB
2021-06-23 00:39:48,697 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.max=247MB
2021-06-23 00:39:48,699 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.total=29MB
2021-06-23 00:39:48,705 [myid:] - INFO  [main:ZooKeeper@637] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@4c70fda8
2021-06-23 00:39:48,713 [myid:] - INFO  [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2021-06-23 00:39:48,720 [myid:] - INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2021-06-23 00:39:48,763 [myid:] - INFO  [main:ClientCnxn@1726] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2021-06-23 00:39:48,811 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1171] - Opening socket connection to server localhost/127.0.0.1:2181.
2021-06-23 00:39:48,812 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1173] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2021-06-23 00:39:48,866 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1005] - Socket connection established, initiating session, client: /127.0.0.1:35988, server: localhost/127.0.0.1:2181
JLine support is enabled
2021-06-23 00:39:48,972 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1438] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x1000362a0b70000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
  • 测试zk是否启动成功(创建删除节点)
    image

集群

以上是关于docker安装zookeeper的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 安装 zookeeper(附 docker 安装 zookeeper)

docker 安装 zookeeper

Docker 安装Zookeeper

Docker 安装Zookeeper

docker笔记 kafka安装(zookeeper安装)

阿里云ECS云服务器基于docker安装zookeeper并且操作