zoukankan      html  css  js  c++  java
  • Prometheus+mysqld_exporter

    mysqld_exporter

    mysqld_exporter是Prometheus对MySQL的监控插件

    下载地址

    这里要选择自己合适的版本

    下载并解压

    wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
    tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
    

    ARM版本

    wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-arm64.tar.gz
    tar -zxvf mysqld_exporter-0.12.1.linux-arm64.tar.gz
    

    创建mysqld_exporter配置文件

    cd mysqld_exporter-0.12.1.linux-arm64/
    vim .my.cnf
    
    [client]
    host=localhost
    port=3306
    user=mysqld_exporter
    password=Fwigff+A0T0
    

    创建Prometheus中的mysqld_exporter配置文件

    vim mysql.yml
    
    - labels:
        service: mysql
      targets:
      - localhost
    

    创建mysqld_exporter数据库用户并配置数据库权限

    create user 'mysqld_exporter'@'%' identified by 'Fwigff+A0T0' with MAX_USER_CONNECTIONS 3 ;
    
    grant process,replication client,select on *.* to 'mysqld_exporter'@'%';
    
    
    FLUSH PRIVILEGES;
    

    配置启动文件

    vim /etc/systemd/system/mysqld_exporter.service
    
    [Unit]
    Description=Prometheus Monitoring System
    Documentation=Prometheus Monitoring System
    
    [Service]
    ExecStart=/opt/monitor/service/mysqld_exporter-0.12.1.linux-arm64/mysqld_exporter 
         --config.my-cnf=/opt/monitor/service/mysqld_exporter-0.12.1.linux-arm64/.my.cnf
    
    [Install]
    WantedBy=multi-user.target
    
    


    刷新文件

    systemctl daemon-reload
    

    启动命令

    systemctl start mysqld_exporter    #启动
    systemctl stop mysqld_exporter     #停止
    systemctl restart mysqld_exporter  #重启
    systemctl status mysqld_exporter   #查看状态
    

    配置Prometheus配置文件

    vim prometheus.yml
    
    - file_sd_configs:
          - files:
              - mysql.yml
        job_name: MySQL
        scrape_interval:     5s
        metrics_path: /metrics
        relabel_configs:
          - source_labels: [__address__]
            regex: (.*)
            target_label: instance
            replacement: $1
          - source_labels: [__address__]
            regex: (.*)
            target_label: __address__
            replacement: $1:9104
    

    重启Prometheus

    配置Grafana

    输入7362


  • 相关阅读:
    [LeetCode] 981. Time Based Key-Value Store
    [LeetCode] 97. Interleaving String
    [LeetCode] 953. Verifying an Alien Dictionary
    代价敏感的学习方法
    深度学习中Dropout原理解析
    梯度下降法的三种形式BGD、SGD以及MBGD
    吉布斯采样(Gibbs Sampling)简介(转)
    Java中next()和hasNext() ? nextLine()和hasNextLine()?区别详解
    红黑树介绍及旋转详解
    Pycharm中实现openCV安装好后简单测试
  • 原文地址:https://www.cnblogs.com/SunMoonSky/p/14012623.html
Copyright © 2011-2022 走看看