centos7 部署Prometheus
前言:
一、前置环境说明
1、关闭firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
2、关闭selinux
vim /etc/selinux/config
SELINUX=disabled
使配置立即生效,重启永久生效
setenforce 0
3、系统约定
软件源代码包存放位置:/opt
源码包编译安装位置:/usr/local/软件名字
数据存储位置:/data
二、部署Prometheus server
1、创建用户
useradd -d /data/prometheus -s /sbin/nologin prometheus
2、解压软件包
下载地址:https://prometheus.io/download/
tar xzvf prometheus-2.26.0.linux-amd64.tar.gz -C /usr/local/
授权属主属组
chown -R prometheus:prometheus prometheus/
ln -s /usr/local/prometheus-2.26.0.linux-amd64/ /usr/local/prometheus
已服务启动
cat >> /usr/lib/systemd/system/prometheus.service<<EOF
[Unit]
Description=Prometheus server Daemon
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus --storage.tsdb.retention=15d --web.enable-lifecycle
Restart = on-failure
[Install]
WantedBy=multi-user.target
EOF
3、启动服务
systemctl daemon-reload
systemctl enable prometheus --now
systemctl start prometheus
查看进程
netstat -tunlp | grep 9090
cd /usr/local/prometheus
./promtool check config prometheus.yml