How to Install and Configure mysql_exporter on a Kubernetes Master Node
This guide walks through downloading the mysql_exporter package, extracting it on a Kubernetes master, installing the binary, creating a dedicated MySQL user with proper permissions, configuring a password‑less client file, launching the exporter, and updating Prometheus via kubectl so MySQL metrics are exposed on port 9104.
This article provides a step‑by‑step procedure for setting up mysqld_exporter on a Kubernetes master node to expose MySQL performance metrics to Prometheus.
Download and extract the exporter
tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gzInstall the binary
cd mysqld_exporter-0.10.0.linux-amd64
cp -ar mysqld_exporter /usr/local/bin/Make the binary executable
chmod +x /usr/local/bin/mysqld_exporterCreate a MySQL user for the exporter
mysql> CREATE USER 'mysql_exporter'@'localhost' IDENTIFIED BY 'Abcdef123!.';
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_exporter'@'localhost';
mysql> exitConfigure a password‑less client file
[client]
user=mysql_exporter
password=Abcdef123!.Run the exporter
nohup ./mysqld_exporter --config.my-cnf=./my.cnf &The exporter listens on port 9104.
Add a Prometheus job for MySQL
scrape_configs:
- job_name: 'mysql'
static_configs:
- targets: ['192.168.124.16:9104']Apply the updated Prometheus configuration
kubectl delete -f prometheus-cfg.yaml
kubectl apply -f prometheus-cfg.yaml
kubectl delete -f prometheus-deploy.yaml
kubectl apply -f prometheus-deploy.yamlAfter reloading, Prometheus begins collecting MySQL metrics from the exporter.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack DevOps & Kubernetes
Focused on sharing DevOps, Kubernetes, Linux, Docker, Istio, microservices, Spring Cloud, Python, Go, databases, Nginx, Tomcat, cloud computing, and related technologies.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
