docker部署kafka,JWX配置不生效

我超稳的 发表于: 2022-04-22   最后更新时间: 2022-04-22 14:25:42   2,667 游览

docker-compose脚本

version: "2"

services:
  zookeeper:
    image: docker.io/bitnami/zookeeper:3.8
    ports:
      - "12181:2181"
    volumes:
      - "/mydata/zookeeper:/bitnami"
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes
  kafka:
    image: docker.io/bitnami/kafka:3.1
    ports:
      - "19092:9092"
      - "9999:9999"
    volumes:
      - "/mydata/kafka:/bitnami"
    environment:
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
      - JMX_PORT=9999
    depends_on:
      - zookeeper

volumes:
  zookeeper_data:
    driver: local
  kafka_data:
    driver: local

启动命令

docker-compose -f docker-compose.yaml up -d

eagle报错


[2022-04-21 21:52:00] Mx4jServiceImpl.Thread-317 - ERROR - JMX service url[8689eabbf254:-1] create has error,msg is 
 java.lang.ClassCastException: java.io.IOException cannot be cast to javax.management.remote.JMXConnector
    at org.smartloli.kafka.eagle.common.util.JMXFactoryUtils.connectWithTimeout(JMXFactoryUtils.java:103)
    at org.smartloli.kafka.eagle.core.factory.Mx4jServiceImpl.common(Mx4jServiceImpl.java:231)
    at org.smartloli.kafka.eagle.core.factory.Mx4jServiceImpl.produceMessageConversionsPerSec(Mx4jServiceImpl.java:168)
    at org.smartloli.kafka.eagle.web.quartz.MBeanSubTask$MbeanOfflineSubThread.kafkaMBeanOfflineAssembly(MBeanSubTask.java:429)
    at org.smartloli.kafka.eagle.web.quartz.MBeanSubTask$MbeanOfflineSubThread.brokerMbeanOffline(MBeanSubTask.java:323)
    at org.smartloli.kafka.eagle.web.quartz.MBeanSubTask$MbeanOfflineSubThread.run(MBeanSubTask.java:308)
[2022-04-21 21:52:00] KafkaServiceImpl.Thread-315 - ERROR - Get kafka os memory from jmx has error, msg is java.io.IOException cannot be cast to javax.management.remote.JMXConnector
 [2022-04-21 21:52:00] KafkaServiceImpl.Thread-315 - ERROR - Get kafka os memory from jmx has error, msg is java.io.IOException cannot be cast to javax.management.remote.JMXConnector
 [2022-04-21 21:52:00] KafkaServiceImpl.Thread-315 - ERROR - Get kafka broker used cpu value has error, msg is 
 java.lang.ClassCastException: java.io.IOException cannot be cast to javax.management.remote.JMXConnector
    at org.smartloli.kafka.eagle.common.util.JMXFactoryUtils.connectWithTimeout(JMXFactoryUtils.java:103)
    at org.smartloli.kafka.eagle.core.factory.KafkaServiceImpl.getUsedCpuValue(KafkaServiceImpl.java:1706)
    at org.smartloli.kafka.eagle.web.quartz.MBeanSubTask$KafkaClusterSubThread.kafkaAssembly(MBeanSubTask.java:214)
    at org.smartloli.kafka.eagle.web.quartz.MBeanSubTask$KafkaClusterSubThread.kafkaCluster(MBeanSubTask.java:121)
    at org.smartloli.kafka.eagle.web.quartz.MBeanSubTask$KafkaClusterSubThread.run(MBeanSubTask.java:104)
发表于 2022-04-22
添加评论

你需要指定容器的hostname,如:

-Djava.rmi.server.hostname=设备的ip

但docker容器内的ip是随机的,你需要动态的设置ip,如:

-Djava.rmi.server.hostname=$(hostname -i)
你的答案

查看kafka相关的其他问题或提一个您自己的问题