2.2 supervisor+mysqld_exporter
mysqld_exporter
裸跑有点慌。所以使用进程管理工具 supervisor
协助管理。# 脚本模版
$ cat mysqld_exporter.xxxx.conf
[program:xxxx]
directory = /opt/mysqld_exporter
command = /bin/nohup /opt/mysqld_exporter/mysqld_exporter --web.listen-address=[IP]:[PORT] --collect.global_status --collect.global_variables --collect.slave_status --collect.binlog_size --collect.engine_innodb_status --collect.info_schema.innodb_metrics --collect.info_schema.innodb_tablespaces --collect.info_schema.processlist --collect.info_schema.tablestats --collect.perf_schema.eventsstatements --collect.perf_schema.eventswaits --collect.perf_schema.file_events
autostart = true
startsecs = 5
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /var/log/supervisor/xxxx.log
environment=DATA_SOURCE_NAME='user:password@(hostname:3306)/'
$ supervisorctl status
mysql_xxx_01 RUNNING pid 13935, uptime 4:15:15
mysql_xxx_02 RUNNING pid 14053, uptime 4:15:15
mysql_xxx_03 RUNNING pid 13866, uptime 4:15:15
...