缓存池
In Unraid, a cache pool is a collection of one or more drives, typically SSDs or high-speed HDDs. These drives temporarily store data before it's moved to your main array. Using cache pools can significantly enhance write speeds, protect your data, and provide dedicated storage for specific tasks like running Docker containers or virtual machines.
Cache pools offer several advantages, making them a valuable addition to your Unraid setup, such as:
-
Faster write speeds: Cache pools allow you to quickly write data to faster drives before it gets transferred to the main array. This greatly enhances perceived performance when saving files.
-
Data protection for cached files: By using multiple drives in a cache pool (like setting them up in RAID 1), you add redundancy. This means your cached data is protected from drive failure before it even reaches the main array.
-
为应用程序优化存储: 将 Docker 容器或 虚拟机 存储在 cache pool 上可以提高其性能,减少对主 array 的磨损,并最大限度地缩短访问频繁使用文件的时间。
-
Flexible and dedicated storage: With multiple cache pools, you can assign specific pools for different tasks. For instance, you could have one pool dedicated to downloads and another for virtual machines, reducing competition for resources and boosting efficiency.
- 多个池: 您可以创建并命名不同的 cache pool,以便根据您的具体需要进行调整。
- SSD 与 HDD: SSD 适合于速度,而 HDD 可用于大型顺序数据处理。此外,HDD 可以延长 SSD 的使用寿命。
- Redundancy matters: To protect your data, use more than one drive in a cache pool. A single drive pool won't protect you from potential drive failure.
- File system choice: The default file system for cache pools is BTRFS, which supports various RAID options for added redundancy and flexibility. For more details on file system selection, see File systems.
- Mover integration: Data written to a cache pool is automatically transferred to your main array based on a schedule you set. This keeps your user shares organized and easy to manage.
- 应用程序性能: 通过将 Docker 容器、应用程序数据和 VM 磁盘放在 cache pool 上,您可以提升访问速度,并最大限度地减少对主存储的压力。
池模式
Unraid cache pools can operate in two main modes: single device mode and multi-device mode. Knowing the difference between these modes will help you find the right balance between performance, flexibility, and data protection for your needs.
- 单设备模式
- 多设备模式
在 单设备模式 中,您的 %%cache pool|缓存池%% 仅由一个设备组成。这意味着:
单设备模式很简单。您可以轻松添加或移除设备,但将无法使用诸如冗余或扩展等高级功能。
When you set up a cache pool with more than one device, it enters multi-device mode. Here's what you should know:
cache pool 的常见任务包括:
- 将您的池备份到 array
- 在单设备和多设备模式间切换
- 向池中添加磁盘
- 更换池中的磁盘
将缓存池备份到阵列
Backing up your cache pool to the main array is a crucial step before making any upgrades, reformatting, or replacing your cache devices. This process ensures that important data - like Docker containers, app data, and virtual machine files - are securely stored on the main array, minimizing the risk during maintenance.
为什么要备份您的 cache pool?
- 数据保护:在进行硬件更改或升级之前保护您的重要文件。
- 防止意外丢失:减少重新格式化或替换设备时丢失数据的风险。
- 轻松恢复:确保在维护后您能快速恢复应用程序和
虚拟机数据。
此过程将停止所有 Docker 容器和虚拟机,因此请确保计划一些停机时间,并在必要时通知用户。有关管 理 Docker 容器的更多信息,请参见 管理和自定义容器。
备份您的 cache pool:
- 停止所有运行的Docker容器和
虚拟机:这是顺利备份过程的关键。 - 禁用
虚拟机:- 进入 设置 → 虚拟机管理器。
- 关闭
虚拟机,点击 应用。
- 禁用Docker:
- 进入 设置 → Docker。
- 关闭Docker并点击 应用。
- 设定共享存储与Mover操作 (缓存 → 阵列):
- 转到Shares 选项卡。
- For each user share you want to move, set Primary storage to the source cache pool and Secondary storage to the array.
- 将 Mover操作 设置为 缓存 → 阵列。
- 检查 array 上的空间: 确保有足够的可用空间来存储您的文件。
- Move files to the array: From the Main page, click Move Now. This transfers files from the cache pool to the array based on the Mover action.
- 验证您的池是空的: 在 Mover 完成后,检查 cache pool 中是否没有剩余的文件。
请记住,直接位于池设备上的文件(不属于任何共享)必须手动移动。
将 文件恢复到缓存池
完成维护或更换设备后,可以按以下步骤将文件从 array 恢复到 cache pool:
- 设定共享存储和Mover操作 (阵列 → 缓存):
- 转到Shares 选项卡。
- For each user share you want to restore, set Primary storage to the destination cache pool and Secondary storage to the array.
- 将 Mover 动作 设置为 array → cache。
- 检查池上的空间: 确保 cache pool 上有足够的可用空间。
- 将文件移回池: 转到主页面,然后单击立即移动,将文件传输回 cache pool。
- 验证池中的内容: 移动完成后,请检查您的 cache pool 是否包含预期的文件以及 array 上的共享是否为空。
- 重新启用Docker:进入 设置 → Docker 并重新启用Docker,然后点击 应用。
- 重新启用
虚拟机:进入 设置 → 虚拟机管理器 并重新启用虚拟机,然后点击 应用。 - 重启Docker容器和
虚拟机:最后,启动您希望再次运行的Docker容器或者虚拟机。
切换到多设备模式
Cache pools in Unraid can be expanded from a single device to multiple devices, allowing for increased capacity and redundancy. To take advantage of multi-device mode, your pool must be formatted as BTRFS or ZFS.
将池转换为 BTRFS 或 ZFS
如果您的 cache pool 未格式化为 BTRFS 或 ZFS,请按照以下简单步骤操作:
- 备份您的数据:首先,请确保备份任何重要内容。 (请参见 将缓存池备份到阵列)
- 停止 array: 确保停止 array 以开始转换过程。
- 更改文件系统:在 主页面 点击池,选择
BTRFS或ZFS作为文件系统格式。 - 启动 array: 更改格式后,启动 array。
- 格式化池:池将显示为无法挂载并提供格式化选项。确认并点击格式化按钮。
- 完成格式化: 格式化完成后,您将获得一个 BTRFS 或 ZFS 池,但此时它只有一个设备。
- 如果需要添加其他磁盘:您可以为池添加更多磁盘。
- 恢复您的数据:最后,按照备份步骤将您的数据移回到池中。
向多设备池中添加磁盘
一旦您的池格式化为 BTRFS 或 ZFS,您可以添加更多驱动器以增加冗余和扩展存储。
为冗余添加更多磁盘:
- 停止 array: 同样,首先停止当前 array。
- 分配额外的磁盘:在 主页面,您可以分配一个或多个新设备到池中。
- 启动 array: 一旦分配了驱动器,请重新启动 array。
- 自动平衡/重银化: Unraid 将自动将新设备并入池,并启动一个 平衡(BTRFS)或 重银化(ZFS)以在设备间分配和保护数据。
- 监控进度: 在 主 标签中,单击第一个池设备,然后检查 平衡状态(对于 BTRFS)或 zpool 状态(对于 ZFS)以跟踪进度并确认新设备已成功添加。
- 池已进入多设备模式:一旦平衡完成,您的池将以多设备模式运行,拥有增强的容量和冗余。
您可以使用 BTRFS磁盘使用计算器 估算根据您选择的RAID级别和设备尺寸的可用空间与冗余。
向池中添加磁盘
随着您的存储需求增长,您可能希望通过添加额外的硬盘来扩展您的缓存池。此过程使您能够在提高容量和性能的同时,通过 RAID 配置保持数据保护。
If you want to add disks to your pool, just make sure your pool is already formatted as BTRFS or ZFS. If it's not, you'll need to format it first, as explained in the previous section.
向池中添加磁盘的方法:
- 停止 array: 开始时,停止当前 array 以确保流程顺利进行。
- 打开主页签:转到 WebGUI 的主页签。这里是您管理磁盘的地方。
- 找到池设备部分:向下滚动直到看到池设备部分。这是您可以更改磁盘设置的地方。
- 调整槽位数量:将槽位设置为您正在添加的额外设备的确切数量。不能留有多余的空槽;阵列无法在未使用的池槽位启动。
- 分配设备:选择要添加到池的设备(磁盘)并将其分配到可用插槽中。
- 启动 array: 设备分配后,请返回启动 array 以启用这些更改。
从池中移除磁盘
Removing a disk from a BTRFS or ZFS multi-device cache pool can help you reclaim hardware, replace a failing drive, or reconfigure your storage. This process is only possible if your pool is set up for redundancy (like RAID 1 for both data and metadata) and the remaining devices have enough space to hold all of your data.
- 通过 WebGUI
- 使用命令行(高级)
要通过 WebGUI 删除磁盘:
- 停止 array:前往 主 选项卡,找到停止 array 的选项。
- 取消分配池驱动器:在 主 选项卡中找到要移除的驱动器并取消分配。
- 启动 array:重启 array 以应用更改。
- 验证移除:点击 主 选项卡中的第一个池设备,然后查看 均衡状态(对此使用 BTRFS)或 zpool 状态(对此使用 ZFS),以确认设备已被正确移除。
:::note[Timing]
请记住,根据数据量和设备速度,删除驱动器和重新平衡池可能需要几个小时。
:::
如果您对命令行感到满意,使用此方法可以让您有更多的控制权,并且当 WebGUI 选项不可用时可能非常有用。有关使用命令行接口 的更多信息,请参阅命令行接口。
通过命令行移除磁盘:
-
打开终端会话:确保 array 正在运行,并打开您的命令行接口。
-
移除设备:输入以下命令,将
X替换为要移除的驱动器对应的字母(如主选项卡所示):btrfs device remove /dev/sdX1 /mnt/cache- 对于加密设备,使用:
/dev/mapper/sdX1。 - 对于 NVMe 设备,使用:
nvmeXn1p1。
- 对于加密设备,使用:
-
等待完成:当您看到光标返回时,设备将被移除。
-
让 Unraid "遗忘" 已删除的成员:
移除多个设备:
您可以在一个命令中进行:
btrfs device remove /dev/sdX1 /dev/sdY1 /mnt/cache
不过,请记住移除仍然是一个一个进行的。
:::note[Timing]
与 WebGUI 方法相似,移除设备和再平衡可能需要几个小时,取决于数据量和设备速度。
:::
如果在池中只剩下一个设备,您将需要将 RAID 配置文件转换为 单个 以确保一切正常工作。有关进一步说明,请参考将池RAID级别切换为单个部分。
改变池的 RAID 级别
BTRFS provides the ability to change RAID levels for cache pools dynamically, allowing you to adjust settings without stopping the array or losing any data. This flexibility lets you optimize for performance, redundancy, or storage efficiency as your requirements change.
支持的 RAID 级别
| RAID 级别 | 数据保护 | 空间效率 | 使用场景 |
|---|---|---|---|
| 单个 | 无 | 100% | 用于临时存储或不需要冗余的非关键数据。 |
| RAID 0 | 无 | 100% | 最大化性能和容量,但不建议用于关键数据。 |
| RAID 1|raid1 | 可承受 1 个磁盘故障 | 50% | Unraid 池的默认值。非常适合 Docker/VM 存储和关键数据。 |
| RAID 10 | 可承受 1 个磁盘故障 | 50% | 结合了RAID 0的速度和RAID 1的冗余以满足高性能需求。 |
| RAID 5* | 可承受 1 个磁盘故障 | 67-94% | 实验性。 适用于大规模媒体存储的容量和冗余的平衡。 |
| RAID 6* | 可承受 2 个磁盘故障 | 50-88% | 实验性。 为大容量硬盘提供额外的归档存储保护。 |
更改池的 RAID 级别:
- 在普通模式下启动 array 如果它尚未运行。
- 点击池名称 在 主 选项卡上。
- 滚动到均衡状态:查看当前的 RAID 等级,适用于数据和元数据。
- 选择新的 RAID 配置:从预定义配置的下拉菜单中选择。
- 启动平衡操作:点击 均衡 开始转换。
示例:从RAID 1转换到单一配置文件
- 监控进度:平衡操作可能需要几小时到几天,取决于池中的数据量、驱动器速度和所选 RAID 等级的复杂性。
如果平衡操作卡住,进行故障排除 - 点击以展开/折叠
如果平衡操作似乎卡住或没有响应,请按照这些步骤进行:
- 检查日志:转到 工具 → 日志 并过滤
btrfs条目。 - 停止并重新启动操作:
- 点击 取消均衡。
- 重启 array。
- 再次启动均衡操作。
- Verify disk health: Run SMART tests on all devices in the pool. For more information on disk health monitoring, see SMART reports and disk health.
- 检查可用空间:确保池上至少有 10-15% 的可用空间。
- 发布诊断信息:如果问题持续, 请在 Unraid 论坛上共享日志。有关捕获诊断信息的指南,请参见 捕获诊断和日志。
有关高级 BTRFS 配置的详细信息,请参阅 BTRFS wiki。
在池中更换磁盘
在 cache pool 中更换磁盘是一项重要任务,有助于保持存储系统的性能和可靠性。
:::note[Prerequisites]