Blame
e46c0e | Mayekkuzu | 2025-04-15 20:48:46 | 1 | # Prometheus |
2 | ||||
3 | ## Установка из tarника в случае с Rocky Linux 9 |
|||
4 | ||||
5 | Сразу ставим пакеты (вдруг их нет) |
|||
6 | ```bash |
|||
7 | dnf install wget tar |
|||
8 | ``` |
|||
9 | ||||
10 | Кидаем переменную и качаем файлик с тарником |
|||
11 | ```bash |
|||
12 | VER=2.28.1 |
|||
13 | wget https://github.com/prometheus/prometheus/releases/download/v$VER/prometheus-$VER.linux-amd64.tar.gz -P /tmp |
|||
14 | cd /tmp |
|||
15 | tar -xzf prometheus-$VER.linux-amd64.tar.gz |
|||
16 | ``` |
|||
17 | ||||
18 | Далее перекидываем по папкам |
|||
19 | ```bash |
|||
20 | cp prometheus-$VER.linux-amd64/{prometheus,promtool} /usr/local/bin/ |
|||
21 | cp -r prometheus-$VER.linux-amd64/{consoles,console_libraries} /etc/prometheus/ |
|||
22 | cp prometheus-$VER.linux-amd64/prometheus.yml /etc/prometheus/ |
|||
23 | ``` |
|||
24 | ||||
25 | Накидываем права |
|||
26 | ```bash |
|||
27 | chown -R prometheus:prometheus /etc/prometheus |
|||
28 | chown -R prometheus:prometheus /var/lib/prometheus |
|||
29 | chown prometheus.prometheus /usr/local/bin/{prometheus,promtool} |
|||
30 | ``` |
|||
31 | ||||
32 | Открываем порт 9090 |
|||
33 | ```bash |
|||
34 | firewall-cmd --add-port=9090/tcp --permanent |
|||
35 | firewall-cmd --reload |
|||
36 | ``` |
|||
37 | ||||
38 | Тестовый запуск |
|||
39 | ```bash |
|||
40 | /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml |
|||
41 | ``` |
|||
42 | ||||
43 | Создаем systemd сервис с содержимым: |
|||
44 | ``` |
|||
45 | [Unit] |
|||
46 | Description=Prometheus Server |
|||
47 | Documentation=https://prometheus.io/docs/introduction/overview/ |
|||
48 | After=network-online.target |
|||
49 | ||||
50 | [Service] |
|||
51 | User=prometheus |
|||
52 | Group=prometheus |
|||
53 | Restart=on-failure |
|||
54 | ExecStart=/usr/local/bin/prometheus \ |
|||
55 | --config.file=/etc/prometheus/prometheus.yml \ |
|||
56 | --storage.tsdb.path=/var/lib/prometheus \ |
|||
57 | --storage.tsdb.retention.time=30d |
|||
58 | ||||
59 | [Install] |
|||
60 | WantedBy=multi-user.target |
|||
61 | ``` |
|||
62 | ||||
63 | Рестартим systemd и запускаем сервис: |
|||
64 | ```bash |
|||
65 | systemctl daemon-reload |
|||
66 | systemctl start prometheus |
|||
67 | systemctl enable prometheus |
|||
68 | ``` |