参考博客:
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
下载
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.pngsudo chown -R prometheus2:prometheus2 /home/monitor/prometheus
image.png
网友评论