Deploying Prometheus, Node Exporter, and MySQL Exporter on Linux and Configuring Grafana Monitoring
This guide walks through installing Prometheus, node_exporter, and mysql_exporter on a Linux server, editing Prometheus configuration to scrape node and MySQL metrics, verifying the setup, and creating a Grafana dashboard to visualize MySQL performance data.
1. Deploy Prometheus
tar -zxvf prometheus-2.39.1.linux-amd64.tar.gz
cd prometheus-2.39.1.linux-amd64
mv prometheus-2.39.1.linux-amd64 /usr/local/prometheus
systemctl daemon-reload
systemctl start prometheus
2. Deploy node_exporter
tar -zxvf node_exporter-1.4.0.linux-amd64.tar.gz
3. Modify Prometheus configuration (prometheus.yml)
Add a job for the node exporter:
- job_name: 'node'
file_sd_configs:
- files: ['/usr/local/prometheus/sd_config/node.yml']
refresh_interval: 5s
Create /usr/local/prometheus/sd_config/node.yml with the target:
- targets:
- 192.168.20.235:9100
4. Check the configuration file
./promtool check config prometheus.yml
5. Monitor MySQL service with mysql_exporter
5.1 Create a MySQL user for the exporter and grant permissions:
mysql> create user 'node_exporter'@'localhost' identified by '123456';
mysql> grant process,replication client,select on *.* to 'node_exporter'@'localhost';
mysql> flush privileges;
5.2 Install mysql_exporter:
tar -zxvf mysqld_exporter-0.14.0.linux-amd64.tar.gz
5.3 Create a configuration file /usr/local/mysql_exporter/.my.cnf for password‑less access:
[client]
user=node_exporter
password=123456
5.4 Start the exporter and register it as a systemd service:
nohup /usr/local/mysql_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf &
systemctl daemon-reload
systemctl restart mysql_exporter.service
6. Add MySQL exporter to Prometheus scrape configuration
- job_name: "mysql"
static_configs:
- targets: ["192.168.20.8:9104"]
7. Configure Grafana MySQL dashboard template
Conclusion
If this article helped you, please like, view, and share it; your support encourages me to continue creating high‑quality content. Thank you 🙏🏻
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
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.