这篇文章本来是打算使用pmm 进行数据库监控的,但是居然参考官方文档使用docker 运行起来有点问题,所以直接改用
exporter 进行处理,但是比pmm 弱好多

pmm 的参考架构

说明,以上图比较早了, 实际上也可以监控mongodb,同时也是使用exporter处理的,只是pmm 基于grafanna 的扩展比较多
对于系统分析指标更全

环境准备

  • docker-compose 文件
 
version: "3"
services: 
  pgloader-mysql:
    image: dimitri/pgloader
    command: pgloader mysql://root:dalongrong@mysql/gogs postgresql://postgres:dalong@postgres:5432/appdemo
  gogs:
    image: gogs/gogs
    ports:
      - "10022:22"
      - "3001:3000"
    volumes:
      - ./data/gogs:/data
  mysqlexporter:
    image: prom/mysqld-exporter
    ports: 
    - "9104:9104"
    environment: 
    - "DATA_SOURCE_NAME=root:dalongrong@(mysql:3306)/"
  grafana:
    image: grafana/grafana
    ports:
    - "3000:3000"
  prometheus:
    image: prom/prometheus
    volumes:
    - "./prometheus.yml:/etc/prometheus/prometheus.yml"
    ports:
    - "9090:9090" 
  mysql:
    image: mysql:5.7.16
    ports:
      - 3306:3306
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_ROOT_PASSWORD: dalongrong
      MYSQL_DATABASE: gogs
      MYSQL_USER: gogs
      MYSQL_PASSWORD: dalongrong
      TZ: Asia/Shanghai
  postgres:
    build: 
     context: ./pg
     dockerfile: Dockerfile
    ports:
    - "5432:5432"
    environment:
    - "POSTGRES_PASSWORD:dalong"
  pgexporter:
    image: wrouesnel/postgres_exporter:latest
    ports:
    - 9187:9187
    environment:
    - DATA_SOURCE_NAME=postgresql://postgres:dalong@postgres:5432/postgres_exporter?sslmode=disable
  • 说明
    以上服务有点多,包含了mysql 、pg 以及对应的exporter 同时还有一个gogs git 服务,同时也包含了一个mysql 到pg 迁移的工具pgloader
  • promethues 配置文件
 
scrape_configs:
  - job_name: pg
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 10s
    static_configs:
      - targets: ['pgexporter:9187']
  - job_name: mysql
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 10s
    static_configs:
      - targets: ['mysqlexporter:9104']
  • pg dockerfile
    这个是改动过的pg 镜像,添加了pmm client (测试用的),里面包含了与pmm 集成的配置,但是暂时没用到,后期会尝试使用
 
FROM postgres:latest
RUN set -ex; \
    apt-get update; \
  apt-get install -y gnupg apt-transport-https; \
  echo 'deb https://repo.percona.com/apt stretch main' > /etc/apt/sources.list.d/percona.list; \
  apt-get update && apt-get install -y --allow-unauthenticated pmm-client; \
  apt-get remove --purge -y gnupg apt-transport-https; \
  apt-get autoremove -y --purge; \
  rm -rf /var/lib/apt/lists/* \
  true
COPY init.sql /docker-entrypoint-initdb.d/
COPY initpmm.sh /root/

启动&&测试

  • 启动
docker-compose up -d
  • 配置grafanna
    主要是关于prometheus 以及dashboard json 文件的导入, 具体文件参考github 项目
  • 配置gogs git server
    打开 http://localhost:3001 就可以进行配置了
  • 运行数据导入操作
    目的很简单就是进行数据的一些操作,多些监控指标的数据
    docker-compose up pgloader-mysql
  • 效果

说明

以上是一个简单的集成,实际上pmm还是一个不错的选择,后边重新配置下,运行起来,pmm还是不错的数据库监控工具。

参考资料

https://grafana.com/grafana/dashboards/6742/revisions
https://grafana.com/grafana/dashboards/6239/revisions
https://github.com/rongfengliang/mysql-pg-exporter-prometheus-grafana-docker-compose

promethues exporter+ grafana 监控pg+mysql的更多相关文章

  1. 【开源监控】Prometheus+Node Exporter+Grafana监控linux服务器

    Prometheus Prometheus介绍 Prometheus新一代开源监控解决方案.github地址 Prometheus主要功能 多维 数据模型(时序由 metric 名字和 k/v 的 l ...

  2. [k8s]prometheus+grafana监控node和mysql(普罗/grafana均vm安装)

    https://github.com/prometheus/prometheus Architecture overview Prometheus Server Prometheus Server 负 ...

  3. Grafana+Prometheus系统监控之MySql

    架构 grafana和prometheus之前安装配置过,见:Grafana+Prometheus打造全方位立体监控系统 MySql安装 MySql的地位和重要性就不言而喻了,作为开源产品深受广大中小 ...

  4. 使用Prometheus+Grafana监控MySQL实践

    一.介绍Prometheus Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,起始是由SoundCloud公司开发的.随着发展,越来越多公司和组织接受采 ...

  5. Prometheus+Grafana监控MySQL、Redis数据库

    俗话说,没有监控的系统就是在裸奔,好的监控就是运维人员的第三只手,第三只眼.本文将使用prometheus及Grafana搭建一套监控系统来监控主机及数据库(MySQL.Redis). 1.  安装G ...

  6. prometheus+grafana监控mysql

    prometheus+grafana监控mysql 1.安装配置MySQL官方的 Yum Repository(有mysql只需设置监控账号即可) [root@localhost ~]# wget - ...

  7. 初试 Prometheus + Grafana 监控系统搭建并监控 Mysql

    转载自:https://cloud.tencent.com/developer/article/1433280 文章目录1.Prometheus & Grafana 介绍1.1.Prometh ...

  8. 安装prometheus+grafana监控mysql redis kubernetes等

    1.prometheus安装 wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5 ...

  9. [转帖]安装prometheus+grafana监控mysql redis kubernetes等

    安装prometheus+grafana监控mysql redis kubernetes等 https://www.cnblogs.com/sfnz/p/6566951.html plug 的模式进行 ...

随机推荐

  1. Replication:The replication agent has not logged a progress message in 10 minutes.

    打开Replication Monitor,在Subscription Watch List Tab中,发现有大量的status= “Performance critical” 的黄色Warning, ...

  2. Queue介绍

    美人如斯! 前言 队列是一种先进先出(FIFO)的数据结构,与生活中的排队类似,即先来先被服务,这样的特点决定了其具有一定的优先级含义,可以被用于任务调度等场景.队列模型如图: 图1.队列模型 jav ...

  3. jq 简单实现 table 显示和隐藏

    在做table显示和隐藏的时候,需要用到节点的问题.不要用id.循环的时候id都是一样的. 这样一个简单的tr显示和隐藏就实现了.也可以将click 换成别的事件.

  4. Web api 右连接

    这是原来的代码,两个表的连接的方式是inner join ,查不出我要的全部数据. 后来把代码稍稍改一下,就是left join  join into 到一个临时对象里,相当于再select from ...

  5. String类的方法应用

    String类的几个方法的应用示例: using System;using System.Collections.Generic;using System.Linq;using System.Text ...

  6. 重温拉格朗日乘子法和KKT条件

    在求取有约束条件的优化问题时,拉格朗日乘子法(Lagrange Multiplier) 和KKT条件是非常重要的两个求取方法,对于等式约束的优化问题,可以应用拉格朗日乘子法去求取最优值:如果含有不等式 ...

  7. Ubuntu 挂载硬盘命令介绍

    版权声明:本文为博主原创文章,欢迎转载与采用. https://blog.csdn.net/HinstenyHisoka/article/details/71055656 新升级了Ubuntu 从16 ...

  8. 5 dex文件

    Dex文件中数据结构 类型 含义 u1 等同于uint8_t,表示1字节无符号数 u2 等同于uint16_t,表示2字节的无符号数 u4 等同于uint32_t,表示4字节的无符号数 u8 等同于u ...

  9. Java黑科技之源:JVMTI完全解读

    Java生态中有一些非常规的技术,它们能达到一些特别的效果.这些技术的实现原理不去深究的话一般并不是广为人知.这种技术通常被称为黑科技.而这些黑科技中的绝大部分底层都是通过JVMTI实现的. 形象地说 ...

  10. Linux学习之组管理和权限管理

    Linux组的基本介绍 在Linux中的每个用户必须属于一个组,不能独立于组外.在Linux中每个文件有所有者,所在组,其他组的概念. 1)所有者 2)所在组 3)其他组 4)改变用户所在的组 文件/ ...