下载安装mysql_exporter
cd /usr/localwget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gztar -zxvf mysqld_exporter-0.12.1.linux-amd64.tar.gzmv mysqld_exporter-0.12.1.linux-amd64 mysqld_exportermysql的pxc集群添加账号密码:GRANT REPLICATION CLIENT, PROCESS ON . TO 'exporter'@'localhost' identified by '123456';GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';flush privileges;[root@pxc1 mysqld_exporter]# cat .my.cnf[client]host=192.168.7.201user=exporterpassword=123456启动:nohup ./mysqld_exporter --config.my-cnf=.my.cnf &
Prometheus配置
- job_name: 'mysql-cluster'static_configs:- targets:- '192.168.7.201:9104'- '192.168.7.202:9104'- '192.168.7.203:9104'报警:############ mysql 监控 ############- alert: MySQLGaleraNotReadyexpr: mysql_global_status_wsrep_ready != 1for: 5mlabels:severity: warningannotations:description: "{{$labels.job}} on {{$labels.instance}} is not ready."summary: "Galera cluster node not ready"- alert: MySQLGaleraOutOfSyncexpr: (mysql_global_status_wsrep_local_state != 4 and mysql_global_variables_wsrep_desync == 0)for: 5mlabels:severity: warningannotations:description: "{{$labels.job}} on {{$labels.instance}} is not in sync ({{$value}}!= 4)."summary: "Galera cluster node out of sync"- alert: MySQL is downexpr: mysql_up == 0for: 1mlabels:severity: criticalannotations:description: "Instance {{ $labels.instance }} MySQL is down"summary: "MySQL database is down. This requires immediate action!"- alert: MySql 连接数超过最大连接数的80%expr: mysql_global_status_max_used_connections > mysql_global_variables_max_connections * 0.8for: 2mlabels:severity: warningannotations:description: "Instance {{ $labels.instance }} Used more than 80% of max connections limited"summary: "Used more than 80% of max connections limited"
grafana导入模板
https://grafana.com/grafana/dashboards/7362 mysql插件

https://grafana.com/grafana/dashboards/7377 pxc插件

文章转载自云原生数字化,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




