本文共 2976 字,大约阅读时间需要 9 分钟。
vim .my.cnf[client]host=127.0.0.1user=rootpassword=root
vim /usr/lib/systemd/system/mysqld_exporter.service[Unit]Description=node_exporterDocumentation=https://prometheus.io/After=network.target[Service]Type=simpleUser=prometheusExecStart=/app/prometheus/mysqld_exporter/mysqld_exporter --config.my-cnf=/app/prometheus/mysqld_exporter/.my.cnfRestart=on-failure[Install]WantedBy=multi-user.target
systemctl daemon-reloadsystemctl enable mysqld_exporter.servicesystemctl start mysqld_exporter.service
#systemctl status mysqld_exporter.service● mysqld_exporter.service - node_exporter Loaded: loaded (/usr/lib/systemd/system/mysqld_exporter.service; enabled; vendor preset: disabled) Active: active (running) since 一 2019-06-17 00:11:52 CST; 4s ago Docs: https://prometheus.io/ Main PID: 27193 (mysqld_exporter) CGroup: /system.slice/mysqld_exporter.service └─27193 /app/prometheus/mysqld_exporter/mysqld_exporter --config.my-cnf=/app/prometheus/mysqld_exporter/.my.cnf6月 17 00:11:52 qas-zabbix4 systemd[1]: Started node_exporter.6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Starting mysqld_exporter (version=0.11.0, branch=HEAD, revision=5d7179615...ter.go:206"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Build context (go=go1.10.3, user=root@3d3ff666b0e4, date=20180629-15:00:3...ter.go:207"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Enabled scrapers:" source="mysqld_exporter.go:218"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.global_status" source="mysqld_exporter.go:222"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.global_variables" source="mysqld_exporter.go:222"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.slave_status" source="mysqld_exporter.go:222"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg=" --collect.info_schema.tables" source="mysqld_exporter.go:222"6月 17 00:11:52 qas-zabbix4 mysqld_exporter[27193]: time="2019-06-17T00:11:52+08:00" level=info msg="Listening on :9104" source="mysqld_exporter.go:232"Hint: Some lines were ellipsized, use -l to show in full.
vim /app/prometheus/cfg/prometheus.yml - job_name: 'mysqld' file_sd_configs: - files: ['/app/prometheus/sd_cfg/mysqld.yml'] refresh_interval: 5s
vim /app/prometheus/sd_cfg/mysqld.yml- targets: ['172.16.8.59:9104'] labels: name: mysql
systemctl restart prometheus.service
转载于:https://blog.51cto.com/10880347/2409787