基于Prometheus和Grafana搭建高大上的mysql监控.

1 篇文章 0 订阅
1 篇文章 0 订阅
1、下载安装包

mysqld_exporter-0.12.1.linux-amd64.tar.gz

[mysql_exporter工具包][https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz]

node_exporter-1.0.0-rc.0.linux-amd64.tar.gz

[监控机器的工具包][https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.linux-amd64.tar.gz]

2、解压缩文件
tar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gz  -C /usr/local/
tar -zxvf node_exporter-1.0.0-rc.0.linux-amd64.tar.gz  -C /usr/local/
3、导入mysql的一些配置
export DATA_SOURCE_NAME="username:password@(host:port)/"
echo "export DATA_SOURCE_NAME='username:password@(host:port)/'" >>/etc/profile
4、启动mysqld_exporter
cd /usr/local/mysqld_exporter-0.12.1.linux-amd64/
#启动
nohup ./mysqld_exporter --collect.info_schema.innodb_tablespaces --collect.info_schema.innodb_metrics --collect.info_schema.innodb_cmp --collect.info_schema.innodb_cmpmem --collect.perf_schema.tableiowaits --collect.perf_schema.indexiowaits --collect.perf_schema.tablelocks --collect.engine_innodb_status  --collect.perf_schema.file_events  --collect.info_schema.processlist  --collect.binlog_size  --collect.info_schema.clientstats  --collect.perf_schema.eventswaits &

通过netstat -tnlp | grep "9104"可以查看到本地已经在监听9104端口了。

6、启动node exporter
#cd
cd node_exporter-1.0.0-rc.0.linux-amd64/
#启动
nohup ./node_exporter &

通过netstat -tnlp | grep "9100"可以查看到本地已经在监听9100端口了。

7、配置Prometheus
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'mysql'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    metrics_path: 'metrics'
    static_configs:
    - targets: ['host:9104']

  - job_name: 'node'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    metrics_path: 'metrics'
    static_configs:
    - targets: ['host:9100']

启动Prometheus

/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml &

进入到Prometheus的管理页面查看目标是否已经接通并且可以抓取。选择Status->Target菜单,就可以看到配置的俩个exporter源都已经是UP状态了。

mark

Prometheus也提供了一个简单的查询页面,可以按照查询条件去展示值或者图形。

mark

8、高大上的Grafana

和Prometheus最搭的还是Grafana,Grafana是一款强大的展示监控信息的web图形展示工具。对于各种指标都能以合适的图形展示出来。

这里我们选取的是俩款Grafana模板来展示上文搭建的监控指标。

1、[MYSQL Overview][https://grafana.com/grafana/dashboards/7362]

效果如下:

mark

mark

2,[机器指标监控][https://grafana.com/grafana/dashboards/8919]

效果如下:

mark

mark

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值