MySQL_Exporter
# 5.7+
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'passwd' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
# 5.6
CREATE USER `exporter`@`%` IDENTIFIED BY 'passwd';
GRANT USAGE ON *.* TO `exporter`@`%` WITH MAX_USER_CONNECTIONS 3;
GRANT Process, Replication Client, Select ON *.* TO `exporter`@`%`;
tar mysqld_exporter-0.14.0.linux-amd64.tar.gz
cd mysqld_exporter-0.14.0.linux-amd64
export DATA_SOURCE_NAME='exporter:passwd@(localhost:3306)/'
mysqld_exportertar -zxf mysqld_exporter-0.14.0.linux-amd64.tar.gz
cp mysqld_exporter-0.14.0.linux-amd64/mysqld_exporter /usr/bin/
mkdir -p /etc/prometheus/mysqld_exporter/
cat > /etc/prometheus/mysqld_exporter/my.cnf << EOF
[client]
host=localhost
port=3306
user=exporter
password=passwd
EOF
cat > /etc/systemd/system/mysqld_exporter.service << EOF
[Unit]
Description=mysqld_exporter Daemon
[Service]
ExecStart=/usr/bin/mysqld_exporter \
--config.my-cnf=/etc/prometheus/mysqld_exporter/my.cnf \
--collect.auto_increment.columns \
--collect.binlog_size \
--collect.global_status \
--collect.global_variables \
--collect.info_schema.innodb_metrics \
--collect.info_schema.innodb_cmp \
--collect.info_schema.innodb_cmpmem \
--collect.info_schema.processlist \
--collect.info_schema.query_response_time \
--collect.info_schema.tablestats \
--collect.info_schema.userstats \
--collect.perf_schema.eventswaits \
--collect.perf_schema.file_events \
--collect.perf_schema.indexiowaits \
--collect.perf_schema.tableiowaits \
--collect.perf_schema.tablelocks \
--collect.slave_status \
--web.listen-address=0.0.0.0:9104
User=root
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
EOF部分错误处理记录
5.7.24版本 mysqld_exporter-0.15.1.linux-amd64
--collect.slave_status以下的几个参数是5.7专有的
--collect.slave_status以下的几个参数是5.7专有的--collect.slave_status以下的几个参数是5.6专有的
--collect.slave_status以下的几个参数是5.6专有的最后更新于