kafka-zookeeper无法在docker-compose

时间:2018-10-18 23:40:59

标签: docker apache-kafka docker-compose

我想通过docker-compose运行kafka-zookeeper。我已经创建了一个docker-compose.yml文件,并通过将docker-compose.yml向上-从cmd构建(在docker-compose.yml目录中)进行工作,然后打开我的kafka-tool应用程序然后将其连接

这是docker-compose.yml文件,看起来像:

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
      ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      - KAFKA_CREATE_TOPICS="producer_topic:1:1" # topic:partition:replicas
      - KAFKA_ADVERTISED_HOST_NAME=192.168.99.100 # docker-machine ip
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
      - KAFKA_URL=kafka://192.168.99.100:9092
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

有效。但是,然后,我尝试为我的新项目创建新集群。这是我的新项目的docker-compose.yml代码

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      - KAFKA_CREATE_TOPICS="createreport:1:1" # topic:partition:replicas
      - KAFKA_ADVERTISED_HOST_NAME=192.168.99.100 # docker-machine ip
      - KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
      - KAFKA_URL=kafka://192.168.99.100:9092
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

几乎完全一样,对吧?然后,我尝试在cmd上运行docker-compose.yml up --build,但是当我尝试在kafka-tool中添加新的群集连接时,它失败了。然后,当我尝试运行之前的docker-compose.yml时,它也失败了,无法连接。这是我新项目中Zookeeper容器上的日志

ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
2018-10-18 23:31:35,456 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
2018-10-18 23:31:35,495 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
2018-10-18 23:31:35,496 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 1
2018-10-18 23:31:35,508 [myid:] - WARN  [main:QuorumPeerMain@113] - Either no config or no quorum defined in config, running  in standalone mode
2018-10-18 23:31:35,523 [myid:] - INFO  [PurgeTask:DatadirCleanupManager$PurgeTask@138] - Purge task started.
2018-10-18 23:31:35,644 [myid:] - INFO  [PurgeTask:DatadirCleanupManager$PurgeTask@144] - Purge task completed.
2018-10-18 23:31:35,669 [myid:] - INFO  [main:QuorumPeerConfig@124] - Reading configuration from: /opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
2018-10-18 23:31:35,674 [myid:] - INFO  [main:ZooKeeperServerMain@96] - Starting server
2018-10-18 23:31:35,715 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
2018-10-18 23:31:35,716 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=22be7d406c98
2018-10-18 23:31:35,717 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.7.0_65
2018-10-18 23:31:35,720 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
2018-10-18 23:31:35,722 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
2018-10-18 23:31:35,723 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper-3.4.9/bin/../build/classes:/opt/zookeeper-3.4.9/bin/../build/lib/*.jar:/opt/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/opt/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/opt/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.9/bin/../conf:
2018-10-18 23:31:35,724 [myid:] - INFO  [main:Environment@100] - Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
2018-10-18 23:31:35,725 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
2018-10-18 23:31:35,750 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2018-10-18 23:31:35,751 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Linux
2018-10-18 23:31:35,752 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2018-10-18 23:31:35,753 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=4.9.93-boot2docker
2018-10-18 23:31:35,754 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=root
2018-10-18 23:31:35,755 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/root
2018-10-18 23:31:35,755 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper-3.4.9
2018-10-18 23:31:35,764 [myid:] - INFO  [main:ZooKeeperServer@815] - tickTime set to 2000
2018-10-18 23:31:35,771 [myid:] - INFO  [main:ZooKeeperServer@824] - minSessionTimeout set to -1
2018-10-18 23:31:35,774 [myid:] - INFO  [main:ZooKeeperServer@833] - maxSessionTimeout set to -1
2018-10-18 23:31:35,903 [myid:] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2018-10-18 23:31:39,464 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /172.18.0.2:60442
2018-10-18 23:31:39,494 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@928] - Client attempting to establish new session at /172.18.0.2:60442
2018-10-18 23:31:39,501 [myid:] - INFO  [SyncThread:0:FileTxnLog@203] - Creating new log file: log.1
2018-10-18 23:31:39,597 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@673] - Established session 0x166898523c20000 with negotiated timeout 6000 for client /172.18.0.2:60442
2018-10-18 23:31:39,839 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:create cxid:0x2 zxid:0x3 txntype:-1 reqpath:n/a Error Path:/brokers Error:KeeperErrorCode = NoNode for /brokers
2018-10-18 23:31:39,981 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:create cxid:0x6 zxid:0x7 txntype:-1 reqpath:n/a Error Path:/config Error:KeeperErrorCode = NoNode for /config
2018-10-18 23:31:40,390 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:create cxid:0x9 zxid:0xa txntype:-1 reqpath:n/a Error Path:/admin Error:KeeperErrorCode = NoNode for /admin
2018-10-18 23:31:41,495 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:create cxid:0x15 zxid:0x15 txntype:-1 reqpath:n/a Error Path:/cluster Error:KeeperErrorCode = NoNode for /cluster
2018-10-18 23:31:44,869 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:setData cxid:0x23 zxid:0x1b txntype:-1 reqpath:n/a Error Path:/controller_epoch Error:KeeperErrorCode = NoNode for /controller_epoch
2018-10-18 23:31:45,879 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:delete cxid:0x38 zxid:0x1e txntype:-1 reqpath:n/a Error Path:/admin/reassign_partitions Error:KeeperErrorCode = NoNode for /admin/reassign_partitions
2018-10-18 23:31:46,003 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@649] - Got user-level KeeperException when processing sessionid:0x166898523c20000 type:delete cxid:0x3a zxid:0x1f txntype:-1 reqpath:n/a Error Path:/admin/preferred_replica_election Error:KeeperErrorCode = NoNode for /admin/preferred_replica_election
2018-10-18 23:31:57,125 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /172.18.0.2:60448
2018-10-18 23:31:57,154 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@928] - Client attempting to establish new session at /172.18.0.2:60448
2018-10-18 23:31:57,280 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@673] - Established session 0x166898523c20001 with negotiated timeout 30000 for client /172.18.0.2:60448
2018-10-18 23:31:57,829 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@357] - caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x166898523c20001, likely client has closed socket
at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:228)
at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203)
at java.lang.Thread.run(Thread.java:745)
2018-10-18 23:31:57,839 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1008] - Closed socket connection for client /172.18.0.2:60448 which had sessionid 0x166898523c20001
2018-10-18 23:32:28,001 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x166898523c20001, timeout of 30000ms exceeded
2018-10-18 23:32:28,003 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@487] - Processed session termination for sessionid: 0x166898523c20001

这是在卡夫卡日志 https://pastebin.com/ypVWTFX5

有人知道如何解决吗?预先谢谢你。

1 个答案:

答案 0 :(得分:0)

从该错误看来,它似乎无法解析KAFKA_CREATE_TOPICS变量。

请注意:该属性是可选的,因此,如果第一种方法可行,我建议您继续进行操作,然后手动制作您需要的其他任何主题