服务器 CLI(命令行界面)排查故障通常遵循“从外到内、从系统到应用、从资源到日志”的思路。下面给你一套通用排查流程 + 常用命令清单,适用于 Linux 服务器(Windows Server 也有对应说明)。
在 CLI 里先问自己:
uptime
top
htop # 更友好(需安装)
重点看:
free -h
available 而不是 freedf -h
df -i
du -sh /*
du -sh /var/*
iostat -x 1
(需安装 sysstat)
%util 高 = 磁盘瓶颈await 高 = IO 延迟大ping ip
telnet ip port
# 或
nc -vz ip port
ss -lntp
# 或
netstat -lntp
ip route
cat /etc/resolv.conf
tcpdump -i eth0 port 80
systemctl status nginx
journalctl -u nginx -n 100
ps aux | grep nginx
kill -9 PID
tail -f /var/log/messages
tail -f /var/log/syslog
tail -f /var/log/secure
/var/log/nginx/error.log/var/log/mysql/error.logjournalctl| 故障现象 | 首选命令 |
|---|---|
| SSH 连不上 | ss -lntp, iptables -L |
| 网站打不开 | curl localhost |
| CPU 飙高 | top, pidstat |
| 内存溢出 | free -h, dmesg |
| 磁盘写满 | df -h, du |
| 服务起不来 | journalctl -u 服务名 |
tasklist
netstat -ano
systeminfo
eventvwr
PowerShell:
Get-Process
Get-Service
Get-EventLog
先看资源,再看网络,查服务,最后看日志
如果你能告诉我:
我可以直接给你针对性的命令清单。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。