普罗米修斯prometheus(1) - 安装

下载地址:https://prometheus.io/download/
这里以prometheus-2.15.2.linux-amd64.tar.gz为例
下载到 /home/用户名/prometheus-2.15.2.linux-amd64.tar.gz

// 解压缩
# tar -xzvf prometheus-2.15.2.linux-amd64.tar.gz
# mkdir /usr/local/prometheus
# mv prometheus-2.15.2.linux-amd64 /usr/local/prometheus/prometheus
// 查看版本
# ./prometheus --version

// 创建本地存储目录(tsdb时序数据库)
# mkdir -p /usr/local/prometheus/data

// 添加用户和用户组,用此账号启动prometheus服务
# groupadd prometheus
# useradd -g prometheus -s /sbin/nologin prometheus
// 赋权
# chown -R prometheus:prometheus /usr/local/prometheus/prometheus
# chown -R prometheus:prometheus /usr/local/prometheus/data
// 添加启动服务
# vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description= Prometheus
After=network.target
# Type设置为notify时,服务会不断重启# User设置对应上面创建的账号
# 存储配置, 
# By default, Prometheus stores its database in ./data (flag --storage.tsdb.path).
# --storage.tsdb.path: 存储数据的目录,默认为./data
# --storage.tsdb.retention.time: 数据过期清理时间,默认保存15天
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
// 自动重启服务
# systemctl enable prometheus.service
// 启动服务
# systemctl start prometheus.service
// 查看服务状态
# systemctl status prometheus.service
// 浏览器查看服务状态
http://服务器ip:9090

你可能感兴趣的:(普罗米修斯prometheus(1) - 安装)