Docker部署Confluent Kafka Schema Registry:PLAINTEXT端点未找到报错求助
问题:Docker部署Confluent Kafka Schema Registry连接Kafka报错
报错信息
java.lang.RuntimeException: No endpoints found for security protocol [PLAINTEXT]. Endpoints found in ZK [{INTERNAL=kafka:9092, OUTSIDE=localhost:29092}]
我的Schema Registry配置
schema-registry: image: confluentinc/cp-schema-registry:7.3.2 environment: - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2181 - SCHEMA_REGISTRY_HOST_NAME=schema-registry - ALLOW_PLAINTEXT_LISTENER='yes' - SCHEMA_REGISTRY_LISTENERS=http://schema-registry:8081 - SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS=PLAINTEXT://kafka:29092 links: - zookeeper - kafka ports: - 8082:8081
完整Docker Compose配置
zookeeper: image: confluentinc/cp-zookeeper:6.2.4 healthcheck: test: [ "CMD", "nc", "-vz", "localhost", "2181" ] interval: 10s timeout: 3s retries: 3 environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_TICK_TIME: 2000 ports: - 22181:2181 kafka: image: confluentinc/cp-kafka:6.2.4 depends_on: zookeeper: condition: service_healthy ports: - 29092:29092 healthcheck: test: [ "CMD", "nc", "-vz", "localhost", "9092" ] interval: 10s timeout: 3s retries: 3 environment: KAFKA_BROKER_ID: 1 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: OUTSIDE://:29092,INTERNAL://:9092 KAFKA_ADVERTISED_LISTENERS: OUTSIDE://localhost:29092,INTERNAL://kafka:9092 KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,OUTSIDE:PLAINTEXT KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 kafka-ui: image: provectuslabs/kafka-ui container_name: kafka-ui ports: - "8080:8080" restart: always depends_on: kafka: condition: service_healthy environment: KAFKA_CLUSTERS_0_NAME: local KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092 service-db: image: postgres:14.7-alpine environment: POSTGRES_USER: username POSTGRES_PASSWORD: password healthcheck: test: ["CMD-SHELL", "pg_isready", "-d", "clients_database"] interval: 10s timeout: 3s retries: 3 ports: - "15432:5432" volumes: - ./infrastructure/db/create_db.sql:/docker-entrypoint-initdb.d/create_db.sql restart: unless-stopped pgadmin: container_name: pgadmin_container image: dpage/pgadmin4:7 restart: always environment: PGADMIN_DEFAULT_EMAIL: admin@admin.com PGADMIN_DEFAULT_PASSWORD: root ports: - "5050:80" schema-registry: image: confluentinc/cp-schema-registry:7.3.2 environment: - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2181 - SCHEMA_REGISTRY_HOST_NAME=schema-registry - ALLOW_PLAINTEXT_LISTENER='yes' - SCHEMA_REGISTRY_LISTENERS=http://schema-registry:8081 - SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS=PLAINTEXT://kafka:29092 links: - zookeeper - kafka ports: - 8082:8081 kafka-topics-generator: image: confluentinc/cp-kafka:6.2.4 depends_on: kafka: condition: service_healthy entrypoint: [ '/bin/sh', '-c' ] command: | " # blocks until kafka is reachable kafka-topics --bootstrap-server kafka:9092 --list echo -e 'Creating kafka topics' kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic send-order-event --replication-factor 1 --partitions 2 echo -e 'Successfully created the following topics:' kafka-topics --bootstrap-server kafka:9092 --list "
解决方案
报错根源是Schema Registry配置的SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS使用了kafka:29092,但该端口对应Kafka的OUTSIDE监听器,其对外暴露地址为localhost:29092,Docker内部容器通信应使用Kafka的INTERNAL监听器地址kafka:9092。
同时注意ALLOW_PLAINTEXT_LISTENER无需添加单引号,修正后的Schema Registry配置如下:
schema-registry: image: confluentinc/cp-schema-registry:7.3.2 environment: - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2181 - SCHEMA_REGISTRY_HOST_NAME=schema-registry - ALLOW_PLAINTEXT_LISTENER=yes - SCHEMA_REGISTRY_LISTENERS=http://schema-registry:8081 - SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS=PLAINTEXT://kafka:9092 links: - zookeeper - kafka ports: - 8082:8081
内容的提问来源于stack exchange,提问作者Irina
相关产品推荐
相关产品推荐

