记录一次系统异常重启。发现是大概4小时之前重启。
排查日志,寻找线索
限定在过去6小时内查找重启原因:
-
检查过去6小时内的内核日志:
journalctl --since="6 hours ago" | grep -i "kernel|panic|oom|killed|crash|error"
-
查看重启前的最后日志:
journalctl -b -1 -n 200
-
查看过去6小时的硬件错误:
journalctl --since="6 hours ago" | grep -i "hardware|error|fail|temp|therm|overheat"
-
检查电源相关问题:
journalctl --since="6 hours ago" | grep -i "power|voltage|current|ups"
-
检查看门狗触发记录:
journalctl --since="6 hours ago" | grep -i "watchdog"
-
检查过去6小时的系统服务错误:
journalctl --since="6 hours ago" -p err..emerg
-
检查资源耗尽情况:
journalctl --since="6 hours ago" | grep -i "memory|cpu|load|out of"
-
检查任何可能的计划重启:
journalctl --since="6 hours ago" | grep -i "reboot|restart|shutdown"
-
查看重启前最后的进程活动:
journalctl -b -1 -n 50 | grep -i "process"
-
检查安全相关日志:
journalctl --since="6 hours ago" | grep -i "authentication|security|attack|intrusion"
发现看门狗日志非常可疑
排查日志,发现只有看门狗日志时间对的上
(base) kent@kent-Super-Server:~$ journalctl --since="6 hours ago" | grep -i "watchdog"
3月 24 06:21:25 kent-Super-Server kernel: watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [nvitop:723587]
3月 24 06:28:20 kent-Super-Server kernel: NMI watchdog: Enabled. Permanently consumes one hw-PMU counter.
3月 24 06:28:21 kent-Super-Server kernel: bnxt_en 0000:04:00.0 (unnamed net_device) (uninitialized): Device requests max timeout of 100 seconds, may trigger hung task watchdog
3月 24 06:28:21 kent-Super-Server kernel: bnxt_en 0000:04:00.1 (unnamed net_device) (uninitialized): Device requests max timeout of 100 seconds, may trigger hung task watchdog
3月 24 06:29:50 kent-Super-Server rtkit-daemon[33496]: Watchdog thread running.
(base) kent@kent-Super-Server:~$ journalctl --since="24 hours ago" | grep -i "watchdog"
3月 24 06:21:25 kent-Super-Server kernel: watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [nvitop:723587]
3月 24 06:28:20 kent-Super-Server kernel: NMI watchdog: Enabled. Permanently consumes one hw-PMU counter.
3月 24 06:28:21 kent-Super-Server kernel: bnxt_en 0000:04:00.0 (unnamed net_device) (uninitialized): Device requests max timeout of 100 seconds, may trigger hung task watchdog
3月 24 06:28:21 kent-Super-Server kernel: bnxt_en 0000:04:00.1 (unnamed net_device) (uninitialized): Device requests max timeout of 100 seconds, may trigger hung task watchdog
3月 24 06:29:50 kent-Super-Server rtkit-daemon[33496]: Watchdog thread running.
(base) kent@kent-Super-Server:~$ journalctl --since="240 hours ago" | grep -i "watchdog"
3月 24 06:21:25 kent-Super-Server kernel: watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [nvitop:723587]
3月 24 06:28:20 kent-Super-Server kernel: NMI watchdog: Enabled. Permanently consumes one hw-PMU counter.
3月 24 06:28:21 kent-Super-Server kernel: bnxt_en 0000:04:00.0 (unnamed net_device) (uninitialized): Device requests max timeout of 100 seconds, may trigger hung task watchdog
3月 24 06:28:21 kent-Super-Server kernel: bnxt_en 0000:04:00.1 (unnamed net_device) (uninitialized): Device requests max timeout of 100 seconds, may trigger hung task watchdog
3月 24 06:29:50 kent-Super-Server rtkit-daemon[33496]: Watchdog thread running.
(base) kent@kent-Super-Server:~$
原因分析
这条日志确实可能解释了系统重启的原因:
3月 24 06:21:25 kent-Super-Server kernel: watchdog: BUG: soft lockup - CPU#1 stuck for 26s! [nvitop:723587]
这条信息表明系统在3月24日6:21:25检测到一个"软锁死"(soft lockup)问题。具体来说:
- CPU#1被卡住了26秒没有响应
- 问题与一个名为
nvitop
的进程有关,进程ID是723587 - 这个nvitop通常是用于监控NVIDIA GPU的工具
Linux内核有一个看门狗(watchdog)机制,当它检测到某个CPU核心长时间不响应时,会记录类似上面的错误。这种软锁死可能表明:
- 在nvitop程序运行时,CPU#1陷入了长时间的卡顿状态
- 如果锁死情况持续或恶化,系统可能会触发自动重启机制
值得注意的是:
- 这个错误发生在6:21:25,而您之前的日志显示系统在5:44左右有最后记录
- 这可能意味着:
- 系统在5:44后出现严重问题但没有记录日志
- 6:21:25的日志是重启后新的一轮启动过程中的记录
建议进一步操作:
-
检查nvitop程序的使用情况:
ps aux | grep nvitop
-
查看完整的锁死上下文:
journalctl --since="12 hours ago" -u kernel
-
检查与NVIDIA GPU相关的日志:
journalctl --since="12 hours ago" | grep -i "nvidia"
-
如果这种软锁死问题经常发生,可能需要:
- 更新NVIDIA驱动
- 检查是否有过热问题
- 调整nvitop的使用方式
- 考虑增加系统的sysctl参数来控制软锁死行为
软锁死通常不会立即导致系统重启,但持续的软锁死可能引发更严重的问题,最终触发看门狗计时器或内核崩溃导致重启。