linux系统服务器中常见故障及排查方法

🍁博主简介
        🏅云计算领域优质创作者
        🏅2022年CSDN新星计划python赛道第一名

        🏅2022年CSDN原力计划优质作者
        🏅阿里云ACE认证高级工程师
        🏅阿里云开发者社区专家博主

💊交流社区CSDN云计算交流社区欢迎您的加入!

目录

故障1:系统无响应

故障2:网络连接问题

故障3:文件系统错误

故障4:软件包依赖问题

故障5:用户权限问题

故障6:服务无法正常工作

故障7:磁盘空间不足

故障8:内存不足

故障9:服务端口被占用

故障10:防火墙和安全组问题


故障1:系统无响应

  • 可能原因:资源耗尽、进程冲突、硬件故障等。

  • 排查方法:

  • 使用tophtopfree -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 -h
              total        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:网络连接问题

  • 可能原因:网络配置错误、防火墙设置、网络设备故障等。

  • 排查方法:

  • 使用pingtraceroute命令检查网络连接。

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/下的文件)。

  • 检查防火墙设置(如iptablesfirewalld)。

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:软件包依赖问题

  • 可能原因:依赖关系不完整、版本不匹配等。

  • 排查方法:

  • 使用包管理器(如aptyumdnf)检查依赖关系。

  • 解决方法:

    • 更新软件包或安装缺失的依赖包。

    • 手动调整软件包依赖关系。

故障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 server
   Loaded: 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 ago
 Main PID: 955 (sshd)
    Tasks: 1
   Memory: 928.0K
      CPU: 112ms
   CGroup: /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 -m
              total        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:防火墙和安全组问题

  • 排查方法:

  • 检查防火墙规则和安全组设置。

  • 解决方法:

    • 调整防火墙规则或安全组设置以允许必要的通信。

请注意,以上只是一些常见的故障和排查方法,实际情况可能因系统和环境的不同而有所差异。在排查和解决故障时,应根据具体的错误信息和日志进行分析和处理。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小鹏linux

感谢老板,老板大气

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值