kafka的docker compose文件中的env变量应该连接到导出JMX指标

时间:2020-07-06 16:06:41

标签: docker jmx apache-kafka-connect

PFB我使用过的撰写文件配置

version: '2'
services:
  kafka-connect:
    image: confluentinc/cp-kafka-connect:5.5.0
    hostname: kafka-connect
    ports:
      - "8083:8083"
      - "8000:8000"
    environment:
      CONNECT_BOOTSTRAP_SERVERS: "kafk_server_host_name:9092"
      CONNECT_REST_PORT: 8083
      CONNECT_GROUP_ID: compose-connect-group
      CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs
      CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets
      CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status
      CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_REST_ADVERTISED_HOST_NAME: "kafka-connect"
      CONNECT_LOG4J_ROOT_LOGLEVEL: "INFO"
      CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "1"
      CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "1"
      CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "1"
      KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false - 
      Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 - 
      Dcom.sun.management.jmxremote.rmi.port=8000"
      CONNECT_PLUGIN_PATH: '/usr/share/java,/etc/kafka-connect/jars'
    volumes:
      - ./libs:/etc/kafka-connect/jars/

当我尝试使用jconsole连接到localhost 8000时,在docker中启动kafka连接后,出现以下错误:

java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.io.EOFException

请帮助排除错误。我不确定我使用的env变量是否正确。

我还有一个问题:在kafka中公开jmx端口是否还为kafka connect提供了指标,还是应该分别从kafka和kafka connect中获取指标?

1 个答案:

答案 0 :(得分:0)

如罗宾·莫法特(Robin Moffatt)提供的资源中所述

https://rmoff.net/2018/09/17/accessing-kafka-docker-containers-jmx-from-host/

我提到了两个变量KAFKA_JMX_HOSTNAME和KAFKA_JMX_PORT,并且使用了9010端口,因为其他端口在问题中给了我jrmf错误