0

我正在尝试设置 confluent kafka v5.4 并运行 prometheus JMX 导出器。我找到了这篇关于如何获得此设置的博客https://alex.dzyoba.com/blog/jmx-exporter/。Kafka 已设置并运行良好,但端口 8080 上的端点没有返回任何内容。我已经尝试了关于如何在 systemd 脚本中调用 javaagent 的所有方法,但似乎没有任何效果。

Description=Confluent Kafka Broker
After=network.target network-online.target remote-fs.target  zookeeper.service

[Service]
Type=forking
User=confluent
Group=confluent
Environment="KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false -javaagent=/opt/prometheus/jmx_prometheus_javaagent.jar=8080:/opt/prometheus/config.yaml"
Environment=LOG_DIR=/var/log/confluent
ExecStart=/opt/confluent/confluent-5.4.0/bin/kafka-server-start -daemon /opt/confluent/confluent-5.4.0/etc/kafka/server.properties
ExecStop=/opt/confluent/confluent-5.4.0/bin/kafka-server-stop
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

关于如何在 systemd 脚本中调用该 java 代理以使其正常工作的任何想法?我尝试了多种调用 OPTS 的选项,但它们都不起作用。我尝试将 -javaagent 命令放入 KAFKA_OPTS。感觉就像我已经尝试了几乎所有选项。Kafka 日志没有提供任何线索,我不确定在哪里可以查看此类问题的日志。

操作系统 Centos 7 JMX 导出器 0.12.0 Java openJDK 11

我发现的日志并没有告诉我为什么它没有运行。也许我正在查看错误的日志。

编辑:

conflue+ 11578 47.4 13.8 8679808 536764 ?      Sl   11:59   0:35 java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true -Xlog:gc*:file=/var/log/confluent/kafkaServer-gc.log:time,tags:filecount=10,filesize=102400 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -javaagent=/opt/prometheus/jmx_prometheus_javaagent.jar=8080:/opt/prometheus/config.yaml -Dkafka.logs.dir=/var/log/confluent -Dlog4j.configuration=file:/etc/kafka/log4j.properties -cp /opt/confluent/confluent-5.4.0/bin/../ce-broker-plugins/build/libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-broker-plugins/build/dependant-libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-auth-providers/build/libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-auth-providers/build/dependant-libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-rest-server/build/libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-rest-server/build/dependant-libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-audit/build/libs/*:/opt/confluent/confluent-5.4.0/bin/../ce-audit/build/dependant-libs/*:/opt/confluent/confluent-5.4.0/bin/../share/java/kafka/*:/opt/confluent/confluent-5.4.0/bin/../share/java/confluent-metadata-service/*:/opt/confluent/confluent-5.4.0/bin/../share/java/rest-utils/*:/opt/confluent/confluent-5.4.0/bin/../share/java/confluent-common/*:/opt/confluent/confluent-5.4.0/bin/../share/java/confluent-security/schema-validator/*:/opt/confluent/confluent-5.4.0/bin/../support-metrics-client/build/dependant-libs-2.12.10/*:/opt/confluent/confluent-5.4.0/bin/../support-metrics-client/build/libs/*:/usr/share/java/support-metrics-client/*:/opt/confluent/confluent-5.4.0/bin/../support-metrics-fullcollector/build/dependant-libs-2.12.10/*:/opt/confluent/confluent-5.4.0/bin/../support-metrics-fullcollector/build/libs/*:/usr/share/java/support-metrics-fullcollector/* io.confluent.support.metrics.SupportedKafka /opt/confluent/confluent-5.4.0/etc/kafka/server.properties
4

2 回答 2

0

确保systemctl daemon-reload每次编辑服务文件时都运行。


另外,我建议不要使用LOG_DIR,从 中删除 RollingFileAppender log4j.properties,然后让journalctl处理来自 SystemD 的所有日志记录

于 2020-04-30T20:31:35.970 回答
0

想通了 ExecStart=/opt/confluent/confluent-5.4.0/bin/kafka-server-start -daemon /opt/confluent/confluent-5.4.0/etc/kafka/server.properties

不正确

ExecStart=/opt/confluent/confluent-5.4.0/bin/kafka-server-start -daemon /etc/kafka/server.properties

是正确的,即使 2 是符号链接的。

于 2020-05-04T19:52:48.590 回答