16.04에 최신 버전의 Prometheus를 어떻게 설치합니까?

16.04에 최신 버전의 Prometheus를 어떻게 설치합니까?

Ubuntu 16.04를 새로 설치할 때 최신 버전의 Prometheus를 설치하는 데 문제가 있습니다. 내가 찾을 수 있는 모든 가이드는 14.04용이며 systemV에서 systemd로 이동하면 16.04에서 설정할 때 이러한 가이드가 호환되지 않거나 적어도 불완전해집니다.

apt에서 Prometheus를 설치할 수 있지만 버전 0.16.2가 설치되고 현재 버전은 1.0.2입니다.

저는 공식을 이용했어요.prometheus.io 설치 가이드그리고Digital Ocean에 대한 이 가이드.

누구든지 시스템 설정을 도와줄 수 있나요? 나는 Ubuntu에 대해 상대적으로 경험이 있지만 시스템 변경으로 인해 커브 볼이 생겼습니다.

답변1

프로메테우스를 설치할 때 다음 단위 파일이 저에게 효과적이었습니다.섬기는 사람버전 1.x(수출자와 반대).

# /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
User=prometheus
Restart=on-failure
ExecStart=/usr/local/bin/prometheus-1.1.2.linux-amd64/prometheus \
                                -config.file=/etc/prometheus/prometheus.yml \
                                -storage.local.path=/var/lib/prometheus/data

[Install]
WantedBy=multi-user.target

물론 이는 prometheus 사용자를 생성하고 필요한 권한을 부여했다고 가정합니다.

그런 다음 WInfly에서 언급한 명령을 사용하십시오.

$ sudo systemctl daemon-reload
$ sudo systemctl enable prometheus
$ sudo systemctl start prometheus
$ sudo systemctl status prometheus

다음 내용이 도움이 되었습니다.

프로메테우스:https://blog.svedr.in/posts/prometheus-quick-start.html

단위 파일 지시어에 대한 매뉴얼 페이지:https://www.freedesktop.org/software/systemd/man/systemd.directives.html

답변2

버전 2.x에서 서버 저장소 인수 이름이 변경되었습니다. 구문은 다음과 같습니다.

[Unit]
Description=Prometheus Server
After=network-online.target

[Service]
User=root
Restart=on-failure
ExecStart=/usr/local/bin/prometheus-2.2.1.linux-amd64/prometheus \
                                --config.file=/etc/prometheus/prometheus.yml \
                                --storage.tsdb.path=/var/lib/prometheus/data

[Install]
WantedBy=multi-user.target

답변3

나는 내 대답을 찾았습니다이 기사. systemd를 사용하여 실행하도록 설정하려고 할 때 누락된 특정 부분은 유닛 파일을 생성하는 것이었습니다. 다음은 node_exporter에 대한 유닛 파일을 생성한 후 서비스로 실행하는 것입니다. 이것이 다른 누군가에게 도움이 되기를 바랍니다!

유닛 파일을 생성합니다:

$ sudo vim /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter

[Service]
User=vxx
ExecStart=/home/vxx/Prometheus/node_exporter/node_exporter

[Install]
WantedBy=default.target

그런 다음 데몬을 다시 로드하거나 서버를 재부팅한 후 서비스를 시작합니다.

$ sudo systemctl daemon-reload
$ sudo systemctl enable node_exporter.service
$ sudo systemctl start node_exporter.service
$ sudo systemctl status node_exporter.service

답변4

누군가 여전히 이 질문으로 돌아오면 다음을 기반으로 prometheus, node_exporter 및 apache_exporter 설치를 스크립트화했습니다.이 DigitalOcean 튜토리얼.

여기에서 내 스크립트를 찾을 수 있습니다. https://github.com/icolwell/install_scripts

다음 스크립트에 관심이 있을 수 있습니다.

prometheus_install.bash
prometheus_node_exporter_install.bash
prometheus_apache_exporter_install.bash

다음을 사용하여 스크립트를 다운로드하고 실행할 수 있습니다.

wget https://raw.githubusercontent.com/icolwell/install_scripts/master/prometheus_install.bash
bash prometheus_install.bash

기존 prometheus 구성이 재정의됩니다.

관련 정보