Prometheus
架构
1.下载安装包
[root@prometheus local]#pwd
/usr/local/
[root@prometheus local]#wget
https://github.com/prometheus/prometheus/releases/download/v2.54.1/prometheus-
2.54.1.linux-amd64.tar.gz
[root@prometheus local]#ls -l prometheus-2.54.1.linux-amd64.tar.gz
-rw-r--r-- 1 root root 64152439 Jul 5 21:13 prometheus-2.54.1.linuxamd64.tar.gz
[root@prometheus local]#tar xvf prometheus-2.54.1.linux-amd64.tar.gz
[root@prometheus local]#ln -s prometheus-2.54.1.linux-amd64 prometheus
[root@prometheus local]#cd prometheus/
[root@prometheus ~]#ll /usr/local/prometheus/
总计 244920
drwxr-xr-x 4 1001 127 4096 2月 26 20:14 ./
drwxr-xr-x 11 root root 4096 3月 18 10:16 ../
drwxr-xr-x 2 1001 127 4096 2月 26 20:11 console_libraries/
drwxr-xr-x 2 1001 127 4096 2月 26 20:11 consoles/
-rw-r--r-- 1 1001 127 11357 2月 26 20:11 LICENSE
-rw-r--r-- 1 1001 127 3773 2月 26 20:11 NOTICE
-rwxr-xr-x 1 1001 127 129611890 2月 26 19:38 prometheus*
-rw-r--r-- 1 1001 127 934 2月 26 20:11 prometheus.yml
-rwxr-xr-x 1 1001 127 121143706 2月 26 19:38 promtool*
#创建相关目录
[root@prometheus prometheus]#mkdir bin conf data
[root@prometheus prometheus]#mv prometheus promtool bin/
[root@prometheus prometheus]#mv prometheus.yml conf/
[root@prometheus prometheus]#useradd -r -s /sbin/nologin prometheus
[root@prometheus prometheus]#chown -R prometheus.prometheus
/usr/local/prometheus/
#修改环境变量
[root@prometheus ~]#vim /etc/profile
export PROMETHEUS_HOME=/usr/local/prometheus
export PATH=${PROMETHEUS_HOME}/bin:$PATH
[root@prometheus ~]#source /etc/profile
2.创建服务
cat > /lib/systemd/system/prometheus.service <<EOF
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target
[Service]
Restart=on-failure
User=prometheus
Group=prometheus
WorkingDirectory=/usr/local/prometheus/
ExecStart=/usr/local/prometheus/bin/prometheus \
--config.file=/usr/local/prometheus/conf/prometheus.yml \
--web.enable-lifecycle
ExecReload=/bin/kill -HUP \$MAINPID
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
[root@prometheus ~]#systemctl daemon-reload
[root@prometheus ~]#systemctl enable --now prometheus.service