prometheus+grafana可视化监控

prometheus监控

一、用二进制安装

1、安装Prometheus

打开官方网址:https://prometheus.io/download/

在这里插入图片描述

wget https://github.com/prometheus/prometheus/releases/download/v2.45.4/prometheus-2.45.4.linux-amd64.tar.gz

下载完成后解压一下安装包

在这里插入图片描述

tar vxf prometheus-2.45.4.linux-amd64.tar.gz

解压完成ls查看一下,并移动到/opt下改名为prometheus

在这里插入图片描述

[root@localhost ~]# ls -l
total 90424
-rw-r--r--  1 root root          0 Apr 19 05:51 ?
-rw-------. 1 root root       1244 Apr 15 05:34 anaconda-ks.cfg
drwxr-xr-x. 2 root root         24 Apr 19 06:12 conf
-rw-r--r--  1 root root        348 Apr 19 07:22 docker-compose.yml
drwxr-xr-x. 2 root root         57 Apr 19 09:06 html
drwxr-xr-x  4 1001 docker      132 Mar 18 07:23 prometheus-2.45.4.linux-amd64
-rw-r--r--  1 root root   92584268 Mar 18 07:26 prometheus-2.45.4.linux-amd64.tar.gz
[root@localhost ~]# mv prometheus-2.45.4.linux-amd64 /opt/prometheus

完成后,创建一个专门的prometheus用户,并更改prometheus用户的文件权限:

[root@localhost ~]# useradd -M -s /usr/sbin/nologin prometheus
id[root@localhost ~]# id prometheus
uid=1000(prometheus) gid=1000(prometheus) groups=1000(prometheus)
[root@localhost ~]# chown prometheus:prometheus -R /opt/prometheus

下一步创建systemd服务

[root@localhost ~]# cat > /etc/systemd/system/prometheus.service << "EOF"
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/opt/prometheus/prometheus/prometheus \
  --config.file=/opt/prometheus/prometheus/prometheus.yml \
  --storage.tsdb.path=/opt/prometheus/prometheus/data \
  --storage.tsdb.retention.time=60d \
  --web.enable-lifecycle

[Install]
WantedBy=multi-user.target
EOF
[root@localhost ~]# ls -l /etc/systemd/system/prometheus.service
-rw-r--r-- 1 root root 471 Apr 20 04:52 /etc/systemd/system/prometheus.service
[root@localhost ~]# cat /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/opt/prometheus/prometheus/prometheus \
  --config.file=/opt/prometheus/prometheus/prometheus.yml \
  --storage.tsdb.path=/opt/prometheus/prometheus/data \
  --storage.tsdb.retention.time=60d \
  --web.enable-lifecycle

[Install]
WantedBy=multi-user.target
[root@localhost ~]# ll /opt/prometheus/
total 229516
drwxr-xr-x 2 prometheus prometheus        38 Mar 18 07:20 console_libraries
drwxr-xr-x 2 prometheus prometheus       173 Mar 18 07:20 consoles
-rw-r--r-- 1 prometheus prometheus     11357 Mar 18 07:20 LICENSE
-rw-r--r-- 1 prometheus prometheus      3773 Mar 18 07:20 NOTICE
-rwxr-xr-x 1 prometheus prometheus 120923743 Mar 18 07:00 prometheus
-rw-r--r-- 1 prometheus prometheus       934 Mar 18 07:20 prometheus.yml
-rwxr-xr-x 1 prometheus prometheus 114075116 Mar 18 07:01 promtool
  • 6
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄昏终结者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值