• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

prometheus mysqld_exporter监控mysql-5.7

mysql技术 思考_ 59次浏览 已收录 0个评论

1、下载及解压安装包

https://github.com/prometheus/mysqld_exporter
tar -xvf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /app/prometheus

2、创建密码填写内容.my.cnf文件

vim .my.cnf
[client]
host=127.0.0.1
user=root
password=root

3、创建mysqld_exporter.service 的 systemd unit 文件

vim /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/app/prometheus/mysqld_exporter/mysqld_exporter --config.my-cnf=/app/prometheus/mysqld_exporter/.my.cnf
Restart=on-failure

[Install]
WantedBy=multi-user.target

4、启动服务

systemctl daemon-reload
systemctl enable mysqld_exporter.service
systemctl start mysqld_exporter.service

5、运行状态

#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.cnf

6月 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.

http://172.16.8.59:9104/metrics
prometheus mysqld_exporter监控mysql-5.7

6、prometheus.service添加配置

vim /app/prometheus/cfg/prometheus.yml 
  - job_name: 'mysqld'     
    file_sd_configs:
      - files: ['/app/prometheus/sd_cfg/mysqld.yml']
        refresh_interval: 5s

7、基于文件发现添加配置文件

vim /app/prometheus/sd_cfg/mysqld.yml
- targets: ['172.16.8.59:9104']
  labels:
   name: mysql

8、重启服务

systemctl restart prometheus.service 

prometheus mysqld_exporter监控mysql-5.7

9、grafana图像展示

prometheus mysqld_exporter监控mysql-5.7


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明prometheus mysqld_exporter监控mysql-5.7
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址