美文网首页
mysqld_exporter-部署

mysqld_exporter-部署

作者: 李哈哈_2c85 | 来源:发表于2023-12-20 14:23 被阅读0次

    1、下载mysqld_exporter

    [GitHub - prometheus/mysqld_exporter at v0.11.0]
    https://github.com/prometheus/mysqld_exporter/tree/v0.11.0
    
    wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz
    tar  -zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz
    mv mysqld_exporter-0.11.0.linux-amd64 mysqld_exporter
    mv mysqld_exporter /usr/local/
    

    2、mysql中创建相应账号

    CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'system@123!' WITH MAX_USER_CONNECTIONS 3;
    GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
    flush privileges;
    

    3、设置成服务

    vim /usr/lib/systemd/system/mysqld_exporter.service
    
    [Unit]
    Description=mysqld_exporter
    After=network.target
    [Service]
    Type=simple
    User=prometheus
    Environment='DATA_SOURCE_NAME=exporter:system@123!@tcp(127.0.0.1:3306)/'
    ExecStart=/usr/local/prometheus_exporter/mysqld_exporter \
              --config.my-cnf='/data/GreatSQL/my.cnf' \
              --collect.engine_innodb_status \
              --collect.slave_status \
              --web.listen-address=:9104 \
              --web.telemetry-path=/metrics
    Restart=on-failure
    RestartSec=60s
    [Install]
    WantedBy=multi-user.target
    
    #启动服务
    systemctl enable mysqld_exporter.service
    systemctl start mysqld_exporter.service
    #测试服务是否正常
    curl http://localhost:9104/metrics
    

    4、prometheus添加监控、grafana添加模版

        - job_name: 'mysql_health'
          scrape_interval: 3s
          static_configs:
          - targets:
            - '192.168.3.101:9104'
            - '192.168.3.199:9104'
    
    
    #grafana模版 https://grafana.com/grafana/dashboards  去搜mysql
    7362
    

    相关文章

      网友评论

          本文标题:mysqld_exporter-部署

          本文链接:https://www.haomeiwen.com/subject/xjgtndtx.html