bin / kafka-run-class.sh:第304行::使用JMX Prometheus导出器启动Zookeeper时,没有这样的文件或目录

时间:2019-04-28 04:23:28

标签: apache-kafka apache-zookeeper

我正在尝试使用kafka_2.12_2.2.0启动Zookeeper。

正常启动时,它工作正常。

我想使用Prometheus JMX导出器导出Zookeeper指标。

我在目录jmx_prometheus_javaagent-0.11.0.jar中有zookeeper.yaml/home/vagrant/prometheus

/home/vagrant/prometheus/zookeeper.yaml的内容-

    $ cat /home/vagrant/prometheus/zookeeper.yaml 
    rules:
    # replicated Zookeeper
    - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+)><>(\\w+)"
        name: "zookeeper_$2"
    - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+)><>(\\w+)"
        name: "zookeeper_$3"
        labels:
        replicaId: "$2"
    - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+)><>(\\w+)"
        name: "zookeeper_$4"
        labels:
        replicaId: "$2"
        memberType: "$3"
    - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+), name3=(\\w+)><>(\\w+)"
        name: "zookeeper_$4_$5"
        labels:
        replicaId: "$2"
        memberType: "$3"
    # standalone Zookeeper
    - pattern: "org.apache.ZooKeeperService<name0=StandaloneServer_port(\\d+)><>(\\w+)"
        name: "zookeeper_$2"
    - pattern: "org.apache.ZooKeeperService<name0=StandaloneServer_port(\\d+), name1=InMemoryDataTree><>(\\w+)"
        name: "zookeeper_$2"

/etc/init.d/zookeeper文件的内容是-

    #!/bin/bash
    #/etc/init.d/zookeeper
    DAEMON_PATH=/home/vagrant/kafka/bin
    DAEMON_NAME=zookeeper
    # Check that networking is up.
    #[ ${NETWORKING} = "no" ] && exit 0

    PATH=$PATH:$DAEMON_PATH
    export PROM_HOME=/home/vagrant/prometheus
    export EXTRA_ARGS="-javaagent:$PROM_HOME/jmx_prometheus_javaagent-0.11.0.jar=8080:$PROM_HOME/zookeeper.yaml"
    # See how we were called.
    case "$1" in
    start)
            # Start daemon.
            pid=`ps ax | grep -i 'org.apache.zookeeper' | grep -v grep | awk '{print $1}'`
            if [ -n "$pid" ]
            then
                echo "Zookeeper is already running";
            else
            echo "Starting $DAEMON_NAME";
            echo "DAEMON_PATH is $DAEMON_PATH"
            $DAEMON_PATH/zookeeper-server-start.sh -daemon /home/vagrant/kafka/config/zookeeper.properties
            fi
            ;;
    stop)
            echo "Shutting down $DAEMON_NAME";
            $DAEMON_PATH/zookeeper-server-stop.sh
            ;;
    restart)
            $0 stop
            sleep 2
            $0 start
            ;;
    status)
            pid=`ps ax | grep -i 'org.apache.zookeeper' | grep -v grep | awk '{print $1}'`
            if [ -n "$pid" ]
            then
            echo "Zookeeper is Running as PID: $pid"
            else
            echo "Zookeeper is not Running"
            fi
            ;;
    *)
            echo "Usage: $0 {start|stop|restart|status}"
            exit 1
    esac

    exit 0

当我在/etc/init.d/zookeeper中取消注释以下两行时,它运行正常。

导出PROM_HOME = / home / vagrant / prometheus         export EXTRA_ARGS =“-javaagent:$ PROM_HOME / jmx_prometheus_javaagent-0.11.0.jar = 8080:$ PROM_HOME / zookeeper.yaml”

否则,我得到以下错误-

    $ sudo service zookeeper start
    Starting zookeeper
    DAEMON_PATH is /home/vagrant/kafka/bin
    [vagrant@localhost ~]$ /home/vagrant/kafka/bin/kafka-run-class.sh: line 304: : No such file or directory

下面是我的其他细节-

    $ java -version
    java version "1.8.0_211"
    Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

JAVA_HOME env变量是-

    $ echo $JAVA_HOME
    /usr/java/latest

操作系统详细信息为-

    $ cat /etc/os-release 
    NAME="CentOS Linux"
    VERSION="7 (Core)"
    ID="centos"
    ID_LIKE="rhel fedora"
    VERSION_ID="7"
    PRETTY_NAME="CentOS Linux 7 (Core)"
    ANSI_COLOR="0;31"
    CPE_NAME="cpe:/o:centos:centos:7"
    HOME_URL="https://www.centos.org/"
    BUG_REPORT_URL="https://bugs.centos.org/"

    CENTOS_MANTISBT_PROJECT="CentOS-7"
    CENTOS_MANTISBT_PROJECT_VERSION="7"
    REDHAT_SUPPORT_PRODUCT="centos"
    REDHAT_SUPPORT_PRODUCT_VERSION="7"

如何解决此问题并成功导出Zookeeper的JMX指标?

0 个答案:

没有答案