zoukankan      html  css  js  c++  java
  • prometheus监控mysql

    创建一个用于mysqld_exporter连接到MySQL的用户并赋予所需的权限

    mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'mysqld_exporter'@'localhost' identified by '000000';
    mysql> GRANT SELECT ON performance_schema.* TO 'mysqld_exporter'@'localhost';
    mysql> flush privileges;

    创建一个用于连接MySQL的配置文件

    mysqld_exporter默认会读取~/.my.cnf文件。这里是创建在mysqld_exporter的安装目录下的。

    $ vim /usr/local/prom/mysqld_exporter_0110/.my.cnf
    
    [client]
    user=mysqld_exporter
    password=000000

    创建Systemd服务

    #vim /etc/systemd/system/mysql_exporter.service
    [Unit]
    Description=mysql_exporter
    After=network.target
    [Service]
    Type=simple
    User=prometheus
    ExecStart=/usr/local/prom/exporter/mysqld_exporter_0110/mysqld_exporter --config.my-cnf=/usr/local/prom/exporter/mysqld_exporter_0110/.my.cnf
    Restart=on-failure
    [Install]
    WantedBy=multi-user.target

    启动mysqld_exporter

    # systemctl start mysql_exporter
    # systemctl status mysql_exporter

    添加prometheus相关配置

    # vi prometheus280/prometheus.yml
    
      - job_name: 'mysql'
    
        static_configs:
        - targets: ['localhost:9104']
          labels:
              instance: db1

    重启prometheus即可

  • 相关阅读:
    supervisor启动错误解决(二)
    删除文件某行
    离线安装
    docker中/var/lib/docker目录迁移
    if else 使用
    Django views函数添加装饰器
    Netty4
    Fast DFS(二)
    Fast DFS(一)
    SpringBoot和app之间跨域问题
  • 原文地址:https://www.cnblogs.com/roger888/p/10535615.html
Copyright © 2011-2022 走看看