In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to use Prometheus to monitor MySQL and MariaDB.md". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Introduction to the principle of mysqld-exporter
Mysqld-exporter reads some database status data in MySQL or MariaDB, converts them into Prometheus metric format and exposes them to http interface to be collected by Prometheus, so that MySQL and MariaDB which originally do not support Prometheus metrics can be monitored by Prometheus:
Procedure to deploy mysqld-exporter
Before deploying mysqld-exporter, make sure that MySQL or MariaDB has been deployed, either within or outside the cluster, or using off-the-shelf cloud services. If not, take deployment from application market to cluster as an example to deploy a MySQL:
Find MySQL in the application market and click create Application-create.
Check to see if mysql is working properly:
$kubectl get podsNAME READY STATUS RESTARTS AGEmysql-698b898bf7-4dc5k 1 Compact 1 Running 0 11s
Get the root password:
$kubectl get secret-o jsonpath= {.data.MySQL-root-password} mysql6ZAj33yLBo
With MySQL, we are ready to deploy mysqld-exporter. First, create an account for mysqld-exporter and log in to MySQL:
$kubectl exec-it mysql-698b898bf7-4dc5k bash$ mysql- uroot-p6ZAj33yLBo
Then type SQL to create an account. Take mysqld-exporter/123456 as an example:
CREATE USER 'mysqld-exporter' IDENTIFIED BY' 123456 'WITH MAX_USER_CONNECTIONS 3 * Grant PROCESS, REPLICATION CLIENT, REPLICATION SLAVE, SELECT ON *. * TO' mysqld-exporter';flush privileges
Then use the following yaml to deploy mysqld-exporter:
ApiVersion: apps/v1kind: Deploymentmetadata: name: mysqld-exporterspec: replicas: 1 selector: matchLabels: app: mysqld-exporter template: metadata: labels: app: mysqld-exporterspec: containers:-name: mysqld-exporter image: prom/mysqld-exporter:v0.12.1 args:-- collect.info_schema.tables-collect.info_schema. Innodb_tablespaces-collect.info_schema.innodb_metrics-collect.global_status-collect.global_variables-collect.slave_status-collect.info_schema.processlist-collect.perf_schema.tablelocks-collect.perf_schema.eventsstatements-collect.perf_schema.eventsstatementssum -collect.perf_schema.eventswaits-collect.auto_increment.columns-collect.binlog_size-collect.perf_schema.tableiowaits-collect.perf_schema.indexiowaits-collect.info_schema.userstats-collect.info_schema.clientstats-collect.info_schema.tablestats -collect.info_schema.schemastats-collect.perf_schema.file_events-collect.perf_schema.file_instances-collect.perf_schema.replication_group_member_stats-collect.perf_schema.replication_applier_status_by_worker-collect.slave_hosts-collect.info_schema.innodb_cmp -collect.info_schema.innodb_cmpmem-collect.info_schema.query_response_time-- collect.engine_tokudb_status-collect.engine_innodb_status ports:-containerPort: 9104 protocol: TCP env:-name: DATA_SOURCE_NAME value: "mysqld-exporter:123456@ (mysql. Default.svc.cluster.local:3306) / "- apiVersion: v1kind: Servicemetadata: name: mysqld-exporter labels: app: mysqld-exporterspec: type: ClusterIP ports:-port: 9104 protocol: TCP name: http selector: app: mysqld-exporter
! Pay attention to replace the account password in DATA_SOURCE_NAME and the connection address of MySQL according to the actual situation
Add monitoring collection configuration
With mysqld-exporter, we can configure monitoring collection so that the data exposed by mysqld-exporter can be collected. If prometheus-operator is installed in your cluster, you can configure collection rules by defining ServiceMonitor. Example:
ApiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata: name: mysqld-exporterspec: endpoints: interval: 5s targetPort: 9104 namespaceSelector: matchNames:-default selector: matchLabels: app: mysqld-exporter
You can configure the collection rules by modifying the native configuration file of Prometheus. For example:
-job_name: mysqld-exporter scrape_interval: 5s kubernetes_sd_configs:-role: endpoints namespaces: names:-default relabel_configs:-action: keep source_labels:-_ meta_kubernetes_service_label_app_kubernetes_io_name regex: mysqld-exporter-action: keep source_labels:- _ _ meta_kubernetes_endpoint_port_name regex: http add monitoring panel
After collecting and configuring the data normally, you need to add a monitoring panel for Grafana to display. If you only look at some overview of MySQL or MariaDB, you can import this panel of grafana.com: https://grafana.com/grafana/dashboards/7362.
This is the end of "how to use Prometheus to monitor MySQL and MariaDB.md". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.