EPG组合 (Exporter Prometheus Grafana) 监控MySQL
生活随笔
收集整理的這篇文章主要介紹了
EPG组合 (Exporter Prometheus Grafana) 监控MySQL
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
環境說明
監控機10.0.0.200
服務器10.0.0.201
Prometheus的架構
在被監控服務器10.0.0.201安裝exporter 安裝node_exporter wgethttps://github.com/prometheus/node_exporter/releases/download/v0.15.1/node_exporter-0.15.1.linux-amd64.tar.gz tar zxvf node_exporter-0.15.1.linux-amd64.tar.gz cd node_exporter-0.15.1.linux-amd64 nohup ./node_exporter &
安裝mysqld_exporter 連接mysql授予權限mysql -uroot -p GRANT REPLICATION CLIENT, PROCESS ON *.* TO'exporter'@'localhost' identified by'123456'; GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost'; flush privileges;
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz tar zxvf mysqld_exporter-0.10.0.linux-amd64 cd mysqld_exporter-0.10.0.linux-amd64 建立配置文件my.cnf [client] user=exporter password=123456 運行mysqld exporter nohup ./mysqld_exporter -config.my-cnf="my.cnf" &
在監控主機10.0.0.200安裝Prometheus wget https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz tar zxvf prometheus-2.0.0.linux-amd64.tar.gz cd prometheus-2.0.0.linux-amd64
Package details
安裝dashboards git clone https://github.com/percona/grafana-dashboards.git cp -r grafana-dashboards/dashboards /var/lib/grafana/
運行grafana server systemctl start grafana-server
訪問grafana服務器 通過瀏覽器訪問http://10.0.0.200:3000, 默認用戶名和密碼是admin 建立數據源
Prometheus的架構
在被監控服務器10.0.0.201安裝exporter 安裝node_exporter wgethttps://github.com/prometheus/node_exporter/releases/download/v0.15.1/node_exporter-0.15.1.linux-amd64.tar.gz tar zxvf node_exporter-0.15.1.linux-amd64.tar.gz cd node_exporter-0.15.1.linux-amd64 nohup ./node_exporter &
安裝mysqld_exporter 連接mysql授予權限mysql -uroot -p GRANT REPLICATION CLIENT, PROCESS ON *.* TO'exporter'@'localhost' identified by'123456'; GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost'; flush privileges;
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz tar zxvf mysqld_exporter-0.10.0.linux-amd64 cd mysqld_exporter-0.10.0.linux-amd64 建立配置文件my.cnf [client] user=exporter password=123456 運行mysqld exporter nohup ./mysqld_exporter -config.my-cnf="my.cnf" &
在監控主機10.0.0.200安裝Prometheus wget https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz tar zxvf prometheus-2.0.0.linux-amd64.tar.gz cd prometheus-2.0.0.linux-amd64
prometheus.yml
global:scrape_interval: 5s # By default, scrape targets every 15 seconds.evaluation_interval: 15s# Attach these labels to any time series or alerts when communicating with# external systems (federation, remote storage, Alertmanager).#external_labels:# monitor: 'codelab-monitor'scrape_configs:- job_name: prometheusstatic_configs:- targets: ['10.0.0.200:9090']labels: instance: prometheus- job_name: linuxstatic_configs:- targets: ['10.0.0.201:9100']labels: instance: db1- job_name: mysqlstatic_configs:- targets: ['10.0.0.201:9104']labels:instance: db1
運行prometheus
nohup prometheus &
打開瀏覽器訪問http://10.0.0.200:9090
查看Status->Target
安裝Grafana yuminstallhttps://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.2-1.x86_64.rpm yum install fontconfig yum install freetype* yum install urw-fonts
Package details
- Installs binary to?/usr/sbin/grafana-server
- Copies init.d script to?/etc/init.d/grafana-server
- Installs default file (environment vars) to?/etc/sysconfig/grafana-server
- Copies configuration file to?/etc/grafana/grafana.ini
- Installs systemd service (if systemd is available) name?grafana-server.service
- The default configuration uses a log file at?/var/log/grafana/grafana.log
- The default configuration specifies an sqlite3 database at?/var/lib/grafana/grafana.db
安裝dashboards git clone https://github.com/percona/grafana-dashboards.git cp -r grafana-dashboards/dashboards /var/lib/grafana/
運行grafana server systemctl start grafana-server
訪問grafana服務器 通過瀏覽器訪問http://10.0.0.200:3000, 默認用戶名和密碼是admin 建立數據源
查看dashboard
以下展現的是node_exporter采集的數據
以下展現的是mysqld_exporter采集的數據
grafana的圖表展現比cacti之類的確實漂亮多了。
參考資料
https://prometheus.io/ https://grafana.com/ https://github.com/percona/grafana-dashboards總結
以上是生活随笔為你收集整理的EPG组合 (Exporter Prometheus Grafana) 监控MySQL的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 世界正在走向实时化,谈谈Twitter对
- 下一篇: PMM (Percona MySQL M