prmethus和grafana安装使用.doc

prometheus/grafna安装使用

 

IP

Role

lang

prometheus

grafana

exporter

192.168.201.177

monitore

Golang

yes

yes

 

192.168.201.129

db

Golang

no

no

Node_exporter

Mysqld_exporter

 

 

 

 

 

 

  • 安装配prometheus

yum install golang

https://prometheus.io/download/prometheus-2.3.2.linux-amd64.tar.gz

 

tar -zxvf prometheus-2.3.2.linux-amd64.tar.gz

mv prometheus-2.3.2.linux-amd64  prometheus

新增配置 vi  prometheus.yml

 

- job_name: 'mysql_exporter'

 

    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

 

    static_configs:

    - targets: ['192.168.201.129:9100']

 

  - job_name: 'mysql'

 

    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

 

    static_configs:

    - targets: ['192.168.201.129:9104']

 

 

启动prometheus

nohup ./prometheus &

 

 

 

  • 安装grafana5.0

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm

yum install initscripts fontconfig

rpm -Uvh grafana-5.2.3-1.x86_64.rpm

systemctl daemon-reload

systemctl start grafana-server

 

上传仪表盘路径/var/lib/grafana/dashboards

 git clone https://github.com/percona/grafana-dashboards.git

cp * /var/lib/grafana/dashboard/

 

Systemctl restart grafana-server

 

  • 安装exporter

 

$ wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-amd64.tar.gz

 

$ wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz

 

安装运行node_exporter

$ tar xvf node_exporter-0.14.0.linux-amd64.tar.gz -C /usr/local/

$ nohup /usr/local/node_exporter-0.14.0.linux-amd64/node_exporter  &

 

mysqld_exporter需要连接到Mysql,所以需要Mysql的权限,我们先为它创建用户并赋予所需的权限.

 

mysql> GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'mysql_monitor'@'localhost' identified by 'mysql_monitor';

mysql> GRANT SELECT ON *.* TO 'mysql_monitor'@'localhost';

 

 

创建.my.cnf文件并运行mysqld_exporter:

$ cat /usr/local/mysqld_exporter-0.10.0.linux-amd64/.my.cnf

[client]

user=mysql_monitor

password=mysql_monitor

 

$ tar xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /usr/local/

$  /usr/local/mysqld_exporter/mysqld_exporter  -config.my-cnf="/usr/local/mysqld_exporter/my.cnf"

 

 

 

 

 

 

猜你喜欢

转载自blog.csdn.net/u012482502/article/details/82260007
今日推荐