安装prometheus
下载prometheus的安装包
现在 /opt 目录创建 prometheus的目录,下载tar包进行解压
cd /opt/
mkdir prometheus
cd prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.55.1/prometheus-2.55.1.linux-amd64.tar.gz
tar -zxvf prometheus-2.55.1.linux-amd64.tar.gz
编写 service 文件
ln -s /opt/prometheus/prometheus-2.55.1.linux-amd64 /usr/local/prometheus
vim /usr/lib/systemd/system/prometheus.service
对于的service文件如下
[root@loaclhost home]# vim prometheus.service
[Unit]
Description=Prometheus service
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --log.level=warn --storage.tsdb.path=/usr/local/prometheus/data/
Restart=on-failure
ExecStop=/usr/bin/kill -9 MAINPID
[Install]
WantedBy=multi-user.target
启动 prometheus
systemctl start prometheus.service
systemctl enable prometheus.service
测试访问
http://ip:9090
安装 Grafana
下载安装包
创建 /opt/grafana 并解压
mkdir /opt/grafana
cd /opt/grafana
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.1.2.linux-amd64.tar.gz
tar -zxvf grafana-enterprise-8.1.2.linux-amd64.tar.gz
编写 service文件
vim /usr/lib/systemd/system/grafana.service
ln -s /opt/grafana/grafana-8.1.2 /usr/local/grafana
对应的service文件如下
[Unit]
Description=grafana
[Service]
ExecStart=/usr/local/grafana/bin/grafana-server -homepath=/usr/local/grafana
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动 grafana
systemctl start grafana.service
systemctl enable grafana.service
测试访问
http://ip:3000