mysqld_exporter部署

警告
本文最后更新于 2020-08-26 11:01,文中内容可能已过时。

1.下载安装:

1
2
3
wget https://github.91chifun.workers.dev//https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
tar xf mysqld_exporter-0.12.1.linux-amd64.tar.gz
mv mysqld_exporter-0.12.1.linux-amd64/mysqld_exporter /usr/local/bin/mysqld_exporter

2.创建监控用户:

1
2
CREATE USER 'exporter'@'localhost' IDENTIFIED BY '123456' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';

3.制作启动服务:

vim /usr/lib/systemd/system/mysqld_exporter.service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[Unit]
Description=mysqld_exporter
Documentation=https://github.com/prometheus/mysqld_exporter
After=network.target

[Service]
Type=simple
User=mysql
Environment=DATA_SOURCE_NAME=exporter:123456@(localhost:3306)/
ExecStart=/usr/local/bin/mysqld_exporter --web.listen-address=0.0.0.0:9104 \
  --log.level=error \
  --collect.info_schema.innodb_metrics \
  --collect.info_schema.innodb_tablespaces \
  --collect.info_schema.innodb_cmp \
  --collect.info_schema.innodb_cmpmem
Restart=on-failure
[Install]
WantedBy=multi-user.target

4.启动服务:

1
2
systemctl start mysqld_exporter
systemctl enable mysqld_exporter

5.测试metrics

1
curl localhost:9104/metrics

6.配置prometheus

1
2
3
4
    scrape_configs:
      - job_name: mysqld_exporter
        static_configs:
        - targets: ['10.0.0.73:9104']
请我喝杯水
SoulChild 微信号 微信号
SoulChild 微信打赏 微信打赏
0%