专栏首页技术进阶之路Docker 中启动 ZooKeeper

Docker 中启动 ZooKeeper

2181 端口启动 zookeeper 进程:

# 查看镜像的 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
# 获取容器 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 服务:

# 查看容器的 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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Spring BeanPostProcessor 的执行顺序

    实际上在实战中,我们很少处理 Spring 的初始化操作,所以没有必要区分 Before 还是 After。只需要实现其中的一个即可,显然选 After 方法更...

    wsuo
  • Vue 中使用 JQuery 插件不起作用

    有时候在 vue 的代码中使用 jQuery 会不起作用,这是因为 vue 还没有绑定变量,所以我们使用的 jQuery 根本就找不到目标变量,就不会执行,正确...

    wsuo
  • 从数据库中查询马上过生日的人并统计各年龄段及性别所占的人数

    wsuo
  • swoole框架-swoft实现程圣母与云天明对话功能启动ws服务创建http服务的聊天控制器创建视图文件创建ws控制器结果演示

    当万有引力号启动广播按钮,向宇宙发送三体星的坐标时,地球已经失去了任何侵略价值。三体人将所有在地球的资源全部撤走,但在临别时,安排了程圣母与云天明的远程会话。接...

    章鱼喵
  • android的PowerManager和PowerManager.WakeLock

      学习android一段时间了,为了进一步了解android的应用是如何设计开发的,决定详细研究几个开源的android应用。从一些开源应用中吸收点东西,一边...

    杨奉武
  • android的PowerManager和PowerManager.WakeLock

      学习android一段时间了,为了进一步了解android的应用是如何设计开发的,决定详细研究几个开源的android应用。从一些开源应用中吸收点东西,一边...

    杨奉武
  • expect定期远程登录Juniper防火墙实现定期重新拨号

    明哥的运维笔记
  • 《Monkey Java》课程3.1之分支语句

    GitOPEN
  • xwiki管理指南-性能

    默认情况下XWiki使用嵌入式Solr,主要是为了方便开发。但是如果页面开始多起来,搜索变得很慢,那么应该试下使用外部Solr实例(独立出solr)。Solr ...

    lilihongjava
  • 自用图片压缩工具推荐(优化博客加载速度)

    2016-03-2318:22:27 发表评论 609℃热度 之前wordpress写博客时文章里面的图片都是上传到服务器中,以前以为这样省事,都是原图上传,...

    timhbw

扫码关注云+社区

领取腾讯云代金券