Prometheus是一个时间序列数据库,常用于监控,下面我们在CentOS7上部署一个Prometheus软件。
第一步、创建Prometheus目录
mkdir /usr/local/prometheus
第二步、下载Prometheus文件包
cd /usr/local/src
#官方网站:https://prometheus.io/download/
https://github.com/prometheus/prometheus/releases/download/v2.9.1/prometheus-2.9.1.linux-amd64.tar.gz
第三步、解压缩
tar zxvf prometheus-2.9.1.linux-amd64.tar.gz
mv prometheus-2.9.1.linux-amd64 /usr/local/prometheus
第四步、创建Promethdus Systemd服务
cat >/etc/systemd/system/nginx.service <<EOF
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=prometheus
Restart=on-failure
#Change this line if you download the
#Prometheus on different path user
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/usr/local/prometheus/prometheus.yml \
--storage.tsdb.path=/usr/local/prometheus/data \
--web.enable-admin-api
[Install]
WantedBy=multi-user.target
EOF
第五步、创建prometheus用户和组
groupadd prometheus
useradd -g prometheus prometheus
cd /usr/local/prometheus
chown -R prometheus.prometheus *
第六步、启动Prometheus服务
systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus
第七步、访问测试
curl http://localhost:9090
后续,请修改/usr/local/prometheus/prometheus.yml配置文件