zookeeper已启动,但kafka服务器在使用docker compose时未启动

w8rqjzmb  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(496)

docker-compose.yml公司

version: '3'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"

  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: localhost
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'

错误:

[root@sourabh kafka-example]# docker-compose up
Starting kafka-example_zookeeper_1 ... done
Recreating kafka-example_kafka_1   ... done
Attaching to kafka-example_zookeeper_1, kafka-example_kafka_1
kafka_1      | Excluding KAFKA_HOME from broker config
zookeeper_1  | ZooKeeper JMX enabled by default
zookeeper_1  | Using config: /opt/zookeeper-3.4.13/bin/../conf/zoo.cfg
kafka_1      | [Configuring] 'advertised.host.name' in '/opt/kafka/config/server.properties'
kafka_1      | [Configuring] 'port' in '/opt/kafka/config/server.properties'
kafka_1      | [Configuring] 'auto.create.topics.enable' in '/opt/kafka/config/server.properties'
kafka_1      | [Configuring] 'broker.id' in '/opt/kafka/config/server.properties'
kafka_1      | Excluding KAFKA_VERSION from broker config
kafka_1      | [Configuring] 'zookeeper.connect' in '/opt/kafka/config/server.properties'
kafka_1      | [Configuring] 'log.dirs' in '/opt/kafka/config/server.properties'
zookeeper_1  | 2020-08-01 06:44:50,414 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /opt/zookeeper-3.4.13/bin/../conf/zoo.cfg
zookeeper_1  | 2020-08-01 06:44:50,426 [myid:] - INFO  [main:DatadirCleanupManager@78] - autopurge.snapRetainCount set to 3
zookeeper_1  | 2020-08-01 06:44:50,426 [myid:] - INFO  [main:DatadirCleanupManager@79] - autopurge.purgeInterval set to 1
zookeeper_1  | 2020-08-01 06:44:50,428 [myid:] - WARN  [main:QuorumPeerMain@116] - Either no config or no quorum defined in config, running  in standalone mode
zookeeper_1  | 2020-08-01 06:44:50,448 [myid:] - INFO  [PurgeTask:DatadirCleanupManager$PurgeTask@138] - Purge task started.
zookeeper_1  | 2020-08-01 06:44:50,471 [myid:] - INFO  [main:QuorumPeerConfig@136] - Reading configuration from: /opt/zookeeper-3.4.13/bin/../conf/zoo.cfg
zookeeper_1  | 2020-08-01 06:44:50,472 [myid:] - INFO  [main:ZooKeeperServerMain@98] - Starting server
zookeeper_1  | 2020-08-01 06:44:50,512 [myid:] - INFO  [PurgeTask:DatadirCleanupManager$PurgeTask@144] - Purge task completed.
zookeeper_1  | 2020-08-01 06:44:50,517 [myid:] - INFO  [main:Environment@100] - Server environment:zookeeper.version=3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
zookeeper_1  | 2020-08-01 06:44:50,517 [myid:] - INFO  [main:Environment@100] - Server environment:host.name=209707fd23b9
zookeeper_1  | 2020-08-01 06:44:50,517 [myid:] - INFO  [main:Environment@100] - Server environment:java.version=1.7.0_65
zookeeper_1  | 2020-08-01 06:44:50,518 [myid:] - INFO  [main:Environment@100] - Server environment:java.vendor=Oracle Corporation
zookeeper_1  | 2020-08-01 06:44:50,519 [myid:] - INFO  [main:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-7-openjdk-amd64/jre
zookeeper_1  | 2020-08-01 06:44:50,520 [myid:] - INFO  [main:Environment@100] - Server environment:java.class.path=/opt/zookeeper-3.4.13/bin/../build/classes:/opt/zookeeper-3.4.13/bin/../build/lib/*.jar:/opt/zookeeper-3.4.13/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/zookeeper-3.4.13/bin/../lib/slf4j-api-1.7.25.jar:/opt/zookeeper-3.4.13/bin/../lib/netty-3.10.6.Final.jar:/opt/zookeeper-3.4.13/bin/../lib/log4j-1.2.17.jar:/opt/zookeeper-3.4.13/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.13/bin/../lib/audience-annotations-0.5.0.jar:/opt/zookeeper-3.4.13/bin/../zookeeper-3.4.13.jar:/opt/zookeeper-3.4.13/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.13/bin/../conf:
zookeeper_1  | 2020-08-01 06:44:50,520 [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
zookeeper_1  | 2020-08-01 06:44:50,520 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=/tmp
zookeeper_1  | 2020-08-01 06:44:50,526 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
zookeeper_1  | 2020-08-01 06:44:50,526 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Linux
zookeeper_1  | 2020-08-01 06:44:50,526 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
zookeeper_1  | 2020-08-01 06:44:50,526 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=4.18.0-193.14.2.el8_2.x86_64
zookeeper_1  | 2020-08-01 06:44:50,527 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=root
zookeeper_1  | 2020-08-01 06:44:50,527 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/root
zookeeper_1  | 2020-08-01 06:44:50,527 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper-3.4.13
zookeeper_1  | 2020-08-01 06:44:50,548 [myid:] - INFO  [main:ZooKeeperServer@836] - tickTime set to 2000
zookeeper_1  | 2020-08-01 06:44:50,548 [myid:] - INFO  [main:ZooKeeperServer@845] - minSessionTimeout set to -1
zookeeper_1  | 2020-08-01 06:44:50,548 [myid:] - INFO  [main:ZooKeeperServer@854] - maxSessionTimeout set to -1
zookeeper_1  | 2020-08-01 06:44:50,628 [myid:] - INFO  [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
zookeeper_1  | 2020-08-01 06:44:50,651 [myid:] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
kafka_1      | [2020-08-01 06:44:51,969] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$)
kafka_1      | [2020-08-01 06:44:53,521] INFO Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation (org.apache.zookeeper.common.X509Util)
kafka_1      | [2020-08-01 06:44:53,719] INFO Registered signal handlers for TERM, INT, HUP (org.apache.kafka.common.utils.LoggingSignalHandler)
kafka_1      | [2020-08-01 06:44:53,742] INFO starting (kafka.server.KafkaServer)
kafka_1      | [2020-08-01 06:44:53,746] INFO Connecting to zookeeper on zookeeper:2181 (kafka.server.KafkaServer)
kafka_1      | [2020-08-01 06:44:53,828] INFO [ZooKeeperClient Kafka server] Initializing a new session to zookeeper:2181. (kafka.zookeeper.ZooKeeperClient)
kafka_1      | [2020-08-01 06:44:53,876] INFO Client environment:zookeeper.version=3.5.7-f0fdd52973d373ffd9c86b81d99842dc2c7f660e, built on 02/10/2020 11:30 GMT (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,876] INFO Client environment:host.name=e7b24759e294 (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,877] INFO Client environment:java.version=1.8.0_212 (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,877] INFO Client environment:java.vendor=IcedTea (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,877] INFO Client environment:java.home=/usr/lib/jvm/java-1.8-openjdk/jre (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,877] INFO Client environment:java.class.path=/opt/kafka/bin/../libs/activation-1.1.1.jar:/opt/kafka/bin/../libs/aopalliance-repackaged-2.5.0.jar:/opt/kafka/bin/../libs/argparse4j-0.7.0.jar:/opt/kafka/bin/../libs/audience-annotations-0.5.0.jar:/opt/kafka/bin/../libs/commons-cli-1.4.jar:/opt/kafka/bin/../libs/commons-lang3-3.8.1.jar:/opt/kafka/bin/../libs/connect-api-2.5.0.jar:/opt/kafka/bin/../libs/connect-basic-auth-extension-2.5.0.jar:/opt/kafka/bin/../libs/connect-file-2.5.0.jar:/opt/kafka/bin/../libs/connect-json-2.5.0.jar:/opt/kafka/bin/../libs/connect-mirror-2.5.0.jar:/opt/kafka/bin/../libs/connect-mirror-client-2.5.0.jar:/opt/kafka/bin/../libs/connect-runtime-2.5.0.jar:/opt/kafka/bin/../libs/connect-transforms-2.5.0.jar:/opt/kafka/bin/../libs/hk2-api-2.5.0.jar:/opt/kafka/bin/../libs/hk2-locator-2.5.0.jar:/opt/kafka/bin/../libs/hk2-utils-2.5.0.jar:/opt/kafka/bin/../libs/jackson-annotations-2.10.2.jar:/opt/kafka/bin/../libs/jackson-core-2.10.2.jar:/opt/kafka/bin/../libs/jackson-databind-2.10.2.jar:/opt/kafka/bin/../libs/jackson-dataformat-csv-2.10.2.jar:/opt/kafka/bin/../libs/jackson-datatype-jdk8-2.10.2.jar:/opt/kafka/bin/../libs/jackson-jaxrs-base-2.10.2.jar:/opt/kafka/bin/../libs/jackson-jaxrs-json-provider-2.10.2.jar:/opt/kafka/bin/../libs/jackson-module-jaxb-annotations-2.10.2.jar:/opt/kafka/bin/../libs/jackson-module-paranamer-2.10.2.jar:/opt/kafka/bin/../libs/jackson-module-scala_2.12-2.10.2.jar:/opt/kafka/bin/../libs/jakarta.activation-api-1.2.1.jar:/opt/kafka/bin/../libs/jakarta.annotation-api-1.3.4.jar:/opt/kafka/bin/../libs/jakarta.inject-2.5.0.jar:/opt/kafka/bin/../libs/jakarta.ws.rs-api-2.1.5.jar:/opt/kafka/bin/../libs/jakarta.xml.bind-api-2.3.2.jar:/opt/kafka/bin/../libs/javassist-3.22.0-CR2.jar:/opt/kafka/bin/../libs/javassist-3.26.0-GA.jar:/opt/kafka/bin/../libs/javax.servlet-api-3.1.0.jar:/opt/kafka/bin/../libs/javax.ws.rs-api-2.1.1.jar:/opt/kafka/bin/../libs/jaxb-api-2.3.0.jar:/opt/kafka/bin/../libs/jersey-client-2.28.jar:/opt/kafka/bin/../libs/jersey-common-2.28.jar:/opt/kafka/bin/../libs/jersey-container-servlet-2.28.jar:/opt/kafka/bin/../libs/jersey-container-servlet-core-2.28.jar:/opt/kafka/bin/../libs/jersey-hk2-2.28.jar:/opt/kafka/bin/../libs/jersey-media-jaxb-2.28.jar:/opt/kafka/bin/../libs/jersey-server-2.28.jar:/opt/kafka/bin/../libs/jetty-client-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-continuation-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-http-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-io-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-security-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-server-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-servlet-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-servlets-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jetty-util-9.4.24.v20191120.jar:/opt/kafka/bin/../libs/jopt-simple-5.0.4.jar:/opt/kafka/bin/../libs/kafka-clients-2.5.0.jar:/opt/kafka/bin/../libs/kafka-log4j-appender-2.5.0.jar:/opt/kafka/bin/../libs/kafka-streams-2.5.0.jar:/opt/kafka/bin/../libs/kafka-streams-examples-2.5.0.jar:/opt/kafka/bin/../libs/kafka-streams-scala_2.12-2.5.0.jar:/opt/kafka/bin/../libs/kafka-streams-test-utils-2.5.0.jar:/opt/kafka/bin/../libs/kafka-tools-2.5.0.jar:/opt/kafka/bin/../libs/kafka_2.12-2.5.0-sources.jar:/opt/kafka/bin/../libs/kafka_2.12-2.5.0.jar:/opt/kafka/bin/../libs/log4j-1.2.17.jar:/opt/kafka/bin/../libs/lz4-java-1.7.1.jar:/opt/kafka/bin/../libs/maven-artifact-3.6.3.jar:/opt/kafka/bin/../libs/metrics-core-2.2.0.jar:/opt/kafka/bin/../libs/netty-buffer-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-codec-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-common-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-handler-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-resolver-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-transport-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-transport-native-epoll-4.1.45.Final.jar:/opt/kafka/bin/../libs/netty-transport-native-unix-common-4.1.45.Final.jar:/opt/kafka/bin/../libs/osgi-resource-locator-1.0.1.jar:/opt/kafka/bin/../libs/paranamer-2.8.jar:/opt/kafka/bin/../libs/plexus-utils-3.2.1.jar:/opt/kafka/bin/../libs/reflections-0.9.12.jar:/opt/kafka/bin/../libs/rocksdbjni-5.18.3.jar:/opt/kafka/bin/../libs/scala-collection-compat_2.12-2.1.3.jar:/opt/kafka/bin/../libs/scala-java8-compat_2.12-0.9.0.jar:/opt/kafka/bin/../libs/scala-library-2.12.10.jar:/opt/kafka/bin/../libs/scala-logging_2.12-3.9.2.jar:/opt/kafka/bin/../libs/scala-reflect-2.12.10.jar:/opt/kafka/bin/../libs/slf4j-api-1.7.30.jar:/opt/kafka/bin/../libs/slf4j-log4j12-1.7.30.jar:/opt/kafka/bin/../libs/snappy-java-1.1.7.3.jar:/opt/kafka/bin/../libs/validation-api-2.0.1.Final.jar:/opt/kafka/bin/../libs/zookeeper-3.5.7.jar:/opt/kafka/bin/../libs/zookeeper-jute-3.5.7.jar:/opt/kafka/bin/../libs/zstd-jni-1.4.4-7.jar (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,878] INFO Client environment:java.library.path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,878] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,878] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,878] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,878] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:os.version=4.18.0-193.14.2.el8_2.x86_64 (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:user.dir=/ (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:os.memory.free=978MB (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:os.memory.max=1024MB (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,879] INFO Client environment:os.memory.total=1024MB (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,891] INFO Initiating client connection, connectString=zookeeper:2181 sessionTimeout=18000 watcher=kafka.zookeeper.ZooKeeperClient$ZooKeeperClientWatcher$@c33b74f (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:44:53,912] INFO jute.maxbuffer value is 4194304 Bytes (org.apache.zookeeper.ClientCnxnSocket)
kafka_1      | [2020-08-01 06:44:53,928] INFO zookeeper.request.timeout value is 0. feature enabled= (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:44:53,942] INFO [ZooKeeperClient Kafka server] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
kafka_1      | [2020-08-01 06:44:53,978] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:44:55,028] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:44:56,136] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:44:57,139] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:44:58,242] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:44:59,252] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:00,356] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:01,363] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:02,468] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:03,476] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:04,579] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:05,587] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:06,705] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:07,763] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:08,867] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:09,875] INFO Socket error occurred: zookeeper/172.25.0.2:2181: Host is unreachable (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:10,984] INFO Opening socket connection to server zookeeper/172.25.0.2:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:11,956] INFO [ZooKeeperClient Kafka server] Closing. (kafka.zookeeper.ZooKeeperClient)
kafka_1      | [2020-08-01 06:45:12,099] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
kafka_1      | [2020-08-01 06:45:12,099] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
kafka_1      | [2020-08-01 06:45:12,107] INFO [ZooKeeperClient Kafka server] Closed. (kafka.zookeeper.ZooKeeperClient)
kafka_1      | [2020-08-01 06:45:12,116] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka_1      | kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
kafka_1      |  at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:262)
kafka_1      |  at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:258)
kafka_1      |  at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:119)
kafka_1      |  at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1863)
kafka_1      |  at kafka.server.KafkaServer.createZkClient$1(KafkaServer.scala:378)
kafka_1      |  at kafka.server.KafkaServer.initZkClient(KafkaServer.scala:403)
kafka_1      |  at kafka.server.KafkaServer.startup(KafkaServer.scala:210)
kafka_1      |  at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44)
kafka_1      |  at kafka.Kafka$.main(Kafka.scala:82)
kafka_1      |  at kafka.Kafka.main(Kafka.scala)
kafka_1      | [2020-08-01 06:45:12,127] INFO shutting down (kafka.server.KafkaServer)
kafka_1      | [2020-08-01 06:45:12,151] INFO shut down completed (kafka.server.KafkaServer)
kafka_1      | [2020-08-01 06:45:12,166] ERROR Exiting Kafka. (kafka.server.KafkaServerStartable)
kafka_1      | [2020-08-01 06:45:12,190] INFO shutting down (kafka.server.KafkaServer)
kafka-example_kafka_1 exited with code 1

[root@sourabh sourabh]# docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                                                NAMES
209707fd23b9        wurstmeister/zookeeper   "/bin/sh -c '/usr/sb…"   15 minutes ago      Up About a minute   22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp   kafka-example_zookeeper_1
[root@sourabh sourabh]#

我的Kafka服务器无法运行,即使我将Kafka主机名端口更改为docker0

[root@sourabh sourabh]# ifconfig
br-694d97c1f1f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.0.1  netmask 255.255.0.0  broadcast 172.25.255.255
        inet6 fe80::42:77ff:fe8d:f873  prefixlen 64  scopeid 0x20<link>
        ether 02:42:77:8d:f8:73  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:b4:0d:8e:61  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.159.132  netmask 255.255.255.0  broadcast 192.168.159.255
        inet6 fe80::4532:55cb:1dac:f2ff  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f3:b4:fe  txqueuelen 1000  (Ethernet)
        RX packets 21216  bytes 28430355 (27.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11253  bytes 812166 (793.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethff4e4a1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::8466:7cff:fe9b:1e5c  prefixlen 64  scopeid 0x20<link>
        ether 86:66:7c:9b:1e:5c  txqueuelen 0  (Ethernet)
        RX packets 1  bytes 42 (42.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 23  bytes 2612 (2.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:c1:f0:97  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
1cosmwyk

1cosmwyk1#

我试着换衣服 KAFKA_ADVERTISED_HOST_NAME: localhostKAFKA_ADVERTISED_HOST_NAME: kafka 而且成功了。

kaustubh@test:~$ docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                                                NAMES
1afe7b3a07c2        wurstmeister/zookeeper   "/bin/sh -c '/usr/sb…"   2 minutes ago       Up 2 minutes        22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp   kafka-zookeeper_zookeeper_1
cebc740250d2        wurstmeister/kafka       "start-kafka.sh"         2 minutes ago       Up 2 minutes        0.0.0.0:9092->9092/tcp                               kafka-zookeeper_kafka_1

telnet至9092和2181

kaustubh@test:~$ telnet localhost 9092
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> Connection closed.
kaustubh@test:~$ 
kaustubh@test:~$ telnet localhost 2181
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> Connection closed.

使用的参考文献:

拉马努斯的评论
https://docs.docker.com/compose/networking/

相关问题