性能测试——性能测试-linux监控工具-Centos7.x安装Prometheus
此处参考小菠萝文档:https://www.cnblogs.com/poloyy/p/12375039.html
下载安装Prometheus
PROM_PATH='/data/prometheus' mkdir -p ${PROM_PATH} mkdir -p ${PROM_PATH}/{data,conf,logs,bin} useradd prometheus cd /usr/local/src wget https://github.com/prometheus/prometheus/releases/download/v2.13.0/prometheus-2.13.0.linux-amd64.tar.gz tar -xvf prometheus-2.13.0.linux-amd64.tar.gz cd prometheus-2.13.0.linux-amd64/ cp prometheus promtool ${PROM_PATH}/bin/ cp prometheus.yml ${PROM_PATH}/conf/ chown -R prometheus.prometheus /data/prometheus # Setting Variables cat >> /etc/profile <<EOF PATH=/data/prometheus/bin:$PATH:$HOME/bin EOF
将Prometheus配置系统服务
cat >>/etc/systemd/system/prometheus.service <<EOF [Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus/bin/prometheus --config.file=/data/prometheus/conf/prometheus.yml --storage.tsdb.path=/data/prometheus/data --storage.tsdb.retention=90d Restart=on-failure [Install] WantedBy=multi-user.target EOF
现在使用下面的systemctl命令重新加载systemd系统,并查看服务是否启动
systemctl daemon-reload
systemctl enable prometheus.service
systemctl start prometheus.service
systemctl status prometheus.servic
查看端口是否正常
netstat -plntu |grep 9090
这里需要放行9090端口,也可以直接关闭防火墙
systemctl stop firewalld
systemctl status firewall
访问http://IP:9090
出现上图就是成功了!!
=======================================================================
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/data/prometheus/bin/prometheus --config.file=/data/prometheus/conf/prometheus.yml --storage.tsdb.path=/data/prometheus/data --storage.tsdb.retention=90d
Restart=on-failure
[Install]
WantedBy=multi-user.target
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
执行:
vim /etc/systemd/system/prometheus.service 命令
[Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/data/prometheus/bin/prometheus --config.file=/data/prometheus/conf/prometheus.yml --storage.tsdb.path=/data/prometheus/data --storage.tsdb.retention=90d Restart=on-failure [Install] WantedBy=multi-user.target [Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target
==========================================================