基于prometheus+grafana 搭建监控mysql redis mongodb等
2017-07-21 23:15
1271 查看
写的比较粗糙。等整个项目上生产环境的时候,再补充完善这篇博文。
官方网站
https://prometheus.io/
https://github.com/prometheushttps://github.com/prometheus/mysqld_exporterhttps://prometheus.io/docs/
参考文档:
http://www.cnblogs.com/sfnz/p/6566951.html
http://www.jb51.net/article/107386.htm
https://www.iamle.com/archives/2130.html
新建目录:
mkdir -p /root/prometheus
然后把prometheus、grafana的包都丢到这个目录下,这是我们的工作目录(当然生产环境下不要这个路径规划,建议生产环境下丢到/opt目录下去)。
编写用于安装mysqld_exporter的yml文件:- hosts: 10.0.10.100
tasks:
- name: copy install file
copy: src=files/mysqld_exporter-0.10.0.linux-amd64.tar.gz dest=/tmp/mysqld_exporter-0.10.0.linux-amd64.tar.gz
- name: install mysqld_exporter
shell: cd /tmp && tar xf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /opt && cd /opt/mysqld_exporter-0.10.0.linux-amd64 && echo -e "[client]\nuser=prom\npassword=123456\nhost=$(/sbin/ip a|egrep "10.[0|1].[1-9]+.[1-9]+*" | awk '{print $2}'| cut -d '/' -f 1)" > .my.cnf && cd /opt/mysqld_exporter-0.10.0.linux-amd64 && nohup ./mysqld_exporter -config.my-cnf=".my.cnf" &只要使用ansible批量推送这个软件到mysqld服务器兵启动即可开始采集数据了。
在mysql上加prom采集数据的授权:#!/bin/bash
# 添加prom监控账号 以便mysqld_exporter 采集数据
# Date: 2017/08/01source /etc/profileMYSQLCMD="/usr/local/mysql/bin/mysql -uroot -p111111"IP=$(ip a|egrep "10.[0|1].[1-9]+.[1-9]+*" | awk '{print $2}'| cut -d '/' -f 1)# 只添加本机的prom账户,因此这里不写binlog 防止同步到从库去
$MYSQLCMD -e "set session sql_log_bin=OFF;grant process,replication client,select on *.* to 'prom'@'$IP' identified by '123456'; "
在prometheus.yml里面添加相关监控host,类似如下:
然后,使用 ./prometheus 来启动prometheus。
然后浏览器访问prometheus的服务器的9090端口,即可打开一个web界面。切换到status---> Targets ,如果mysqld_exporter能正常工作的话,这里应该显示很多的up状态的主机。类似下图这种(图是我从线上截取的):
安装grafana:
vim /root/prometheus/grafana-4.3.2/conf/defaults.ini 修改下面的地方:
[dashboards.json]
enabled = true
path = /var/lib/grafana/dashboards
安装[b]grafana的仪表盘:[/b]
git clone https://github.com/percona/grafana-dashboards.git cp -r grafana-dashboards/dashboards /var/lib/grafana
启动grafana-server:
cd /root/prometheus/grafana-4.3.2
./bin/grafana-cli plugins install percona-percona-app
./bin/grafana-cli plugins install alexanderzobnin-zabbix-app
./bin/grafana-server
默认是监听在3000端口的。浏览器访问即可。默认用户名和密码都是admin。
官方网站
https://prometheus.io/
https://github.com/prometheushttps://github.com/prometheus/mysqld_exporterhttps://prometheus.io/docs/
参考文档:
http://www.cnblogs.com/sfnz/p/6566951.html
http://www.jb51.net/article/107386.htm
https://www.iamle.com/archives/2130.html
新建目录:
mkdir -p /root/prometheus
然后把prometheus、grafana的包都丢到这个目录下,这是我们的工作目录(当然生产环境下不要这个路径规划,建议生产环境下丢到/opt目录下去)。
编写用于安装mysqld_exporter的yml文件:- hosts: 10.0.10.100
tasks:
- name: copy install file
copy: src=files/mysqld_exporter-0.10.0.linux-amd64.tar.gz dest=/tmp/mysqld_exporter-0.10.0.linux-amd64.tar.gz
- name: install mysqld_exporter
shell: cd /tmp && tar xf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /opt && cd /opt/mysqld_exporter-0.10.0.linux-amd64 && echo -e "[client]\nuser=prom\npassword=123456\nhost=$(/sbin/ip a|egrep "10.[0|1].[1-9]+.[1-9]+*" | awk '{print $2}'| cut -d '/' -f 1)" > .my.cnf && cd /opt/mysqld_exporter-0.10.0.linux-amd64 && nohup ./mysqld_exporter -config.my-cnf=".my.cnf" &只要使用ansible批量推送这个软件到mysqld服务器兵启动即可开始采集数据了。
在mysql上加prom采集数据的授权:#!/bin/bash
# 添加prom监控账号 以便mysqld_exporter 采集数据
# Date: 2017/08/01source /etc/profileMYSQLCMD="/usr/local/mysql/bin/mysql -uroot -p111111"IP=$(ip a|egrep "10.[0|1].[1-9]+.[1-9]+*" | awk '{print $2}'| cut -d '/' -f 1)# 只添加本机的prom账户,因此这里不写binlog 防止同步到从库去
$MYSQLCMD -e "set session sql_log_bin=OFF;grant process,replication client,select on *.* to 'prom'@'$IP' identified by '123456'; "
在prometheus.yml里面添加相关监控host,类似如下:
然后,使用 ./prometheus 来启动prometheus。
然后浏览器访问prometheus的服务器的9090端口,即可打开一个web界面。切换到status---> Targets ,如果mysqld_exporter能正常工作的话,这里应该显示很多的up状态的主机。类似下图这种(图是我从线上截取的):
安装grafana:
vim /root/prometheus/grafana-4.3.2/conf/defaults.ini 修改下面的地方:
[dashboards.json]
enabled = true
path = /var/lib/grafana/dashboards
安装[b]grafana的仪表盘:[/b]
git clone https://github.com/percona/grafana-dashboards.git cp -r grafana-dashboards/dashboards /var/lib/grafana
启动grafana-server:
cd /root/prometheus/grafana-4.3.2
./bin/grafana-cli plugins install percona-percona-app
./bin/grafana-cli plugins install alexanderzobnin-zabbix-app
./bin/grafana-server
默认是监听在3000端口的。浏览器访问即可。默认用户名和密码都是admin。
相关文章推荐
- prometheus+grafana 监控生产环境机器的系统信息、redis、mongodb以及jmx
- Prometheus+Grafana打造Mysql监控平台
- 使用Prometheus+Grafana监控MySQL实践
- [k8s]prometheus+grafana监控node和mysql(普罗/grafana均vm安装)
- Prometheus+Grafana搭建监控系统
- Prometheus+Grafana搭建监控系统(一)
- Spring Boot 应用可视化监控(Prometheus + Grafana)
- prometheus+grafana+docker 监控tomcat jvm
- Open-Falcon 监控系统监控 MySQL/Redis/MongoDB 状态监控
- 基于springboot+bootstrap+mysql+redis搭建一套完整的权限架构【一】【构建工程】
- 秦波|如何基于MySQL及Redis搭建统一的kv存储服务
- 基于springboot+bootstrap+mysql+redis搭建一套完整的权限架构【六】【引入bootstrap前端框架】
- prometheus+grafana构建应用监控(三)
- Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)
- 基于Redis+MySQL+MongoDB存储架构应用
- 安装prometheus+grafana监控mysql redis kubernetes等
- Kubernetes + Prometheus + Grafana 集群监控
- 数据库笔记——Mysql、Oracle、Sqlserver || Redis、Memcached、mongoDB环境搭建
- Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)
- 基于springboot+bootstrap+mysql+redis搭建一套完整的权限架构【四】【编写基础开发工具】