debezium/zookeeper port 2181 closed

心不动则不痛 提交于 2021-01-01 07:00:06

问题


I have a running Zookeeper instance from the https://hub.docker.com/r/debezium/zookeeper:1.2 image and my Compose file:

version: "3.7"
services:
  zookeeper:
    image: debezium/zookeeper:1.2
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
    networks:
      common:
    volumes:
      - "~/dev/docker/projects/debezium/volumes/zookeeper/data:/zookeeper/data"
      - "~/dev/docker/projects/debezium/volumes/zookeeper/txns:/zookeeper/txns"
      - "~/dev/docker/projects/debezium/volumes/zookeeper/conf:/zookeeper/conf"
      - "~/dev/docker/projects/debezium/volumes/zookeeper/logs:/zookeeper/logs"
    environment:
      HOST_USER_ID: ${CURRENT_UID}
      HOST_GROUP_ID: ${CURRENT_GID}
    deploy:
      replicas: 1
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 10s
    healthcheck:
      test: curl --fail http://localhost:2181 || exit 1
      interval: 1m
      timeout: 3s
      retries: 3

I can see the Zookeeper server start all right:

5f7860484b48        debezium/zookeeper:1.2            "/docker-entrypoint.…"   About a minute ago   Up About a minute (health
: starting)   2181/tcp, 2888/tcp, 3888/tcp, 8778/tcp, 9779/tcp   debezium_zookeeper.1.hmdxswlsmqdebqkqvkjqzxnlc

with the server log showing:

debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,032 - INFO  [main:ContextHandler@825] - Started o.e.j.s.ServletContextHandler@3f197a46{/,null,AVAILABLE}
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,111 - INFO  [main:AbstractConnector@330] - Started ServerConnector@4278a03f{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,112 - INFO  [main:Server@399] - Started @5046ms
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,113 - INFO  [main:JettyAdminServer@112] - Started AdminServer on address 0.0.0.0, port 8080 and command URL /commands
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,135 - INFO  [main:ServerCnxnFactory@135] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,145 - INFO  [main:NIOServerCnxnFactory@673] - Configuring NIO connection handler with 10s sessionless connection timeout, 1 selector thread(s), 8 worker threads, and 64 kB direct buffers.
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,150 - INFO  [main:NIOServerCnxnFactory@686] - binding to port 0.0.0.0/0.0.0.0:2181
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,224 - INFO  [main:ZKDatabase@117] - zookeeper.snapshotSizeFactor = 0.33
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,320 - INFO  [main:FileSnap@83] - Reading snapshot /zookeeper/data/version-2/snapshot.0
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,340 - INFO  [main:FileTxnSnapLog@404] - Snapshotting: 0x0 to /zookeeper/data/version-2/snapshot.0
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:45:15,408 - INFO  [main:ContainerManager@64] - Using checkIntervalMs=60000 maxPerMinute=10000
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:46:10,244 - WARN  [NIOWorkerThread-1:NIOServerCnxn@370] - Exception causing close of session 0x0: Len error 1195725856
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:47:10,884 - WARN  [NIOWorkerThread-2:NIOServerCnxn@370] - Exception causing close of session 0x0: Len error 1195725856
debezium_zookeeper.1.j841dv1adeab@stephane-pc    | 2020-10-12 08:48:12,599 - WARN  [NIOWorkerThread-3:NIOServerCnxn@370] - Exception causing close of session 0x0: Len error 1195725856

But I can't connect to the published port from the host:

stephane@stephane-pc:~$ nmap -p 2181 localhost
Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-12 10:50 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00033s latency).

PORT     STATE  SERVICE
2181/tcp closed eforward

Of course, the port is enabled in the firewall:

sudo ufw allow from any to any port 2181;

stephane@stephane-pc:~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
8500                       ALLOW IN    127.0.0.0                 
8500                       ALLOW IN    Anywhere                  
18630                      ALLOW IN    Anywhere                  
2181                       ALLOW IN    127.0.0.0                 
2181                       ALLOW IN    Anywhere                  
9092                       ALLOW IN    Anywhere                  
8500 (v6)                  ALLOW IN    Anywhere (v6)             
18630 (v6)                 ALLOW IN    Anywhere (v6)             
2181 (v6)                  ALLOW IN    Anywhere (v6)             
9092 (v6)                  ALLOW IN    Anywhere (v6)

I can connect to the running container:

docker-exec debezium_zookeeper.1.app5h7goosa2cpn4g06azp2xt

and see the server status:

[zookeeper@2f57d1a84ce7 ~]$ bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone

The log does show a warning though:

debezium_zookeeper.1.u0koxm2njw2i@stephane-pc    | 2020-10-12 09:03:47,829 - WARN  [NIOWorkerThread-2:NIOServerCnxn@370] - Exception causing close of session 0x0: Len error 1195725856

which seems to be a known issue.

Could this be related to my closed port issue ?

UPDATE: I also tried adding a hostname property as hostname: zookeeper to the Compose file and add the 127.0.1.1 zookeeper entry in the /etc/hosts file, but the nmap -p 2181 zookeeper command still showed a closed port.


回答1:


I had to change the way I check for health.

healthcheck:
  test: /zookeeper/bin/zkServer.sh print-cmd || exit 1
  interval: 1m
  timeout: 3s
  retries: 3
  start_period: 15s

The complete Compose file:

version: "3.7"
services:
  zookeeper:
    image: debezium/zookeeper:1.2
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
    networks:
      common:
    volumes:
      - "~/dev/docker/projects/debezium/volumes/zookeeper/data:/zookeeper/data"
      - "~/dev/docker/projects/debezium/volumes/zookeeper/txns:/zookeeper/txns"
      - "~/dev/docker/projects/debezium/volumes/zookeeper/conf:/zookeeper/conf"
      - "~/dev/docker/projects/debezium/volumes/zookeeper/logs:/zookeeper/logs"
    environment:
      HOST_USER_ID: ${CURRENT_UID}
      HOST_GROUP_ID: ${CURRENT_GID}
    deploy:
      resources:
        limits:
          cpus: "0.1"
          memory: 256M
      replicas: 1
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 10s
    healthcheck:
      test: /zookeeper/bin/zkServer.sh print-cmd || exit 1
      interval: 1m
      timeout: 3s
      retries: 3
      start_period: 15s
  kafka:
    image: debezium/kafka:1.2
    ports:
      - "9092:9092"
    networks:
      common:
    volumes:
      - "~/dev/docker/projects/debezium/volumes/kafka/data:/kafka/data"
      - "~/dev/docker/projects/debezium/volumes/kafka/logs:/kafka/logs"
    environment:
      ZOOKEEPER_CONNECT: zookeeper:2181
      HOST_USER_ID: ${CURRENT_UID}
      HOST_GROUP_ID: ${CURRENT_GID}
    depends_on:
      - zookeeper      
    deploy:
      replicas: 1
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 10s
    healthcheck:
      test: /kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181 || exit 1
      interval: 1m
      timeout: 15s
      retries: 3
      start_period: 15s
networks:
  common:  
    external: true
    name: common


来源:https://stackoverflow.com/questions/64314622/debezium-zookeeper-port-2181-closed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!