我目前运行的是 Ubuntu 21.04 服务器。最近,我在服务器上安装了 VNC。我通过运行 ssh 隧道将 VNC 连接到服务器上ssh -L 5901:localhost:5900 username@ip -i ~/.ssh/privatekey
,然后使用 tigerVNC 连接到本地主机端口 5901。除了 3 个 nodejs 项目外,服务器上没有运行任何密集型项目。
我的问题:结束 VNC 会话 5 小时后,服务器崩溃。运行时last -x
,崩溃时出现以下错误:
tanish tty7 :0 Fri May 14 06:05 - crash (09:41)
tanish tty7 :0 Fri May 14 23:38 - crash (01:08)
mihir tty7 :0 Sat May 15 01:06 - crash (01:17)
tanish pts/0 (My Public IP) Sat May 15 01:05 - crash (01:18)
tanish tty7 :0 Sat May 15 22:39 - crash (05:19)
:0 是我用于 VNC 的显示器,tty7 与 VNC 终端有关。
当我在崩溃前检查 Syslogs 时,我发现 4/5 的崩溃都出现了这种情况,第 4 次崩溃是个例外。
May 14 06:17:01 (myservername) CRON[2046]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
May 14 06:19:53 (myservername) systemd[1]: Starting Cleanup of Temporary Directories...
May 14 06:19:53 (myservername) systemd[1]: systemd-tmpfiles-clean.service: Succeeded.
May 14 06:19:53 (myservername) systemd[1]: Finished Cleanup of Temporary Directories.
May 14 06:25:02 (myservername) CRON[2065]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
May 14 06:26:11 (myservername) NetworkManager[745]: <info> [1620973571.6512] manager: sleep: sleep requested (sleeping: no enabled: yes)
May 14 06:26:11 (myservername) NetworkManager[745]: <info> [1620973571.6516] manager: NetworkManager state is now ASLEEP
May 14 06:26:11 (myservername) ModemManager[776]: <info> [sleep-monitor] system is about to suspend
May 14 06:26:11 (myservername) systemd[1]: Reached target Sleep.
May 14 06:26:11 (myservername) systemd[1]: Starting Suspend...
May 14 06:26:11 (myservername) kernel: [ 1304.854501] PM: suspend entry (s2idle)
May 14 06:26:11 (myservername) systemd-sleep[2068]: Suspending system...
Random @^@^@^s for like 12 lines
May 14 15:47:39 (myservername) kernel: [ 0.000000] Linux version 5.11.0-17-generic (buildd@lcy01-amd64-002) (gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0, GNU ld (GNU Binutils for Ubuntu) 2.36.1) #18-Ubuntu SMP Thu May 6 20:10:11 UTC 2021 (Ubuntu 5.11.0-17.18-generic 5.11.12)
如果有人知道如何解决这个问题适用于 Ubuntu 21.04,我会感激任何帮助。运行的节点项目对时间非常敏感,停机 4 小时意味着客户会生气!提前致谢!
编辑:运行sudo systemd-inhibit
返回:
WHO UID USER PID COMM WHAT WHY MODE
ModemManager 0 root 787 ModemManager sleep ModemManager needs to reset devices delay
NetworkManager 0 root 707 NetworkManager sleep NetworkManager needs to turn off networks delay
UPower 0 root 1310 upowerd sleep Pause device polling delay
Unattended Upgrades Shutdown 0 root 824 unattended-upgr shutdown Stop ongoing upgrades or perform upgrades before shutdown delay
lightdm 113 lightdm 1262 unity-settings- handle-lid-switch Multiple displays attached block
lightdm 113 lightdm 1212 unity-greeter handle-power-key Unity Greeter handling keypresses block
lightdm 113 lightdm 1262 unity-settings- sleep GNOME needs to lock the screen delay
7 inhibitors listed.
这也证实了系统日志显示网络管理器正在关闭服务器。
答案1
从日志中:
tanish tty7 :0 Fri May 14 06:05 - crash (09:41)
读作 06:05 开始时间 + 09:41 运行时间 = 15:46 崩溃时间,考虑到舍入误差,该值与重启时间相匹配:
May 14 06:26:11 (myservername) systemd-sleep[2068]: Suspending system...
Random @^@^@^s for like 12 lines
May 14 15:47:39 (myservername) kernel: [ 0.000000]...
“崩溃”是因为服务器在睡眠期间重新启动。您真正的问题是 20 分钟后进入睡眠状态,这不是崩溃,但看起来像是。
网络管理员只是拖延来自其他东西的关机请求。我怀疑这是由空闲电源管理设置导致的。对于不在键盘旁的用户来说,“空闲”是一个误导性的名称。
如果您无法修复该问题,一种解决方法是在服务器上运行任何需要保持无人值守运行的程序:
systemd-inhibit COMMAND
阻止睡眠和关机请求,直到其完成。