gpt4 book ai didi

java - 配置 JMX 导出器时 Kafka 无法启动

转载 作者:行者123 更新时间:2023-12-01 17:46:18 27 4
gpt4 key购买 nike

我正在尝试为在计算实例 (CentOS 7) 上运行的 Kafka 设置 JMX 导出器。

我从以下位置下载了 JMX Exporter jar 和 Kafka yaml。

wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.12.0/jmx_prometheus_javaagent-0.12.0.jar
wget https://raw.githubusercontent.com/prometheus/jmx_exporter/master/example_configs/kafka-0-8-2.yml

我在“/etc/systemd/system/kafka.service”文件中设置了以下环境变量,如下所示:

Environment="KAFKA_OPTS=$KAFKA_OPTS -javaagent:/home/kafka_user/jmx_kafka_exporter/jmx_prometheus_javaagent-0.12.0.jar=7070:/home/kafka_user/jmx_kafka_exporter/kafka-0-8-2.yml"

执行重新加载并重新启动后; Kafka启动失败。

非常感谢任何关于为计算实例上托管的 Kafka 运行 JMX 导出器的建议。

提前谢谢您,

sudo systemctl daemon-reload
sudo systemctl restart kafka

sudo systemctl status kafka
● kafka.service - Kafka Daemon
Loaded: loaded (/etc/systemd/system/kafka.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Thu 2020-03-26 06:05:52 UTC; 935ms ago
Process: 9842 ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties (code=exited, status=1/FAILURE)
Main PID: 9842 (code=exited, status=1/FAILURE)

Mar 26 06:05:51 kafka1.com systemd[1]: Unit kafka.service entered failed state.
Mar 26 06:05:51 kafka1.com systemd[1]: kafka.service failed.
Mar 26 06:05:52 kafka1.com systemd[1]: kafka.service holdoff time over, scheduling restart.
Mar 26 06:05:52 kafka1.com systemd[1]: Stopped Kafka Daemon.
Mar 26 06:05:52 kafka1.com systemd[1]: start request repeated too quickly for kafka.service
Mar 26 06:05:52 kafka1.com systemd[1]: Failed to start Kafka Daemon.
Mar 26 06:05:52 kafka1.com systemd[1]: Unit kafka.service entered failed state.
Mar 26 06:05:52 kafka1.com systemd[1]: kafka.service failed.

猫/etc/systemd/system/kafka.service

[Unit]
Description=Kafka Daemon
Requires=network.target
After=network.target

[Service]
LimitNOFILE=65536
Environment="JMX_PORT=5555"
Environment="KAFKA_OPTS=-javaagent:/home/kafka_user/jmx_kafka_exporter/jmx_prometheus_javaagent-0.12.0.jar=7070:/home/kafka_user/jmx_kafka_exporter/kafka-2_0_0.yml"
Type=simple
User=kafka
Group=kafka
UMask=0027
ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
Restart=on-failure

[Install]
WantedBy=multi-user.target

最佳答案

在我将“/etc/systemd/system/kafka.service”文件中的“jmx_kafka_exporter”路径从“/home/kafka_user/jmx_kafka_exporter/”更新为“/opt/jmx_kafka_exporter/”之后。

Kafka 的重新加载和重启工作顺利,我看到 jmx_kafka_exporter 在端口 7070 上拍摄日志

netstat -ntlp | grep 70
tcp 0 kafka1:7070 0.0.0.0:* LISTEN 3536/java
tcp6 0 0 :::111 :::* LISTEN 1708/rpcbind


curl http://kafka1:7070/metrics

# HELP jvm_info JVM version info
# TYPE jvm_info gauge
jvm_info{version="1.8.0xx",vendor="XYZ",runtime="Java(TM) SE Runtime Environment",} 1.0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 5.55
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
......
jvm_buffer_pool_used_buffers{pool="direct",} 4.0
jvm_buffer_pool_used_buffers{pool="mapped",} 0.0
# HELP jmx_config_reload_success_total Number of times configuration have successfully been reloaded.
# TYPE jmx_config_reload_success_total counter
jmx_config_reload_success_total 0.0

关于java - 配置 JMX 导出器时 Kafka 无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60862178/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com