EPG组合 (Exporter Prometheus Grafana) 监控MySQL
生活随笔
收集整理的這篇文章主要介紹了
EPG组合 (Exporter Prometheus Grafana) 监控MySQL
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
環(huán)境說(shuō)明
監(jiān)控機(jī)10.0.0.200
服務(wù)器10.0.0.201
Prometheus的架構(gòu)
在被監(jiān)控服務(wù)器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授予權(quán)限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 運(yùn)行mysqld exporter nohup ./mysqld_exporter -config.my-cnf="my.cnf" &
在監(jiān)控主機(jī)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/
運(yùn)行g(shù)rafana server systemctl start grafana-server
訪問(wèn)grafana服務(wù)器 通過(guò)瀏覽器訪問(wèn)http://10.0.0.200:3000, 默認(rèn)用戶名和密碼是admin 建立數(shù)據(jù)源
Prometheus的架構(gòu)
在被監(jiān)控服務(wù)器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授予權(quán)限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 運(yùn)行mysqld exporter nohup ./mysqld_exporter -config.my-cnf="my.cnf" &
在監(jiān)控主機(jī)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
運(yùn)行prometheus
nohup prometheus &
打開(kāi)瀏覽器訪問(wèn)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/
運(yùn)行g(shù)rafana server systemctl start grafana-server
訪問(wèn)grafana服務(wù)器 通過(guò)瀏覽器訪問(wèn)http://10.0.0.200:3000, 默認(rèn)用戶名和密碼是admin 建立數(shù)據(jù)源
查看dashboard
以下展現(xiàn)的是node_exporter采集的數(shù)據(jù)
以下展現(xiàn)的是mysqld_exporter采集的數(shù)據(jù)
grafana的圖表展現(xiàn)比cacti之類的確實(shí)漂亮多了。
參考資料
https://prometheus.io/ https://grafana.com/ https://github.com/percona/grafana-dashboards總結(jié)
以上是生活随笔為你收集整理的EPG组合 (Exporter Prometheus Grafana) 监控MySQL的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 世界正在走向实时化,谈谈Twitter对
- 下一篇: PMM (Percona MySQL M