架构图

环境

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相关推荐

  1. prometheus监控mysql慢查询_使用Grafana+Prometheus监控mysql服务性能

    prometheus(也叫普罗米修斯)官网: grafana官网: 特征 普罗米修斯的主要特点是: 具有由度量名称和键/值对标识的时间序列数据的 一个 来利用这一维度 不依赖分布式存储; 单个服务器节 ...

  2. 使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库

    使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库 原文:使用 Docker 部署 Grafana + Prometheus 监控 MySQL 数据库 一.背 ...

  3. Prometheus 监控Mysql服务器及Grafana可视化

    Prometheus 监控Mysql服务器及Grafana可视化 mysql_exporter:用于收集MySQL性能信息. 使用版本 mysqld_exporter 0.11.0 官方地址 使用文档 ...

  4. 普罗米修斯 mysql监控_普罗米修斯Prometheus监控MySQL

    普罗米修斯Prometheus监控MySQL 添加数据库用户 CREATE USER monitor_prometheus@'192.168.245.%' IDENTIFIED BY 'Abcde@1 ...

  5. prometheus监控mysql主从

    文章目录 prometheus监控mysql主从 先将MySQL部署完成,并配置好主从复制 主从复制节点授权exporter 数据库授权(master 节点执行) 配置mysqld 主从复制的指标暴露 ...

  6. prometheus 监控mysql数据库

    prometheus 监控mysql数据库 本文通过prometheus 来监控mysql数据库状态,主要利用mysqld_exporter来实现mysql状态上报. 主机信息如下: 主机IP 用途 ...

  7. 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 官方教程: ...

  8. MySQL中出现 错误 2003Can‘t connect to MySQL server on‘localhost‘ (0)

    MySQL中出现  错误 2003Can't connect to MySQL server on'localhost' (0) 在SQLyog这个工具上登陆不了,但是在cmd命令窗口中可以正常操作. ...

  9. 使用 prometheus 监控 MySQL

    1. 下载 https://prometheus.io/download/ wget https://github.com/prometheus/mysqld_exporter/releases/do ...

最新文章

  1. 判断程序是否已经运行
  2. silverlight 一些写法小计
  3. Coursera课程 Competitive Strategy内容简介
  4. springboot aop使用_SpringBoot 使用AOP实现读写分离
  5. 学计算机应用基础学到了什么,2021年学习计算机应用基础心得体会-得范文网
  6. python乱码怎么办_Python爬虫结果是乱码怎么办?带你了解乱码的原因及其解决办法...
  7. 计算机硬盘使用寿命,怎么看电脑硬盘的寿命
  8. 爬虫实战之selenium淘宝抢购订单
  9. 软件测试需要什么思维,做软件测试需要学习什么
  10. 使用C#编写17种Hello World程序(初学者C#测试石)
  11. neutron组网规划(flat、vlan类型)
  12. 你知道Verilog HDL程序是如何构成的吗
  13. DBPwAudit -数据库密码破解工具的使用
  14. C++OO部分知识小结(1)
  15. 一个阿里P8的程序员,一年能赚多少钱?
  16. cocos2d-x 3.0游戏实例学习笔记《卡牌塔防》第三步---编辑器(2)---更方便更多操作更像编辑器
  17. 关于Vue中的v-if和v-for区别讲解
  18. Python进阶编程问题集
  19. 国耻日,各大门户网站.
  20. 中国广电与中国移动共建5G,但是并不幻想完全依赖后者

热门文章

  1. 设计师和开发人员更快完成工作需求的35个惊人的jquery插件教程(下)
  2. C++中引用()基础认识
  3. php控制器教程,laravel基础教程 -- 控制器
  4. 企业网站 源码 服务邮箱:_公司企业邮箱购买,外贸企业邮箱用哪家服务好?
  5. Python 之 线程
  6. 解决:关于Git无法提交 index.lock File exists的问题
  7. 深入浅出WPF之Binding的使用(一)
  8. 使用命名空间、头文件和实现文件
  9. Linux: shell 中命令代换 $() 和 ``(有图有代码有真相!!!)
  10. C语言常量类型及名称,菜鸟带你入门C语言|基本数据类型之常量