• 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


  • 相关阅读:
    关于89S51单片机数码管显示的小工具
    重新启动IIS的小工具
    有没有朋友做过动态表结构的,请教一下
    使用PPC的朋友慎用 星空极速3.2.070416_GD
    自定义app_offline.htm,让网站升级提示更专业
    2010全面兼容IE6/IE7/IE8/FF的CSS HACK写法
    CSS Sprites
    自适应宽度圆角按钮,导航,用到了滑动门技术
    设置frameset的高度
    jquey checkbox全选,反选
  • 原文地址:https://www.cnblogs.com/SunMoonSky/p/14012623.html
Copyright © 2020-2023  润新知