一、準備環境
主機名 | ip | 配置 |
prometheus-server31 | 10.0.0.31 | 1核1g-20GB |
prometheus-server32 | 10.0.0.31 | 1核1g-20GB |
prometheus-server33 | 10.0.0.31 | 1核1g-20GB |
二、下載/上傳軟件包
1,軟件包地址
這里給大家準備了百度云盤的安裝包;
鏈接:https://pan.baidu.com/s/1fhg5UD1HkQo0XWrwHTkAzQ?pwd=9m5p?
提取碼:9m5p
2,準備工作目錄
[root@prometheus-server31 ~]# mkdir -pv /prometheus/{soft,data,logs}
[root@prometheus-server31 ~]# cd /prometheus/soft/
3,上傳軟件包
[root@prometheus-server31 soft]# rz -E
[root@prometheus-server31 soft]# tar xf prometheus-2.37.8.linux-amd64.tar.gz?
[root@prometheus-server31 soft]# ll
total 81396
drwxr-xr-x 4 1001 ?123 ? ? ?132 May ?5 ?2023 prometheus-2.37.8.linux-amd64
做個軟連接,方便操作
[root@prometheus-server31 soft]# ln -sv prometheus-2.37.8.linux-amd64 prometheus
‘prometheus’ -> ‘prometheus-2.37.8.linux-amd64’
三、啟動prometheus
1,查看prometheus軟連接中的文件
[root@prometheus-server31 soft]# cd prometheus
[root@prometheus-server31 prometheus]# ll
total 207040
drwxr-xr-x 2 1001 123 ? ? ? ?38 May ?5 ?2023 console_libraries
drwxr-xr-x 2 1001 123 ? ? ? 173 May ?5 ?2023 consoles
-rw-r--r-- 1 1001 123 ? ? 11357 May ?5 ?2023 LICENSE
-rw-r--r-- 1 1001 123 ? ? ?3773 May ?5 ?2023 NOTICE#啟動文件
-rwxr-xr-x 1 1001 123 109128753 May ?5 ?2023 prometheus
-rw-r--r-- 1 1001 123 ? ? ? 934 May ?5 ?2023 prometheus.yml
-rwxr-xr-x 1 1001 123 102856799 May ?5 ?2023 promtool
2,啟動prometheus
[root@prometheus-server31 prometheus]# ./prometheus
3,檢查端口9090
[root@prometheus-server31 ~]# netstat -tnulp
四、頁面查看
瀏覽器訪問:10.0.0.31:9090
你會發現一個非常丑的圖,這代表你部署成功了;
五、配置systemctl啟動文件
1,編輯啟動文件
[root@prometheus-server31 ~]# vim /etc/systemd/system/prometheus-server.service
[Unit]
Description=xinjizhiwa Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network.target[Service]
Restart=on-failure
ExecStart=/prometheus/soft/prometheus/prometheus \
? ? --config.file=/prometheus/soft/prometheus/prometheus.yml \
? ? --web.enable-lifecycle
ExecReload=/bin/kill -HUP \$MAINPID
LimitNOFILE=65535[Install]
WantedBy=multi-user.target
2,重新加載systemctl
[root@prometheus-server31 ~]# systemctl daemon-reload?
[root@prometheus-server31 ~]# systemctl enable --now prometheus-server.service?
3,重新加載prometheus
[root@prometheus-server31 ~]# systemctl reload prometheus-server.service
#如果不管用,則使用下面的命令
curl -X POST http://10.0.0.31:9090/-/reload
六、查看啟動后是否生成data/數據目錄
[root@prometheus-server31 ~]# ll /prometheus/soft/prometheus/
至此,prometheus部署完畢;