schema注册表容器:使用docker compose启动时服务器意外死亡

u4dcyp6a  于 2021-06-08  发布在  Kafka
关注(0)|答案(3)|浏览(388)

我编写了docker-compose.yml文件来创建以下容器:
合流Zookeeper
合流Kafka
合流模式注册表
我想要一个单独的docker compose文件来旋转必要的容器,公开所需的端口并互连依赖的容器。目标是让我使用的是docker hub的官方合流图像。我的docker compose文件如下所示:

zookeeper:
  image: confluent/zookeeper
  container_name: confluent-zookeeper
  hostname: zookeeper
  environment:
    ZOOKEEPER_CLIENT_PORT: 2181
  ports:
    - "2181:2181"

kafka:
  environment:
    KAFKA_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
    KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
  image: confluent/kafka
  container_name: confluent-kafka
  hostname: kafka
  links:
    - zookeeper
  ports:
    - "9092:9092"

schema-registry:
  image: confluent/schema-registry
  container_name: confluent-schema_registry
  environment:
    SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: zookeeper:2181
    SCHEMA_REGISTRY_HOSTNAME: schema-registry
    SCHEMA_REGISTRY_LISTENERS: http://schema-registry:8081
    SCHEMA_REGISTRY_DEBUG: 'true'
    SCHEMA_REGISTRY_KAFKASTORE_TOPIC_REPLICATION_FACTOR: '1'
  links:
    - kafka
    - zookeeper
  ports:
    - "8081:8081"

现在当我跑的时候 docker-compose up ,将创建并启动所有这些容器。但是模式注册表容器立即退出。 docker logs 提供以下输出:

(io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig:135)
[2017-05-17 06:06:33,415] ERROR Server died unexpectedly:  (io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain:51)
org.apache.kafka.common.config.ConfigException: Only plaintext and SSL Kafka endpoints are supported and none are configured.
        at io.confluent.kafka.schemaregistry.storage.KafkaStore.getBrokerEndpoints(KafkaStore.java:254)
        at io.confluent.kafka.schemaregistry.storage.KafkaStore.<init>(KafkaStore.java:111)
        at io.confluent.kafka.schemaregistry.storage.KafkaSchemaRegistry.<init>(KafkaSchemaRegistry.java:136)
        at io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication.setupResources(SchemaRegistryRestApplication.java:53)
        at io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication.setupResources(SchemaRegistryRestApplication.java:37)
        at io.confluent.rest.Application.createServer(Application.java:117)
        at io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain.main(SchemaRegistryMain.java:43)

我寻找这个问题,但没有任何帮助。我尝试了其他各种配置,如提供kafka\u播发的\u主机名、更改schema\u注册表\u侦听器值等,但没有成功。有人能指出模式注册表容器失败的确切配置问题吗?

8yparm6h

8yparm6h1#

这个问题由来已久,不过留下一个对我有用的解决方案或许会有所帮助。我正在使用docker compose:

version: '3.3'

services:
  zookeeper:
    image: confluent/zookeeper:3.4.6-cp1
    hostname: "zookeeper"
    networks:
      - test-net
    ports:
      - 2181:2181
    environment:
      zk_id: "1"

  kafka:
    image: confluent/kafka:0.10.0.0-cp1
    hostname: "kafka"
    depends_on:
      - zookeeper
    networks:
      - test-net
    ports:
      - 9092:9092
    environment:
      KAFKA_ADVERTISED_HOST_NAME: "kafka"
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_BROKER_ID: "0"
      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"

  schema-registry:
    image: confluent/schema-registry:3.0.0
    hostname: "schema-registry"
    depends_on:
      - kafka
      - zookeeper
    networks:
      - test-net
    ports:
      - 8081:8081
    environment:
      SR_HOSTNAME: schema-registry
      SR_LISTENERS: http://schema-registry:8081
      SR_DEBUG: 'true'
      SR_KAFKASTORE_TOPIC_REPLICATION_FACTOR: '1'
      SR_KAFKASTORE_TOPIC_SERVERS: PLAINTEXT://kafka:9092

networks:
  test-net:
    driver: bridge`
drnojrws

drnojrws2#

这些都是过时的docker图像。使用confluentinc.最新支持的docker映像https://hub.docker.com/u/confluentinc/
你可以在这里找到一个完整的文件-confluentinc/cp docker images

dzhpxtsq

dzhpxtsq3#

你缺少主机名( hostname: schema-registry )失败容器中的条目。默认情况下,docker将填充容器的 /etc/hosts 使用链接容器的别名和名称,加上self的主机名。

相关问题