AI智能摘要
深夜收到服务器宕机告警,你是对着满屏日志盲目重启,还是能精准定位到那个拖垮系统的“隐形杀手”?大多数运维人只盯着 CPU 和内存的使用率,却忽略了 IO 等待和 P99 响应时间这些真正决定生死的细节。错误的排查顺序不仅浪费黄金救援时间,更可能让一次小波动演变成严重事故。从 Prometheus 的陷阱配置到 top 命令里被误读的数据,这篇文章将拆解一套经过实战验证的故障排查逻辑,帮你避开那些 90% 的人都会踩的坑。当告警再次响起,你确定手中的工具真的能救命吗?
— AI 生成的文章内容摘要
linux 服务器监控与故障排查实战
一、监控指标体系
1.1 基础指标

- CPU 使用率(用户态、内核态、IO 等待) - 内存使用率(已用、缓存、Swap) - 磁盘使用率(空间、IO、inode) - 网络流量(带宽、连接数、丢包率)
1.2 业务指标
- QPS(每秒查询数) - 响应时间(P50、P95、P99) - 错误率(4xx、5xx) - 业务成功率
---
二、监控工具选型
2.1 开源方案
| 工具 | 用途 | 特点 |
|---|---|---|
| **Prometheus** | 指标收集 | 时序数据库、Pull 模式 |
| **Grafana** | 可视化 | 丰富的图表、告警 |
| **Zabbix** | 综合监控 | 功能全面、学习曲线陡 |
| **Nagios** | 告警 | 插件丰富、配置复杂 |
2.2 商业方案
- 阿里云云监控 - 腾讯云监控 - 听云 - OneAPM
---
三、实战:搭建 Prometheus 监控
3.1 安装 Prometheus
# 下载 wget https://github.com/prometheus/prometheus/releases/download/v2.40.0/prometheus-2.40.0.linux-amd64.tar.gz # 解压 tar -xzf prometheus-*.tar.gz cd prometheus-* # 启动 ./prometheus --config.file=prometheus.yml
3.2 配置 Node Exporter
# 安装 wget https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz tar -xzf node_exporter-*.tar.gz cd node_exporter-* ./node_exporter # 验证 curl http://localhost:9100/metrics
3.3 配置 Grafana
# Docker 安装 docker run -d -p 3000:3000 grafana/grafana # 添加数据源 # http://prometheus-server:9090 # 导入 Dashboard # ID: 1860(Node Exporter Full)
---
四、故障排查流程
4.1 CPU 过高
# 查看负载 uptime w # 查看进程 top -c htop # 查看具体进程 pidstat -u 1 # 查看内核态 vmstat 1
4.2 内存不足
# 查看内存 free -h # 查看进程 ps aux --sort=-%mem | head # 查看 Swap vmstat 1 # 清理缓存 sync && echo 3 > /proc/sys/vm/drop_caches
4.3 磁盘 IO 高
# 查看 IO iostat -x 1 # 查看进程 iotop # 查看磁盘 df -h du -sh /*
4.4 网络问题
# 查看连接 netstat -ant | grep ESTABLISHED | wc -l # 查看流量 iftop nethogs # 查看丢包 ping -c 100 target.com
---
五、告警配置
5.1 Prometheus Alertmanager
# alertmanager.yml
route:
receiver: 'email'
group_by: ['alertname']
receivers:
- name: 'email'
email_configs:
- to: 'admin@example.com'
from: 'alert@example.com'
smarthost: 'smtp.example.com:587'
5.2 告警规则
# alert.rules.yml
groups:
- name: server
rules:
- alert: HighCPU
expr: 100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
for: 5m
labels:
severity: warning
annotations:
summary: "CPU 使用率过高"
---
六、总结
监控体系核心:指标全面、告警准确、响应及时
---
作者:爪
分类:安全运维
标签:服务器监控、故障排查、Prometheus、Grafana、linux 运维
发布时间:2026-03-19

浙江省宁波市 1F
这配置在M1上能跑吗?