目录
故障1:系统无响应
故障2:网络连接问题
故障3:文件系统错误
故障4:软件包依赖问题
故障5:用户权限问题
故障6:服务无法正常工作
故障7:磁盘空间不足
故障8:内存不足
故障9:服务端口被占用
故障10:防火墙和安全组问题
故障1:系统无响应
-
可能原因:资源耗尽、进程冲突、硬件故障等。
-
排查方法:
-
使用
top
、htop
或free -h
命令检查系统资源使用情况
root@fylog001:~# top
top - 11:23:31 up 46 days, 23:38, 1 user, load average: 0.00, 0.01, 0.00
Tasks: 156 total, 1 running, 155 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 16431740 total, 940580 free, 1922844 used, 13568316 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 14119512 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1528 root 10 -10 1153656 24084 2276 S 0.3 0.1 180:53.36 AliDetect 8292 root 10 -10 117128 15572 10396 S 0.3 0.1 150:16.64 AliYunDun 8303 root 10 -10 137980 2304 0 S 0.3 0.0 197:15.24 AliYunDunMonito 8805 root 20 0 5882368 403512 4624 S 0.3 2.5 46:00.51 java
25413 root 20 0 690340 12256 8180 S 0.3 0.1 53:15.80 aliyun-service
31180 root 20 0 2193756 13052 11080 S 0.3 0.1 275:12.95 argusagent 1 root 20 0 184908 4972 3308 S 0.0 0.0 0:27.71 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.31 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:10.57 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root 20 0 0 0 0 S 0.0 0.0 27:04.35 rcu_sched 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root rt 0 0 0 0 S 0.0 0.0 0:00.03 migration/0 10 root rt 0 0 0 0 S 0.0 0.0 0:06.02 watchdog/0 11 root rt 0 0 0 0 S 0.0 0.0 0:04.28 watchdog/1
root@fylog001:~# free -htotal used free shared buff/cache available
Mem: 15G 1.8G 913M 3.7M 12G 13G
Swap: 0B 0B 0B
- 使用
ps
命令检查是否有异常进程
root@fylog001:~# ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 184908 4972 ? Ss Mar25 0:27 /sbin/init
root 2 0.0 0.0 0 0 ? S Mar25 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Mar25 0:10 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< Mar25 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S Mar25 27:04 [rcu_sched]
root 8 0.0 0.0 0 0 ? S Mar25 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S Mar25 0:00 [migration/0]
root 10 0.0 0.0 0 0 ? S Mar25 0:06 [watchdog/0]
root 11 0.0 0.0 0 0 ? S Mar25 0:04 [watchdog/1]
root 12 0.0 0.0 0 0 ? S Mar25 0:00 [migration/1]
root 13 0.0 0.0 0 0 ? S Mar25 0:04 [ksoftirqd/1]
- 检查硬件状态,如内存、硬盘等。
- 解决方法:
-
重启系统或关闭不必要的进程。
-
升级硬件或增加系统资源。
-
故障2:网络连接问题
-
可能原因:网络配置错误、防火墙设置、网络设备故障等。
-
排查方法:
-
使用
ping
、traceroute
命令检查网络连接。
root@fylog001:~# ping www.baidu.com
PING www.a.shifen.com (220.181.38.150) 56(84) bytes of data.
64 bytes from 220.181.38.150: icmp_seq=1 ttl=53 time=7.40 ms
64 bytes from 220.181.38.150: icmp_seq=2 ttl=53 time=7.40 ms
64 bytes from 220.181.38.150: icmp_seq=3 ttl=53 time=7.41 ms
64 bytes from 220.181.38.150: icmp_seq=4 ttl=53 time=7.37 ms
-
检查网络配置文件(如
/etc/network/interfaces
或/etc/sysconfig/network-scripts/
下的文件)。 -
检查防火墙设置(如
iptables
或firewalld
)。
root@fylog001:~# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
root@fylog001:~# systemctl status firewalld.service
-
解决方法:
-
修复网络配置或重启网络服务。
-
调整防火墙规则或重启防火墙服务。
-
故障3:文件系统错误
-
可能原因:磁盘故障、文件系统损坏、不正常关机等。
-
排查方法:
-
使用
fsck
命令检查并修复文件系统
root@fylog001:~# fsck
fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
/dev/vda1 is mounted.
-
检查磁盘状态(如使用
smartctl
)。 -
解决方法:
-
修复文件系统或恢复备份数据。
-
更换损坏的硬盘。
-
故障4:软件包依赖问题
-
可能原因:依赖关系不完整、版本不匹配等。
-
排查方法:
-
使用包管理器(如
apt
、yum
或dnf
)检查依赖关系。 -
解决方法:
-
更新软件包或安装缺失的依赖包。
-
手动调整软件包依赖关系。
-
故障5:用户权限问题
-
可能原因:权限不足。
-
排查方法:
-
使用
ls -l
命令检查文件或目录的权限。
root@fylog001:/etc# ls -l
total 844
-rw-r--r-- 1 root root 3028 Feb 27 2019 adduser.conf
-rw-r--r-- 1 root root 18 Oct 25 2021 adjtime
drwxr-xr-x 2 root root 4096 Oct 25 2021 alternatives
drwxr-xr-x 3 root root 4096 Oct 25 2021 apm
drwxr-xr-x 3 root root 4096 May 10 10:59 apparmor
drwxr-xr-x 8 root root 4096 May 10 10:59 apparmor.d
drwxr-xr-x 7 root root 4096 May 10 11:02 apt
-rw-r----- 1 root daemon 144 Jan 15 2016 at.deny
-rw-r--r-- 1 root root 2188 Sep 1 2015 bash.bashrc
-
解决方法:
-
修改文件或目录的权限(如使用
chmod
命令)。 -
使用具有足够权限的用户执行操作。
-
故障6:服务无法正常工作
-
可能原因:软件配置错误、版本不兼容、资源耗尽等。
-
排查方法:
-
检查服务的配置文件和日志文件。
-
使用
systemctl
命令检查服务状态。
root@fylog001:/etc# systemctl status ssh
● ssh.service - OpenBSD Secure Shell serverLoaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)Active: active (running) since Mon 2024-03-25 11:44:40 CST; 1 months 16 days agoMain PID: 955 (sshd)Tasks: 1Memory: 928.0KCPU: 112msCGroup: /system.slice/ssh.service└─955 /usr/sbin/sshd -D
-
解决方法:
-
修复配置文件或重启服务。
-
升级软件或调整配置以适应环境。
-
故障7:磁盘空间不足
-
排查方法:
-
使用
df -h
命令查看磁盘使用情况。
root@fylog001:/etc# df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.9G 0 7.9G 0% /dev
tmpfs 1.6G 3.8M 1.6G 1% /run
/dev/vda1 394G 15G 363G 4% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
-
解决方法:
-
清理不必要的文件或目录。
-
增加磁盘空间或扩展分区。
-
故障8:内存不足
-
排查方法:
-
使用
free -m
命令查看内存使用情况。
root@fylog001:/etc# free -mtotal used free shared buff/cache available
Mem: 16046 1881 908 3 13256 13783
Swap: 0 0 0
-
解决方法:
-
关闭不必要的进程或服务。
-
升级硬件或增加虚拟内存。
-
故障9:服务端口被占用
-
排查方法:
-
使用
netstat -tuln
命令查看端口占用情况。
root@fylog001:~# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 12199/docker-proxy
tcp 0 0 127.0.0.1:42859 0.0.0.0:* LISTEN 21096/hbrclient
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 8207/redis-server 0
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 955/sshd
-
解决方法:
-
停止占用端口的进程或服务。
-
配置服务使用其他端口。
-
故障10:防火墙和安全组问题
-
排查方法:
-
检查防火墙规则和安全组设置。
-
解决方法:
-
调整防火墙规则或安全组设置以允许必要的通信。
-
请注意,以上只是一些常见的故障和排查方法,实际情况可能因系统和环境的不同而有所差异。在排查和解决故障时,应根据具体的错误信息和日志进行分析和处理。