我从https://hub.docker.com/r/debezium/zookeeper:1.2
图像和我的合成文件中有一个正在运行的Zookeeper示例:
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
我可以看到Zookeeper服务器启动正常:
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
服务器日志显示:
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
但我无法从主机连接到发布的端口:
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
当然,该端口在防火墙中是启用的:
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)
我可以连接到正在运行的容器:
docker-exec debezium_zookeeper.1.app5h7goosa2cpn4g06azp2xt
并查看服务器状态:
[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
不过,日志确实显示了一条警告:
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
看起来是known issue。
这是否与我的端口关闭问题有关?
更新:我还尝试将hostname
属性作为hostname: zookeeper
添加到合成文件中,并将127.0.1.1 zookeeper
条目添加到/etc/hosts
文件中,但nmap -p 2181 zookeeper
命令仍然显示一个关闭的端口。
1条答案
按热度按时间zpqajqem1#
我不得不改变我检查健康的方式。
完整的合成文件: