使用 proectuslabs UI 运行 Kafka 集群

问题描述 投票:0回答:1

我尝试在 docker 中使用 proectuslabs-ui 设置 Kafka 集群:

name: 'test-kafka'
    services:
    kafka-1:
        image: 'bitnami/kafka:latest'
        container_name: 'kafka-1'
        ports:
        - '9092:9092'
        - '29092:29092'
        environment:
            # KRaft mode settings
            KAFKA_ENABLE_KRAFT: 'true'
            KAFKA_CFG_NODE_ID: 1
            KAFKA_BROKER_ID: 1
            KAFKA_CFG_CLUSTER:ID: 'abcdefghijklmnopqrstuv'
            KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@kafka-1:9092,2@kafka-2:9093,3@kafka-3:9094
            KAFKA_CFG_PROCESS_ROLES: controller,broker
            # Listeners settings
            KAFKA_CFG_LISTENERS: BROKER://:9092,CONTROLLER://0.0.0.0:29092
            KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-1:9092,CONTROLLER://localhost:29092
            KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,BROKER:PLAINTEXT
            KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
            KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER
            # Clustering
            KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
            KAFKA_CFG_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3
            KAFKA_CFG_TRANSACTION_STATE_LOG_MIN_ISR: 2

    kafka-2:
        image: 'bitnami/kafka:latest'
        container_name: 'kafka-2'
        ports:
        - '9093:9093'
        - '29093:29093'
        environment:
            # KRaft mode settings
            KAFKA_ENABLE_KRAFT: 'true'
            KAFKA_CFG_NODE_ID: 2
            KAFKA_BROKER_ID: 2
            KAFKA_CFG_CLUSTER:ID: 'abcdefghijklmnopqrstuv'
            KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@kafka-1:9092,2@kafka-2:9093,3@kafka-3:9094
            KAFKA_CFG_PROCESS_ROLES: controller,broker
            # Listeners settings
            KAFKA_CFG_LISTENERS: BROKER://:9093,CONTROLLER://0.0.0.0:29093
            KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-2:9093,CONTROLLER://localhost:29093
            KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,BROKER:PLAINTEXT
            KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
            KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER
            # Clustering
            KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
            KAFKA_CFG_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3
            KAFKA_CFG_TRANSACTION_STATE_LOG_MIN_ISR: 2

    kafka-3:
        image: 'bitnami/kafka:latest'
        container_name: 'kafka-3'
        ports:
        - '9094:9094'
        - '29094:29094'
        environment:
            # KRaft mode settings
            KAFKA_ENABLE_KRAFT: 'true'
            KAFKA_CFG_NODE_ID: 3
            KAFKA_BROKER_ID: 3
            KAFKA_CFG_CLUSTER:ID: 'abcdefghijklmnopqrstuv'
            KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@kafka-1:9092,2@kafka-2:9093,3@kafka-3:9094
            KAFKA_CFG_PROCESS_ROLES: controller,broker
            # Listeners settings
            KAFKA_CFG_LISTENERS: BROKER://:9094,CONTROLLER://0.0.0.0:29094
            KAFKA_CFG_ADVERTISED_LISTENERS: BROKER://kafka-3:9094,CONTROLLER://localhost:29094
            KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,BROKER:PLAINTEXT
            KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
            KAFKA_CFG_INTER_BROKER_LISTENER_NAME: BROKER
            # Clustering
            KAFKA_CFG_OFFSETS_TOPIC_REPLICATION_FACTOR: 3
            KAFKA_CFG_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3
            KAFKA_CFG_TRANSACTION_STATE_LOG_MIN_ISR: 2

    kafka-ui:
        image: 'provectuslabs/kafka-ui:latest'
        container_name: 'kafka-ui'
        ports:
        - '1354:8080'
        depends_on:
        - kafka-1
        - kafka-2
        - kafka-3
        environment:
            KAFKA_CLUSTERS_0_NAME: test-local
            KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka-1:9092,kafka-2:9093,kafka-3:9094

当我启动服务时,我收到错误:

  1. UI无法与集群节点建立连接
  2. 节点本身无法相互连接

用户界面错误:

2025-01-15 19:02:33 2025-01-15 16:02:33,796 信息 [kafka-admin-客户端线程 | kafka-ui-admin-1736956953-1] o.a.k.c.NetworkClient: [AdminClient clientId=kafka-ui-admin-1736956953-1] 节点-1已断开连接。

2025-01-15 19:02:33 2025-01-15 16:02:33,800 警告 [kafka-admin-client-thread | kafka-ui-admin-1736956953-1] o.a.k.c.NetworkClient:[AdminClient clientId=kafka-ui-admin-1736956953-1] 连接到节点-1 (kafka-1/172.18.0.3:9092)无法建立。经纪人可能不是 可用。

2025-01-15 19:02:33 2025-01-15 16:02:33,807 信息 [kafka-admin-客户端线程 | kafka-ui-admin-1736956953-1] o.a.k.c.NetworkClient: [AdminClient clientId=kafka-ui-admin-1736956953-1] 节点-2已断开连接。

2025-01-15 19:02:33 2025-01-15 16:02:33,808 警告 [kafka-admin-client-thread | kafka-ui-admin-1736956953-1] o.a.k.c.NetworkClient:[AdminClient clientId=kafka-ui-admin-1736956953-1] 连接到节点-2 (kafka-2/172.18.0.4:9093)无法建立。经纪人可能不是 可用。

2025-01-15 19:02:33 2025-01-15 16:02:33,812 信息 [kafka-admin-客户端线程 | kafka-ui-admin-1736956953-1] o.a.k.c.NetworkClient: [AdminClient clientId=kafka-ui-admin-1736956953-1] 节点-3已断开连接。

2025-01-15 19:02:33 2025-01-15 16:02:33,813 警告 [kafka-admin-client-thread | kafka-ui-admin-1736956953-1] o.a.k.c.NetworkClient:[AdminClient clientId=kafka-ui-admin-1736956953-1] 连接到节点-3 (kafka-3/172.18.0.2:9094)无法建立。经纪人可能不是 可用。

节点错误(kafka-1节点示例):

2025-01-15 19:03:18 [2025-01-15 16:03:18,188] 信息 [RaftManager id=1] 节点 2 已断开连接。 (org.apache.kafka.clients.NetworkClient)

2025-01-15 19:03:18 [2025-01-15 16:03:18,188] 警告 [RaftManager id=1] 无法连接到节点 2 (kafka-2/172.18.0.4:9093) 已确立的。节点可能不可用。 (org.apache.kafka.clients.NetworkClient)

2025-01-15 19:03:18 [2025-01-15 16:03:18,188] 信息 [RaftManager id=1] 节点 3 已断开连接。 (org.apache.kafka.clients.NetworkClient)

2025-01-15 19:03:18 [2025-01-15 16:03:18,188] 警告 [RaftManager id=1] 连接到节点 3 (kafka-3/172.18.0.2:9094)无法建立。节点可能不是 可用的。 (org.apache.kafka.clients.NetworkClient)

apache-kafka kraft provectuslabs-kafka-ui
1个回答
0
投票

有一堆现成的 compose 配置可用: https://github.com/kafbat/kafka-ui/tree/main/documentation/compose 请随意尝试其中之一。

在您的特定情况下,应该有一个

plaintext
广告监听器,而不是
broker
一个:

KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka0:29092,PLAINTEXT_HOST://localhost:9092

如果您有任何其他问题,请随时加入我们在 github 或我们的 Discord 服务器上的讨论(链接可在存储库的自述文件中找到)。

© www.soinside.com 2019 - 2024. All rights reserved.