非正常关机
当 Unraid 检测到 array 没有在系统断电前正确停止时,就会出现不干净关机。这种情况可能会在下次启动时触发自动 parity check 以确保数据完整性。
采取一些主动的步骤可以帮助你避免或识别非正常关机:
- **使用不间断电源(UPS):**确保服务器连接到UPS并设置在电 池电量不足时自动关闭。
- **尝试优雅关闭:**如果您的服务器无响应,短按电源按钮以触发安全关闭。不要长按该按钮,因为这将强制硬关机并导致不洁关机。
- 启用持久日志记录:前往设置 → 系统日志服务器以激活在重新启动后持久存在的日志记录。详细信息请参阅持久日志 (系统日志服务器)。
- 附加诊断信息以获得支持: 如果发生非正常关机,Unraid 将尝试将诊断信息保存到您的闪存设备的
/log/diagnostics.zip
中。当您寻求帮助时,请将此文件附加到论坛帖子中。
导致非正常关机的事件
了解导致不洁关机的主要触发因素有助于您防止此类事件发生。探索下方选项卡以获取每种情况的详细信息。
- “意外的电源损失”
- “闪存驱动器故障”
- 打开终端会话
Power interruptions are one of the main reasons for unclean shutdowns. Protect your system with a properly configured UPS that can automatically shut down Unraid before the battery runs out.
Unraid 支持大多数使用 apcupsd 协议 协议的 UPS 单元(APC 和 CyberPower 通常兼容)。如果您的 UPS 不受支持,建议使用来自社区应用程序的网络 UPS 工具(NUT)插件。
Unraid waits for all open terminal or SSH sessions to close during shutdown. If these sessions remain active and the shutdown timer expires, a forced shutdown occurs.
The Dynamix Stop Shell plugin can automatically close lingering bash or SSH sessions, helping ensure a graceful shutdown. However, be cautious if there are ongoing write operations to the array.
配置关机超时
Properly configuring shutdown timeouts is essential to ensure your Unraid server can stop all services effectively, preventing unclean shutdowns, particularly during power loss or maintenance. Each component of your system - VMs, Docker containers, and the overall array - has its own timeout setting that can be adjusted.
推荐的超时设置
设置 | 默认值 | 推荐最小值 | 配置位置 |
---|---|---|---|
VM 关机超时 | 60秒 | 300秒(5 分钟) | 设置 → 虚拟机管理 → 虚拟机关机(高级) |
Docker 容器停止超时时间 | 10秒 | 30–60秒 | 设置 → Docker(高级) |
通用关机超时时间 | 90秒 | 3 × VM 超时 + Docker 超时 + 15–30秒 | 设置 → 磁盘设置 → 关机超时 |
虚拟机超时时间
点击展开/折叠
“Docker 容器超时时间”
点击展开/折叠
在虚拟机之后,Unraid 停止所有正在运行的 Docker 容器。容器停止超时控制 Unraid 等待每个容器干净退出的时间。
设置位置
- 设置 → Docker (启用高级视图)
考虑
- 容器是并行停止的。
- 复杂容器,或具有大型数据库的容器,可能需要超过默认的 10 秒时间进行安全关闭。
- 如果定时器到期,容器将被强制停止。
最佳做法
如果运行需要额外关闭时间的 Docker 容器,请将超时增加到 30–60 秒。通用关机计时器
点击展开/折叠
The overall Shutdown time-out is the maximum time Unraid allows for all shutdown processes - VMs, Docker, and disk operations - before forcing a shutdown.
设置位置
- 设置 → 磁盘设置 → 关机超时
如何计算
加上 虚拟机 和 Docker 超时时间,然后加上 15–30 秒用于磁盘卸载和其他进程。
- 示例:
3 × ***虚拟机关机超时*** + ***Docker 停止超时*** + 15–30 秒
最佳实践
设置这个计时器高于您最慢的关机场景,尤其当您有许多驱动器或大型 array 时。UPS电池寿命
点击展开/折叠
您的 UPS 必须提供足够的运行时间,以允许所有关闭计时器在服务器失去电力前到期。
设置位置
- 设置 → UPS 设置 (查看 剩余运行时间,所有磁盘旋转起来)
考虑
- UPS 应该在关机序列完成前触发关闭。
- 如果电池在关闭完成之前耗尽,您将面临不完全关闭和可能的数据丢失的风险。
最佳做法
通过模拟断电来测试您的 UPS,并确认 Unraid 可以在时间充裕的情况下干净关闭。