mysql中%3c%3e和=_Grafana+Prometheus 监控 MySQL
架构图
环境
IP
环境
需装软件
192.168.0.237
mysql-5.7.20
node_exporter-0.15.2.linux-amd64.tar.gz
mysqld_exporter-0.10.0.linux-amd64.tar.gz
192.168.0.248
grafana+prometheus
prometheus-2.1.0.linux-amd64.tar.gz
node_exporter-0.15.2.linux-amd64.tar.gz
grafana-4.6.3.linux-x64.tar.gz
在 192.168.0.248 上安装 grafana prometheus
安装 prometheus
# 创建保存软件的目录
mkdir /data/software/ -p
cd /data/software/
# 解压 prometheus
tar xvf prometheus-2.1.0.linux-amd64.tar.gz -C /iba/
cd /iba/
mv prometheus-2.1.0.linux-amd64 prometheus
cd prometheus/
cp prometheus.yml /tmp/prometheus.yml.20181203
# 配置 prometheus.yml
cat prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
- job_name: 'Host'
file_sd_configs:
- files:
- host.yml
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__]
regex: (.*)
target_label: instance
replacement: $1
- source_labels: [__address__]
regex: (.*)
target_label: __address__
replacement: $1:9100
- job_name: 'MySQL'
file_sd_configs:
- files:
- mysql.yml
metrics_path: /metrics
relabel_configs:
- source_labels: [__address__]
regex: (.*)
target_label: instance
replacement: $1
- source_labels: [__address__]
regex: (.*)
target_label: __address__
replacement: $1:9104
- job_name: 'prometheus'
static_configs:
- targets:
- localhost:9090
cat host.yml
- labels:
service: test
targets:
- 192.168.0.248
- 192.168.0.237
cat mysql.yml
- labels:
service: test
targets:
- 192.168.0.237
# 测试 prometheus 是否可以正常启动
/iba/prometheus/prometheus --storage.tsdb.retention=30d &
ps -ef|grep prometh
kill -9 14650
# 配置 prometheus.service 文件
vi /usr/lib/systemd/system/prometheus.service
# 内容为
[Unit]
Description=Prometheus instance
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=simple
Restart=on-failure
WorkingDirectory=/iba/prometheus/
RuntimeDirectory=prometheus
RuntimeDirectoryMode=0750
ExecStart=/iba/prometheus/prometheus --storage.tsdb.retention=30d --config.file=/iba/prometheus/prometheus.yml
LimitNOFILE=10000
TimeoutStopSec=20
[Install]
WantedBy=multi-user.target
# 启动 prometheus
systemctl start prometheus
systemctl status prometheus -l
# 开放防火墙
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.0/16" accept"
firewall-cmd --reload
浏览器输入 http://192.168.0.248:9090 访问
prometheus.yml 文件参考:
https://prometheus.io/docs/prometheus/latest/configuration/configuration/
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Crelabel_config%3E
https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Cfile_sd_config%3E
安装 node_exporter 获取主机信息
# 解压 node_exporter
cd /data/software/
tar xf node_exporter-0.15.2.linux-amd64.tar.gz -C /usr/local
mv node_exporter-0.15.2.linux-amd64 node_exporter
nohup ./node_exporter &
安装 grafana
cd /iba/software
# 解压
tar xf grafana-4.6.3.linux-x64.tar.gz -C /iba/prometheus/
cd /iba/prometheus/
mv grafana-4.6.3 grafana
cd grafana/
# 测试
./bin/grafana-server
# 停止
ctrl+c
cat /usr/lib/systemd/system/grafana-server.service
[Unit]
Description=Grafana instance
Documentation=http://docs.grafana.org
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=simple
Restart=on-failure
WorkingDirectory=/iba/prometheus/grafana
RuntimeDirectory=grafana
RuntimeDirectoryMode=0750
ExecStart=/iba/prometheus/grafana/bin/grafana-server
LimitNOFILE=10000
TimeoutStopSec=20
[Install]
WantedBy=multi-user.target
# 启动
systemctl start grafana-server
systemctl status grafana-server -l
访问 http://192.168.0.248:3000,默认用户和密码是 admin/admin
配置数据源
下载 grafana-dashboards-1.6.1.tar.gz,解压,使用浏览器导入 dashboard, 下载地址:https://github.com/percona/grafana-dashboards/archive/v1.6.1.tar.gz
在 192.168.0.237 安装 node_exporter 和 mysqld_exporter
cd /iba/software/
tar zxf node_exporter-0.15.2.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv node_exporter-0.15.2.linux-amd64 node_exporter
# 启动
cd node_exporter/
nohup ./node_exporter &
几分钟后 grafana 出现了新服务器的信息
在mysql上配置监控使用的用户
GRANT REPLICATION CLIENT, PROCESS, SELECT ON *.* TO 'mysql_monitor'@'%' IDENTIFIED BY 'mysql_monitor';
FLUSH PRIVILEGES;
cd /iba/software/
tar zxf mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv mysqld_exporter-0.10.0.linux-amd64/ mysqld_exporter
cd mysqld_exporter/
# 在 mysql 上创建一个专门用于监控的用户,
cat .my.cnf
[client]
user=mysql_monitor
password=mysql_monitor
# 启动
nohup /usr/local/mysqld_exporter/mysqld_exporter -config.my-cnf="/usr/local/mysqld_exporter/.my.cnf" &
导入 dashboard: MySQL_Overview.json
mysql中%3c%3e和=_Grafana+Prometheus 监控 MySQL相关推荐
- prometheus监控mysql慢查询_使用Grafana+Prometheus监控mysql服务性能
prometheus(也叫普罗米修斯)官网: grafana官网: 特征 普罗米修斯的主要特点是: 具有由度量名称和键/值对标识的时间序列数据的 一个 来利用这一维度 不依赖分布式存储; 单个服务器节 ...
- 使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库
使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库 原文:使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库 一.背 ...
- Prometheus 监控Mysql服务器及Grafana可视化
Prometheus 监控Mysql服务器及Grafana可视化 mysql_exporter:用于收集MySQL性能信息. 使用版本 mysqld_exporter 0.11.0 官方地址 使用文档 ...
- 普罗米修斯 mysql监控_普罗米修斯Prometheus监控MySQL
普罗米修斯Prometheus监控MySQL 添加数据库用户 CREATE USER monitor_prometheus@'192.168.245.%' IDENTIFIED BY 'Abcde@1 ...
- prometheus监控mysql主从
文章目录 prometheus监控mysql主从 先将MySQL部署完成,并配置好主从复制 主从复制节点授权exporter 数据库授权(master 节点执行) 配置mysqld 主从复制的指标暴露 ...
- prometheus 监控mysql数据库
prometheus 监控mysql数据库 本文通过prometheus 来监控mysql数据库状态,主要利用mysqld_exporter来实现mysql状态上报. 主机信息如下: 主机IP 用途 ...
- asp.net mysql 创建变_[ASP.net教程]EF Core使用CodeFirst在MySql中创建新数据库以及已有的Mysql数据库如何使用DB First生成域模型...
[ASP.net教程]EF Core使用CodeFirst在MySql中创建新数据库以及已有的Mysql数据库如何使用DB First生成域模型 0 2018-06-30 07:00:08 官方教程: ...
- MySQL中出现 错误 2003Can‘t connect to MySQL server on‘localhost‘ (0)
MySQL中出现 错误 2003Can't connect to MySQL server on'localhost' (0) 在SQLyog这个工具上登陆不了,但是在cmd命令窗口中可以正常操作. ...
- 使用 prometheus 监控 MySQL
1. 下载 https://prometheus.io/download/ wget https://github.com/prometheus/mysqld_exporter/releases/do ...
最新文章
- NTT DOCOMO将部署多供应商NFV技术
- 接口里面的静态方法--痒啊
- php数组实现堆栈的三个函数,while,do while,s函数的参数作用域,数组堆栈,常见的数组函数等学习2018/8/23...
- SAP Cloud Platform integration上创建一个最简单的iFlow
- 使用jMeter对基于SAP ID service进行Authentication的Restful API进行并发测试
- 轨道运营管理专业自荐书_轨道运营管理专业自荐信x
- 剑指offer 面试题61. 扑克牌中的顺子
- 虹软java接摄像头_java基于虹软sdk实现人脸识别(demo)
- 想要学习C++,到底能从事哪种行业?
- JAVA/JNI的jstring转换为char*
- java中的 关键词vali_Java中的关键字volatile详解
- Nik Collection 3.3.0中文版 (摄影师必备ps滤镜插件套装)支持big surv
- 【目标检测】YOLOv3:An Incremental Improvement
- PHP入门需要多久?
- 《算法笔记》9.4小节 9.5小节——数据结构专题(2)->二叉查找树(BST)->平衡二叉树(AVL)
- 进入docker容器的方法
- Semi-Supervised Semantic Segmentation with Cross-Consistency Training论文笔记
- 苹果xr如何关机_iPhone XR 的实际体验如何?
- Hive任务执行报错:FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
- 《海贼王》路飞的团队建设
热门文章
- 关系的三类完整性约束
- Python多线程--UDP聊天器
- java房产源码_基于jsp的房屋交易管理系统-JavaEE实现房屋交易管理系统 - java项目源码...
- @postconstruct注解方法没有执行_把对象的创建交给spring来管理(注解IOC)
- 如何理解操作系统的不确定性_温度最低-273度,最高却能有1.4亿亿亿亿度,如何定义的?...
- python中错误和异常处理
- 【深度学习】Tensorflow完成线性回归对比机器学习LinearRegression()
- ARM中ROM,RAM,FLASH区别
- java metric_java版的Metric工具介绍
- Java的接口及实例