在现代 IT 运维中,实时掌握服务器运行状态至关重要。对于使用 Debian 系统的用户来说,搭建一个直观、高效的监控仪表板不仅能提升故障排查效率,还能预防潜在风险。本文将从零开始,手把手教你如何在 Debian 系统上部署一套功能强大的开源监控平台,即使你是 Linux 新手也能轻松上手!

随着服务器数量和业务复杂度的增加,仅靠命令行查看 CPU、内存、磁盘等指标已远远不够。服务器性能可视化能帮助你:
本教程以 Debian 11(Bullseye)为例,你需要:
我们将使用 Prometheus + Grafana 组合——这是目前最流行的开源监控方案之一,完全免费且功能强大。
sudo apt updatesudo apt upgrade -ysudo apt install -y wget curl gnupg2 apt-transport-https首先创建专用用户并下载 Prometheus:
sudo useradd --no-create-home --shell /bin/false prometheuscd /tmpwget https://github.com/prometheus/prometheus/releases/latest/download/prometheus-*.linux-amd64.tar.gztar xvf prometheus-*.linux-amd64.tar.gzsudo cp prometheus-*/prometheus /usr/local/bin/sudo cp prometheus-*/promtool /usr/local/bin/sudo mkdir /etc/prometheus /var/lib/prometheussudo chown prometheus:prometheus /var/lib/prometheus接下来配置 Prometheus,创建主配置文件:
sudo nano /etc/prometheus/prometheus.yml填入以下基础配置(监控本机):
global: scrape_interval: 15sscrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node_exporter' static_configs: - targets: ['localhost:9100']Node Exporter 负责收集 CPU、内存、磁盘、网络等系统数据:
cd /tmpwget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-*.linux-amd64.tar.gztar xvf node_exporter-*.linux-amd64.tar.gzsudo cp node_exporter-*/node_exporter /usr/local/bin/sudo useradd --no-create-home --shell /bin/false node_exporter创建 systemd 服务以便开机自启:
sudo tee /etc/systemd/system/node_exporter.service <启动服务:
sudo systemctl daemon-reexecsudo systemctl enable --now node_exporter同样创建 systemd 服务:
sudo tee /etc/systemd/system/prometheus.service <启动 Prometheus:
sudo systemctl daemon-reexecsudo systemctl enable --now prometheus添加官方仓库并安装:
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.listsudo apt updatesudo apt install -y grafana启动 Grafana 服务:
sudo systemctl enable --now grafana-server现在打开浏览器,访问 http://你的服务器IP:3000(默认账号密码均为 admin)。
http://localhost:9090,点击「Save & Test」。恭喜!你现在拥有了一个功能完整的 Debian监控仪表板,可以实时查看 CPU 使用率、内存占用、磁盘 I/O、网络流量等关键指标。
通过本教程,你成功搭建了一套基于 Prometheus 和 Grafana 的开源监控平台,实现了服务器性能可视化。这套方案不仅适用于单台 Debian 服务器,还可轻松扩展至整个服务器集群。掌握这项技能,将极大提升你的系统运维能力!
如果你觉得本文对你有帮助,欢迎收藏并分享给更多需要的朋友。持续关注我们,获取更多 Linux 运维与 DevOps 实战技巧!
本文由主机测评网于2025-12-11发表在主机测评网_免费VPS_免费云服务器_免费独立服务器,如有疑问,请联系我们。
本文链接:https://www.vpshk.cn/2025126377.html