设置 mysqld_exporter 为系统服务:
[root@localhost system]# pwd
/usr/lib/systemd/system
[root@localhost system]# cat mysqld_exporter.service
[Unit]
Description=mysqld_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
#Type=prometheus
User=Prometheus #如果是安装在 root 用户下,注释该参数
ExecStart=ExecStart=/usr/local/mysqld_exporter-0.12.1.linux-
amd64/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter-0.12.1.linux-
amd64/.my.cnf #根据实际路径修改
Restart=on-failure
[Install]
WantedBy=multi-user.target
该 mysqld_exporter 是部署在 prometheus 用户下(在 Service]段中有写 User=prometheus,如果是
部署在 root 用户下,则注释 User=prometheus,保存好文件后,执行如下操作:
systemctl daemon-reload
systemctl enable mysqld_exporter
systemctl start mysqld_exporter
systemctl status mysqld_exporter
评论