在现代IT运维中,监控系统是保障业务稳定运行的核心。Ubuntu Prometheus安装教程是许多开发者入门监控领域的首选。本文将手把手带你完成Prometheus与Grafana的搭建,通过Prometheus一键部署脚本,即便是技术小白也能轻松上手,构建高效的Linux系统监控方案。
在开始之前,请确保你拥有一台安装了Ubuntu系统的服务器(推荐20.04或22.04 LTS版本),并拥有root权限或sudo权限。我们将通过Grafana可视化面板配置来展示最终的监控效果。
为了提高效率,我们将安装过程封装为Shell脚本。请在终端执行以下操作:
# 创建部署脚本
cat << 'EOF' > deploy_monitor.sh
#!/bin/bash
# 更新软件源
sudo apt-get update
# 安装Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
tar -xvf prometheus-2.45.0.linux-amd64.tar.gz
cd prometheus-2.45.0.linux-amd64
nohup ./prometheus --config.file=prometheus.yml > prometheus.log 2>&1 &
# 安装Grafana
sudo apt-get install -y apt-transport-https software-properties-common
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.list
sudo apt-get update && sudo apt-get install grafana -y
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
echo "部署成功!Prometheus端口:9090, Grafana端口:3000"
EOF
# 运行脚本
bash deploy_monitor.sh
1. Prometheus验证:打开浏览器访问 http://IP:9090,看到指标查询界面说明安装成功。
2. Grafana登录:访问 http://IP:3000,默认用户名和密码均为 admin。
3. 添加数据源:在Grafana中点击"Data Sources",选择Prometheus,URL填写 http://localhost:9090 即可完成对接。
© 2023 监控系统实战指南 - 运维技术分享
本文由主机测评网于2026-04-02发表在主机测评网_免费VPS_免费云服务器_免费独立服务器,如有疑问,请联系我们。
本文链接:https://vpshk.cn/20260432945.html