prometheus Stack 安装

学习笔记 2020/09/14 Prometheus

直接上安装步骤:

1. exporter 安装

安装目录

mkdir /usr/local/prometheus-exporter

node-exporter

cd ~/software
wget https://github.com/prometheus/node_exporter/releases/download/v1.0.0/node_exporter-1.0.0.linux-amd64.tar.gz
tar zxvf node_exporter-1.0.0.linux-amd64.tar.gz
mv node_exporter-1.0.0.linux-amd64 /usr/local/prometheus-exporter/node

cd /usr/local/prometheus-exporter/node
nohup ./node_exporter >> stdout.log 2>&1 &


redis-exporter

cd ~/software
wget https://github.com/oliver006/redis_exporter/releases/download/v1.6.1/redis_exporter-v1.6.1.linux-amd64.tar.gz
tar zxvf redis_exporter-v1.6.1.linux-amd64.tar.gz
mv redis_exporter-v1.6.1.linux-amd64 /usr/local/prometheus-exporter/redis

cd /usr/local/prometheus-exporter/redis
nohup ./redis_exporter >> stdout.log 2>&1 &


mysql-exporter

cd ~/software
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
tar zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64 /usr/local/prometheus-exporter/mysqld

cd /usr/local/prometheus-exporter/mysqld
nohup ./mysqld_exporter >> stdout.log 2>&1 &
CREATE USER \'exporter\'@\'localhost\' IDENTIFIED BY \'XXXXXXXX\' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO \'exporter\'@\'localhost\';


Running using an environment variable:

export DATA_SOURCE_NAME=\'user:password@(hostname:3306)/\'
./mysqld_exporter 


Running using ~/.my.cnf:

./mysqld_exporter 


2. prometheus 安装

cd ~/software
wget https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz
tar zxvf prometheus-2.18.1.linux-amd64.tar.gz
mv prometheus-2.18.1.linux-amd64 /usr/local/prometheus

## modify prometheus.yml

cd /usr/local/prometheus
nohup ./prometheus >> stdout.log 2>&1 &


prometheus.yml 修改 scrape_configs 项,对应target 需要修改为正确的目标IP、PORT

# 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=` to any timeseries scraped from this config.
  - job_name: \'prometheus\'

    # metrics_path defaults to \'/metrics\'
    # scheme defaults to \'http\'.

    static_configs:
    - targets: [\'localhost:9090\']

  - job_name: \'node\'
    static_configs:
    - targets: [\'localhost:9100\']

  - job_name: \'redis\'
    static_configs:
    - targets: [\'localhost:9121\']

启动:

./prometheus --storage.tsdb.min-block-duration=4h


3. grafana 安装

安装&启动

cd ~/software
wget https://dl.grafana.com/oss/release/grafana-7.0.3.linux-amd64.tar.gz
tar -zxvf grafana-7.0.3.linux-amd64.tar.gz
mv grafana-7.0.3 /usr/local/grafana

cd /usr/local/grafana
nohup ./bin/grafana-server >> stdout.log 2>&1 &


Data Sources 配置

\"QQ图片20200914172154.png\"/



本文地址:https://www.stayed.cn/item/271

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。