本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名原文链接~~~

Prometheus(1)之快速安装Prometheus

微信搜索 zze_coding 或扫描 👉 二维码关注我的微信公众号获取更多资源推送:


二进制安装

官网下载二进制包:

$ wget https://github.com/prometheus/prometheus/releases/download/v2.22.1/prometheus-2.22.1.linux-amd64.tar.gz

创建安装目录:

$ mkdir -p /opt/apps/prometheus/{conf,bin,data}

解压并移动文件:

$ tar xf prometheus-2.22.1.linux-amd64.tar.gz
$ cd prometheus-2.22.1.linux-amd64
$ mv prometheus promtool /opt/apps/prometheus/bin/
$ mv prometheus.yml /opt/apps/prometheus/conf/

创建 Systemd 配置文件:

$ cat > /lib/systemd/system/prometheus.service << EOF
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
 
[Service]
ExecStart=/opt/apps/prometheus/bin/prometheus \
  --config.file=/opt/apps/prometheus/conf/prometheus.yml \
  --storage.tsdb.path=/opt/apps/prometheus/data \
  --web.listen-address=:9090
 
[Install]
WantedBy=multi-user.target
EOF

启动服务并设置开机自启:

$ systemctl start prometheus && systemctl enable prometheus

启动浏览器访问:

image.png

Docker 安装

快速安装 Docker:

$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

直接运行一个 Docker 容器,由于这里默认的 9090 端口已经被上面二进制方式启动的 Prometheus 占用了,所以这里我将容器的 9090 端口映射到 9091 端口,命令如下:

$ docker run -d -p 9091:9090 -v /opt/apps/prometheus/conf/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus prom/prometheus

启动浏览器访问:

image.png

# 监控   Prometheus  

如果这篇文章对您有帮助,可点击下方链接分享给你的朋友们😋,如果遇到问题欢迎评论、留言~~~😇

评论

公众号:zze_coding

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×