相关安装包的下载

链接:https://pan.baidu.com/s/1ejM0V0f7H1Ikic_vpYGr_w
提取码:axeq

安装步骤

1、将安装包放到部署机器上

2、解压包 tar -zxvf prometheus-2.6.1.linux-amd64.tar.gz

3、移动并重命名到安装目录下 mv prometheus-2.6.1.linux-amd64.tar.gz /usr/local/prometheus

4、进入目录下并修改配置文件prometheus.yml  添加监控机器

# my global config
global:
  scrape_interval:     15s # 默认没15s拉取一次数据点数据
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself
scrape_configs: # The job name is added as a label `job
=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus'   static_configs: - targets: ['localhost:9090']  #监控本地及端口默认9090 - job_name: 'node_exporter_local' #通过node_exporter收集的数据 下面会有介绍 scrape_interval: 5s static_configs: - targets: ['192.168.2.35:9100']

5、启动

./prometheus --config.file=prometheus.yml   
注:第一次操作可能启动报错百分之99是yml文件 修改的问题
# 指定配置文件
--config.file="prometheus.yml"
# 指定监听地址端口
--web.listen-address="0.0.0.0:9090" 
# 最大连接数
--web.max-connections=512
# tsdb数据存储的目录,默认当前data/
--storage.tsdb.path="data/"
# premetheus 存储数据的时间,默认保存15天
--storage.tsdb.retention=15d 
启动项

相关文章: