利用Grafana配合prometheus监控mysql系统资源

先放安装包为敬:
所需要的安装包都在这里
链接:https://pan.baidu.com/s/1_5Jv8Lhcu2rHPLnsMUmwJw
提取码:d5te
复制这段内容后打开百度网盘手机App,操作更方便哦

Grafana监控mysqljson模板:
链接:https://pan.baidu.com/s/1PmcbONO2f_I5BYh9S5HqZg
提取码:hol7
复制这段内容后打开百度网盘手机App,操作更方便哦

安装prometheus(普罗米修斯):
1.将 prometheus-2.15.2.linux-amd64.tar.gz 解压到 /usr/local/ 下
2.将 /usr/local/prometheus-2.15.2.linux-amd64 改名为 /usr/local/prometheus
3.修改配置文件 /usr/local/prometheus/prometheus.yml

 # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
 - job_name: 'prometheus'
   static_configs:
   - targets: ['localhost:9090']

 - job_name: 'linux'
   static_configs:
   - targets: ['localhost:9100']
   
 - job_name: 'mysql'
   static_configs:
   - targets: ['localhost:9104']
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

2.安装Node_Epoeter:
解压完成后守护进程即可:

nohup ./node_exporter > /dev/null 2> /dev/null&

3.修改Mysql权限:

# 选择使用mysql库
root@db 16:04:  [(none)]> use mysql
Database changed

# 创建用户'mysqld_exporter'@'localhost'并设置密码为123456
root@db 16:04:  [mysql]> create user 'mysqld_exporter'@'localhost' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.07 sec)

# 给用户'mysqld_exporter'@'localhost'授权
root@db 16:06:  [mysql]> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'mysqld_exporter'@'localhost';
Query OK, 0 rows affected (0.01 sec)

root@db 16:06:  [mysql]> GRANT SELECT ON performance_schema.* TO 'mysqld_exporter'@'localhost';
Query OK, 0 rows affected (0.01 sec)

# 刷新MySQL的系统权限相关表­
root@db 16:06:  [mysql]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

4.启动mysqld_exporter:

如果报错FATA[0000] no user or password specified under [client] in /root/.my.cnf  source="mysqld_exporter.go:264
在使用vim 在/root/.my.cnf写入如下内容
[client]
host=XXX.XXX.XXX.XXX
port=3306
user=root
password=123456

启动成功出现这边表示启动成功
在这里插入图片描述
5.配合Grafana使用:
不知道怎么安装Grafana的:点击这里跳转后既可观看教程.
划重点————————————————————————————
json文件已经发在上面了,接下来照葫芦画瓢

1.先在Grafana中导入json模块
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
导入后出下如图即表示成功:
在这里插入图片描述

分享最近喜欢的一句话:
兴趣是最好的老师,
其次是屈辱,
所谓无底深渊,
下去也是前程万里。

大家在学习中,有什么问题,可以扫描下方二维码进群沟通交流。
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值