Prometheus的安装及部署

Prometheus的安装及部署

二进制安装部署

  1. 下载二进制包 prometheus-2.6.1.linux-amd64.tar.gz
  2. 解压 tar xvzf prometheus-2.6.1.linux-amd64.tar.gz
  3. 移动到安装目录 mv prometheus-2.6.1.linux-amd64 /usr/local/
  4. 修改目录名 mv prometheus-2.6.1.linux-amd64 prometheus
  5. 进入到目录 cd /usr/local/prometheus
  6. 修改配置文件用来监控本机 vim prometheus.yml
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    # 监控本地及端口
    - targets: ['xiangsikai:9090']

启动服务

./prometheus --config.file=prometheus.yml

测试访问

  1. 访问地址 http://localhost:9090
  2. 页面解释
    1. Alerts 监控告警规则
    2. Graph 图形
    3. Status 基础环境、命令行日志,配置文件、角色定义监控指标告警规则,当前已被纳入主机的情况、服务发现功能

将Prometheus配置为系统服务

  1. 进入system目录下 cd /usr/lib/systemd/system
  2. 创建文件 vim prometheus.service
[Unit]
Description=https://prometheus.io
  
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml

[Install]                      
WantedBy=multi-user.target
  1. 生效系统system文件 systemctl daemon-reload
  2. 停止/启动服务 systemctl stop prometheus.service/systemctl start prometheus.service
posted @ 2020-11-16 14:37  SunFree  阅读(300)  评论(0编辑  收藏  举报