0

我已经使用 docker 建立了一个基本的 Zookeeper 和 kafka 版本 5.4.0 的三服务器集群。对于 zookeeper 和 kafka,我已经指定了所有三个引导服务器。我正在尝试以允许一台服务器关闭并且集群仍将正常运行的方式进行设置。我正在尝试让控制中心正常工作,但遇到了问题。首先,似乎只有一个服务器能够成功运行控制中心,并且只有当我指定它正在运行的引导服务器时,而不是所有三个服务器。如果我尝试在其他两台服务器上启动控制中心,它们将无法启动,并且会不断记录以下内容:

INFO unable to get command store (io.confluent.command.CommandStore)

我不确定如何最好地完成这项工作。因为它可能会有所帮助,所以我在我的 docker-compose 文件下方发布了 zookeeper/broker 对以及控制中心的文件。如果我有任何错误指定或您认为需要更改,请告诉我。

zookeeper/kafka 代理 docker-compose.yml (其他仅通过广告侦听器 IP 不同):

---
version: '2'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:5.4.0
    hostname: zookeeper
    container_name: zookeeper
    network_mode: host
    restart: always
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_SERVER_ID: 2
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_INIT_LIMIT: 5
      ZOOKEEPER_SYNC_LIMIT: 2
      ZOOKEEPER_SERVERS: "10.100.1.1:2888:3888;10.100.1.2:2888:3888;10.100.1.3:2888:3888"
    volumes:
      - ./zk-data:/var/lib/zookeeper/data
      - ./zk-txn-logs:/var/lib/zookeeper/log

  broker:
    image: confluentinc/cp-enterprise-kafka:5.4.0
    hostname: broker
    container_name: broker
    depends_on:
      - zookeeper
    network_mode: host
    restart: always
    ports:
      - "9092:9092"
    environment:
      KAFKA_BROKER_ID: 2
      KAFKA_ZOOKEEPER_CONNECT: '10.100.1.1:2181,10.100.1.2:2181,10.100.1.3:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://10.100.1.1:9092"
      KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 2
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: 10.100.1.1:9092,10.100.1.2:9092,10.100.1.3:9092
      CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: 10.100.1.1:2181,10.100.1.2:2181,10.100.1.3:2181
      CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 2
      CONFLUENT_METRICS_ENABLE: 'true'
      CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
    volumes:
      - ./kafka-data:/var/lib/kafka/data

控制中心 docker-compose.yml:

---
version: '2'
services:
  control-center:
    image: confluentinc/cp-enterprise-control-center:5.4.0
    hostname: control-center
    container_name: control-center
    network_mode: host
    restart: always
    ports:
      - "9021:9021"
    environment:
      CONTROL_CENTER_BOOTSTRAP_SERVERS: '10.100.1.1:9092'
      CONTROL_CENTER_ZOOKEEPER_CONNECT: '10.100.1.1:2181'
      CONTROL_CENTER_REPLICATION_FACTOR: 1
      CONTROL_CENTER_INTERNAL_TOPICS_PARTITIONS: 1
      CONTROL_CENTER_MONITORING_INTERCEPTOR_TOPIC_PARTITIONS: 1
      CONFLUENT_METRICS_TOPIC_REPLICATION: 1
      PORT: 9021
    volumes:
      - ./control-center:/var/lib/confluent-control-center
4

1 回答 1

1

1) 删除network_mode: host

2l 将控制中心添加到同一个撰写文件中

3)zookeeper:2181用于 Zookeeper 连接字符串和kafka:9092引导服务器。我认为指标报告者或控制中心没有 Zookeeper 属性


如果你想创建一个容器集群,那么你可能想看看 Confluent Helm Charts 而不是 Docker compose files

于 2020-03-07T15:11:54.250 回答