在当今的大数据时代,对服务器和应用系统的实时监控变得尤为重要。对于使用 Ubuntu 系统部署大数据平台(如 Hadoop、Spark 等)的用户来说,一套高效、可视化的 大数据监控 系统不仅能帮助你及时发现性能瓶颈,还能预防潜在故障。本文将带你从零开始,在 Ubuntu 系统上搭建基于 Prometheus 和 Grafana 的监控平台,即使你是 Linux 小白也能轻松上手!

确保你的 Ubuntu 系统已更新,并具备基本网络访问权限:
sudo apt updatesudo apt upgrade -yPrometheus 是一个开源的 系统性能监控 工具,专门用于收集和存储时间序列数据。
sudo useradd --no-create-home --shell /bin/false prometheuswget https://github.com/prometheus/prometheus/releases/download/v2.47.1/prometheus-2.47.1.linux-amd64.tar.gztar xvfz prometheus-2.47.1.linux-amd64.tar.gzsudo mv prometheus-2.47.1.linux-amd64 /opt/prometheussudo mkdir /etc/prometheus /var/lib/prometheussudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus/etc/prometheus/prometheus.yml:global: scrape_interval: 15sscrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node' static_configs: - targets: ['localhost:9100']sudo tee /etc/systemd/system/prometheus.service <sudo systemctl daemon-reloadsudo systemctl start prometheussudo systemctl enable prometheusNode Exporter 负责采集 CPU、内存、磁盘、网络等 系统性能监控 指标,并暴露给 Prometheus。
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gztar xvfz node_exporter-1.7.0.linux-amd64.tar.gzsudo mv node_exporter-1.7.0.linux-amd64/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-reloadsudo systemctl start node_exportersudo systemctl enable node_exporterGrafana 是业界领先的 可视化 工具,能将 Prometheus 采集的数据以图表形式直观展示,是构建 Ubuntu大数据监控 平台的关键组件。
sudo apt-get install -y apt-transport-https software-properties-common wgetwget -q -O - https://packages.grafana.com/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/grafana-keyring.gpgecho "deb [signed-by=/usr/share/keyrings/grafana-keyring.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.listsudo apt updatesudo apt install grafana -y启动 Grafana:
sudo systemctl start grafana-serversudo systemctl enable grafana-serverhttp://你的服务器IP:3000(默认账号密码均为 admin)http://localhost:9090Grafana 社区提供了大量现成的仪表盘模板。推荐使用 ID 1860(Node Exporter Full)来监控系统资源:
1860通过以上步骤,你已经成功在 Ubuntu 上搭建了一套完整的 大数据监控 系统。这套方案不仅适用于单机环境,还可扩展至集群,配合 Alertmanager 实现告警功能。掌握 Prometheus安装配置 与 Grafana可视化 技能,将极大提升你在运维和大数据领域的竞争力。
现在就动手试试吧!如有问题,欢迎在评论区交流~
本文由主机测评网于2025-12-25发表在主机测评网_免费VPS_免费云服务器_免费独立服务器,如有疑问,请联系我们。
本文链接:https://vpshk.cn/20251212541.html