前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker 中启动 ZooKeeper

Docker 中启动 ZooKeeper

作者头像
wsuo
发布2020-09-28 11:39:15
2.8K0
发布2020-09-28 11:39:15
举报
文章被收录于专栏:技术进阶之路

2181 端口启动 zookeeper 进程:

代码语言:javascript
复制
# 查看镜像的 ID 
[root@shuozg ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
zookeeper           latest              36b7f3aa2340        4 days ago          252MB
# 启动 zp
[root@shuozg ~]# docker run -d -p 2181:2181 --name some-zookeeper --restart always 36b7f3aa2340
64e866e1c417d3be8becbc28c3d4c40f878299133cc2e744d21d4dd365e6bdaf
代码语言:javascript
复制
# 获取容器 ID
[root@shuozg ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS
                                 NAMES
64e866e1c417        36b7f3aa2340        "/docker-entrypoint.…"   2 minutes ago       Up 2 minutes        2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp   some-zookeeper

# 启动 zookeeper 的命令行
[root@shuozg ~]# docker exec -it 64e866e1c417 bash
root@64e866e1c417:/apache-zookeeper-3.6.2-bin# ./bin/zkCli.sh
Connecting to localhost:2181
2020-09-27 04:46:08,256 [myid:] - INFO  [main:Environment@98] - Client environment:zookeeper.version=3.6.2--803c7f1a12f85978cb049af5e4ef23bd8b688715, built on 09/04/2020 12:44 GMT
2020-09-27 04:46:08,259 [myid:] - INFO  [main:Environment@98] - Client environment:host.name=64e866e1c417
2020-09-27 04:46:08,259 [myid:] - INFO  [main:Environment@98] - Client environment:java.version=11.0.8
2020-09-27 04:46:08,263 [myid:] - INFO  [main:Environment@98] - Client environment:java.vendor=N/A
2020-09-27 04:46:08,263 [myid:] - INFO  [main:Environment@98] - Client environment:java.home=/usr/local/openjdk-11
2020-09-27 04:46:08,263 [myid:] - INFO  [main:Environment@98] - Client environment:java.class.path=/apache-zookeeper-3.6.2-bin/bin/../zookeeper-server/target/classes:/apache-zookeeper-3.6.2-bin/bin/../build/classes:/apache-zookeeper-3.6.2-bin/bin/../zookeeper-server/target/lib/*.jar:/apache-zookeeper-3.6.2-bin/bin/../build/lib/*.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/zookeeper-prometheus-metrics-3.6.2.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/zookeeper-jute-3.6.2.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/zookeeper-3.6.2.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/snappy-java-1.1.7.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/slf4j-api-1.7.25.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/simpleclient_servlet-0.6.0.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/simpleclient_hotspot-0.6.0.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/simpleclient_common-0.6.0.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/simpleclient-0.6.0.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-transport-native-unix-common-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-transport-native-epoll-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-transport-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-resolver-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-handler-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-common-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-codec-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/netty-buffer-4.1.50.Final.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/metrics-core-3.2.5.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/log4j-1.2.17.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/json-simple-1.1.1.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jline-2.14.6.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jackson-databind-2.10.3.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jackson-core-2.10.3.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/jackson-annotations-2.10.3.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/commons-lang-2.6.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/commons-cli-1.2.jar:/apache-zookeeper-3.6.2-bin/bin/../lib/audience-annotations-0.5.0.jar:/apache-zookeeper-3.6.2-bin/bin/../zookeeper-*.jar:/apache-zookeeper-3.6.2-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/conf:
2020-09-27 04:46:08,263 [myid:] - INFO  [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2020-09-27 04:46:08,263 [myid:] - INFO  [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:java.compiler=<NA>
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:os.name=Linux
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:os.arch=amd64
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:os.version=3.10.0-514.26.2.el7.x86_64
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:user.name=root
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:user.home=/root
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:user.dir=/apache-zookeeper-3.6.2-bin
2020-09-27 04:46:08,264 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.free=21MB
2020-09-27 04:46:08,267 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.max=247MB
2020-09-27 04:46:08,267 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.total=29MB
2020-09-27 04:46:08,279 [myid:] - INFO  [main:ZooKeeper@1006] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@6166e06f
2020-09-27 04:46:08,286 [myid:] - INFO  [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2020-09-27 04:46:08,299 [myid:] - INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2020-09-27 04:46:08,316 [myid:] - INFO  [main:ClientCnxn@1716] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2020-09-27 04:46:08,356 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1167] - Opening socket connection to server localhost/127.0.0.1:2181.
2020-09-27 04:46:08,366 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1169] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2020-09-27 04:46:08,374 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@999] - Socket connection established, initiating session, client: /127.0.0.1:55990, server: localhost/127.0.0.1:2181
JLine support is enabled
2020-09-27 04:46:08,486 [myid:localhost:2181] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1433] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x1000016c2a30000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

# 到这里说明启动成功
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]

# 输入 quit 退出
[zk: localhost:2181(CONNECTED) 1] quit
2020-09-27 04:46:56,887 [myid:localhost:2181] - WARN  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1279] - An exception was thrown while closing send thread for session 0x1000016c2a30000.
EndOfStreamException: Unable to read additional data from server sessionid 0x1000016c2a30000, likely server has closed socket
        at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:77)
        at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1275)

WATCHER::

WatchedEvent state:Closed type:None path:null
2020-09-27 04:46:56,992 [myid:] - INFO  [main:ZooKeeper@1619] - Session: 0x1000016c2a30000 closed
2020-09-27 04:46:56,994 [myid:] - ERROR [main:ServiceUtils@42] - Exiting JVM with code 0
2020-09-27 04:46:56,994 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@577] - EventThread shut down for session: 0x1000016c2a30000
root@64e866e1c417:/apache-zookeeper-3.6.2-bin# exit
exit

停止 zookeeper 服务:

代码语言:javascript
复制
# 查看容器的 ID
[root@shuozg ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS
                   NAMES
9e09b18d3792        zookeeper           "/docker-entrypoint.…"   7 minutes ago       Up 7 minutes        2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp   zookeeper
[root@shuozg ~]# docker stop 9e09b18d3792
9e09b18d3792
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/09/27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档