美文网首页
10.Prometheus 一篇就够

10.Prometheus 一篇就够

作者: starQuest | 来源:发表于2022-06-27 10:21 被阅读0次

    参考博客:

    https://wiki.eryajf.net/pages/2497.html#_1%E3%80%81%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2

    10.0 安装路径

    x.x.x.3:/home/monitor

    下载

    $ wget https://github.com/prometheus/prometheus/releases/download/v2.4.2/prometheus-2.4.2.linux-amd64.tar.gz

    $ wget https://github.com/prometheus/alertmanager/releases/download/v0.15.2/alertmanager-0.15.2.linux-amd64.tar.gz

    $ wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz

    10.1 运行用户创建

    groupadd prometheus2

    useradd -g prometheus2 -m -d /home/monitor/prometheus/ -s /sbin/nologin prometheus2

    10.2 prometheus server安装

    tar -zxvf prometheus-2.14.0.linux-amd64.tar.gz

    cd /home/monitor/prometheus-2.14.0.linux-amd64

    10.3****prometheus配置语法校验

    ./promtool check config prometheus.yml

    10.4启动与自启动

    ./prometheus --config.file=prometheus.yml

    touch /usr/lib/systemd/system/prometheus.service

    chown prometheus2:prometheus2 /usr/lib/systemd/system/prometheus.service

    vim /usr/lib/systemd/system/prometheus.service

    配置prometheus.service

    [Unit]

    Description=Prometheus

    Documentation=https://prometheus.io/

    After=network.target

    [Service]

    Type=simple

    User=prometheus2

    --storage.tsdb.path是可选项,默认数据目录在运行目录的./dada目录中

    ExecStart=/home/monitor/prometheus/prometheus --config.file=/home/monitor/prometheus/prometheus.yml --web.enable-lifecycle --storage.tsdb.path=/home/monitor/prometheus/data --storage.tsdb.retention=60d

    Restart=on-failure

    [Install]

    WantedBy=multi-user.target

    自启动

    systemctl daemon-reload

    systemctl enable prometheus.service

    systemctl start prometheus.service

    systemctl status prometheus.service

    systemctl restart prometheus.service systemctl stop prometheus.service

    10.5 注意

    自启动失败Failed to start Prometheus. 权限问题

    image.png

    sudo chown -R prometheus2:prometheus2 /home/monitor/prometheus

    image.png

    相关文章

      网友评论

          本文标题:10.Prometheus 一篇就够

          本文链接:https://www.haomeiwen.com/subject/hnasvrtx.html