跳到主要内容

缓存池

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:

  1. 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.

  2. 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.

  3. 为应用程序优化存储: 将 Docker 容器或 虚拟机 存储在 cache pool 上可以提高其性能,减少对主 array 的磨损,并最大限度地缩短访问频繁使用文件的时间。

  4. 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.

Keep 铭记在心
  • 多个池: 您可以创建并命名不同的 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|缓存池%% 仅由一个设备组成。这意味着:

  • 没有冗余: 如果设备出现故障,任何尚未传输到您的 array 的数据将会丢失。
  • 文件系统选项: 您可以使用非 BTRFSXFSZFS 的文件系统。
important

如果您在单设备模式下选择非 BTRFS 或非 ZFS 文件系统,并在之后决定向池中添加更多设备,则需要先将设备重新格式化为 BTRFSZFS。因此,BTRFS 是 %%cache pools|缓存池%% 的默认文件系统,即使只使用一个设备时也是如此。%%BTRFS|btrfs%% 和 %%ZFS|zfs%% 都支持随后添加设备以创建镜像池。有关文件系统选择和兼容性的更多信息,请参见文件系统

单设备模式很简单。您可以轻松添加或移除设备,但将无法使用诸如冗余或扩展等高级功能。

多设备模式

When you set up a cache pool with more than one device, it enters multi-device mode. Here's what you should know:

  • 数据保护: 此模式使用 BTRFSZFS 来跨设备镜像数据,帮助保护您的缓存数据免受驱动器故障的影响。即使丢失一个设备,您也不会丢失任何数据。
  • 混合搭配:您可以添加或移除不同尺寸和类型的设备,包括混合使用SSD和HDD。
  • 容量管理: 使用 BTRFS 磁盘使用计算器 来估算基于 RAID 级别和您使用的设备大小将有多少空间。对于 ZFS 池,请使用 ZFS 存储指南 获取配置详细信息。

cache pool 的常见任务包括:


向多设备池中添加磁盘

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

If your cache pool isn't already formatted as BTRFS or ZFS, you can convert it using the following steps.

将池转换为 BTRFS 或 ZFS:

  1. Back up important content. See Moving files between a pool and the array to move files from your pool to the array.
  2. 停止array
  3. 选项卡中,单击池并选择BTRFSZFS作为文件系统格式。
  4. 启动 array
  5. 当池显示为无法挂载时,确认并点击格式化
  6. 格式化后,您将拥有一个BTRFSZFS池(此时为单设备)。
  7. (可选)根据需要添加额外驱动。
  8. 通过将文件移回池来恢复数据。

向多设备池中添加磁盘

一旦您的池格式化为 BTRFSZFS,您可以添加更多驱动器以增加冗余和扩展存储。

随着您的存储需求增长,您可能希望通过添加额外的硬盘来扩展您的缓存池。此过程使您能够在提高容量和性能的同时,通过 RAID 配置保持数据保护。

  1. 停止array
  2. 选项卡中,为您的池分配一个或多个新设备。
  3. 启动 array
  4. Unraid 自动整合新设备并启动一个平衡BTRFS)或重新排列ZFS)。
  5. 选项卡中,单击第一个池设备并检查平衡状态BTRFS)或zpool 状态ZFS)以跟踪进度。
  6. 完成后,池将在多设备模式下运行,增加了容量和冗余。
提示

您可以使用 BTRFS磁盘使用计算器 估算根据您选择的RAID级别和设备尺寸的可用空间与冗余。


向池中添加磁盘

随着您的存储需求增长,您可能希望通过添加额外的硬盘来扩展您的缓存池。此过程使您能够在提高容量和性能的同时,通过 RAID 配置保持数据保护。

备注

如果您想向池中添加磁盘,请确保您的池已经格式化为BTRFSZFS。如果没有,您需要首先格式化,如将池转换为 BTRFS 或 ZFS中所述。

向池中添加磁盘的方法:

  1. 停止array
  2. 选项卡中,打开池。
  3. 在池设备部分,将槽位设置为额外设备的确切数量。
  4. 将新设备分配到可用槽位上。
  5. Start the array to enable the changes.

从池中移除磁盘

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

Before 您开始
  • 只能通过GUI一次移除一个驱动器。
  • 确保您的池使用冗余RAID配置(例如,数据和元数据使用RAID 1)。
  • 要检查游泳池的 RAID 级别,请导航到主选项卡并点击游泳池。向下滚动到平衡状态部分(对于 BTRFS) 或 ZFS 池状态(对于 ZFS)。

要通过 WebGUI 删除磁盘:

  1. 停止array:转到选项卡并查找停止你的array的选项。
  2. 取消分配池驱动器:在选项卡中找到要移除的驱动器并取消分配。
  3. 启动array:重新启动array以应用更改。
  4. 验证移除:点击选项卡中的第一个池设备,然后检查平衡状态(适用于BTRFS)或zpool状态(适用于ZFS)以确认设备已正确移除。

:::note[Timing]

请记住,根据数据量和设备速度,删除驱动器和重新平衡池可能需要几个小时。

:::

使用命令行(高级)。

如果您对命令行感到满意,使用此方法可以让您有更多的控制权,并且当 WebGUI 选项不可用时可能非常有用。有关使用命令行接口的更多信息,请参阅命令行接口

Before 您开始
  • 确保您的池的 RAID 配置支持设备移除;在 2 设备的 RAID 1 池中,必须先将其更改为单一配置以便移除设备。
  • 检查剩余设备是否有足够的空间容纳您的数据。

通过命令行移除磁盘:

  1. 确保 array 正在运行,然后打开命令行界面。

  2. 在下面输入命令,用想要移除的驱动器对应的字母替换 X(如主选项卡所示):

    btrfs device remove /dev/sdX1 /mnt/cache
    • 对于加密设备,使用:/dev/mapper/sdX1
    • 对于 NVMe 设备,使用:nvmeXn1p1
  3. 等待完成:当光标返回时,设备将被移除。

  4. 使 Unraid "忘记" 已删除的成员:

    • 停止array
    • 取消分配所有池设备。
    • 启动 array (Unraid 将清除池配置)。
    • 如果任何 Docker/VM 服务使用此池,请在启动 array 之前禁用它们,以防 Unraid 在其他地方重新创建映像。
  5. 再次停止 array,重新分配除已移除设备之外的所有剩余池成员,然后启动 array

移除多个设备

您可以在一个命令中进行:

btrfs device remove /dev/sdX1 /dev/sdY1 /mnt/cache

不过,请记住移除仍然是一个一个进行的。

:::note[Timing]

WebGUI 方法相似,移除设备和再平衡可能需要几个小时,取决于数据量和设备速度。

:::

important

如果在池中只剩下一个设备,您将需要将 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 0100%最大化性能和容量,但不建议用于关键数据。
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%实验性。 为大容量硬盘提供额外的归档存储保护。
important

RAID 5 and RAID 6 are considered experimental in BTRFS. ZFS provides more mature support for these RAID levels. Use with caution and ensure you have backups. Avoid using experimental RAID levels for critical data.

更改池的 RAID 级别:

  1. Start the array in normal mode.
  2. 选项卡中,单击池名称。
  3. 滚动到平衡状态查看当前数据和元数据的RAID级别。
  4. 从下拉列表中选择新的RAID配置文件。
  5. 点击平衡以开始转换。

从%%RAID 1|raid1%%转换到单一配置文件

示例:从RAID 1转换到单一配置文件

  1. WebGUI监控进度。

:::note[Timing]

平衡操作可能需要几个小时到几天,具体取决于池中的数据量、驱动器速度以及所选RAID级别的复杂性。

:::

如果平衡操作卡住,进行故障排除 - 点击以展开/折叠

如果平衡操作似乎卡住或没有响应,请按照这些步骤进行:

  1. 工具 → 日志中过滤 btrfs 条目。
  2. 停止并恢复操作:
    • 点击 取消均衡
    • 重启 array
    • 再次启动均衡操作。
  3. 在池中所有设备上运行SMART测试。有关磁盘健康监测的更多信息,请参阅SMART 报告和磁盘健康
  4. 确保池上有至少 10-15% 的可用空间。
  5. 如果问题仍然存在,在 Unraid 论坛上分享日志。有关捕获诊断信息的指南,请参阅捕获诊断和日志

有关高级 BTRFS 配置的详细信息,请参阅 BTRFS wiki


缓存池的最低空闲空间

cache pool 中更换磁盘是一项重要任务,有助于保持存储系统的性能和可靠性。

:::note[Prerequisites]

  • Check your pool configuration: Make sure your pool is set up with a redundant RAID profile, like RAID 1. You can do this by going to Main → Pool → Balance Status (for BTRFS) or ZFS pool status (for ZFS) in your management interface.
  • **选择合适的替换磁盘:**新磁盘的大小必须与您要替换的磁盘相同或更大。
  • **热插拔能力:**如果您的硬件支持热插拔,您不需要关闭系统电源来更换磁盘。

:::

您可以通过点击 选项卡中的池名称并转到 个人池设置 来访问最低空闲空间。

  1. In the Main tab, stop the array (Array Operation → Stop).
  2. (可选)如果您没有热插拔,物理移除旧磁盘。
  3. 安装替换磁盘并确保连接正常。
  4. 刷新选项卡以检测新磁盘。
  5. 将新磁盘分配到之前的槽位。
  6. 启动 array
  7. WebGUI中监控重建进度。

:::important[Timing]

根据磁盘大小和系统当前负载情况,重建可能需要一些时间。例如,在 RAID 1 设置中重建一个 4TB 的 SSD 可能需要大约 3-6 小时。建议在可以让系统不受干扰的情况下进行计划。

:::


缓存池的最低空闲空间

Setting a minimum free space for your cache pool can provide better control over file placement, especially when dealing with large files like high-resolution videos. This setting helps Unraid know when to stop writing to the pool and start writing directly to the larger storage array, avoiding interruptions or data corruption.

:::tip[Example]

如果您常常下载大约 10GB 的文件,则将最低空闲空间设置为至少 10GB,最好是 20GB 以便调整。

:::

您可以通过点击 选项卡中的池名称并转到 个人池设置 来访问最低空闲空间。

原理

  • 当您将文件传输到包含池的共享时,Unraid 将遵循遇到的第一个最低空闲空间设置 (无论是共享的最低空闲空间还是池的最低空闲空间,哪个先达到) 。
  • 最低可用空间设置告诉 Unraid,当可用空间降到此数量以下时,将停止使用 cache pool
  • 如果您的共享使用 cache pool 作为主存储,文件会进入池,直到达到最低可用空间,然后直接发送到 array
  • 如果设置为仅使用 cache pool(没有次存储),则不应用此设置。
  • 如果设置为仅使用 array 作为 主存储,则文件将直接写入 array
Use case example

媒体共享将地板设置为 20GB,这对于该共享中的文件来说是合适的。但是,如果您还在池中使用 VM 并希望留有缓冲空间以防虚拟磁盘增长,则可以将池地板设置为 50GB。这样,在池的空余空间少于 50GB 之后,对媒体共享的任何传输将直接转到阵列。

Best 实践

将最小可用空间设置为您期望的最大文件大小,最好是该大小的两倍。例如,如果您的最大文件是 30 GB,要将最小可用空间设置为 60 GB。

注意

When accessing a user share from multiple pools and array disks, Unraid merges the directory listings in this order:


在池和数组之间移动文件

There are times when you may need to move files between your cache pool and the main array, such as when preparing for maintenance, upgrading hardware, or optimizing performance. This process is also useful for backing up your cache pool before making configuration changes or replacing drives. Unraid provides a built-in tool called Mover to automate this process for user shares.

提示

在使用 Mover 移动文件之前,务必禁用 Docker 和 VM 服务。这可以防止在传输过程中跳过打开的文件。

从池移动到阵列

Common 用例

在执行维护或升级之前,从 cache pool 移动文件到 array 确保您的数据安全。

将文件从池移动到 array

  1. 进入设置并关闭 Docker 和 VM 管理器。这样可以防止任何文件被打开,允许 Mover 顺利转移所有内容。
  2. 共享标签中,对于要移动的每个共享(如 appdatasystem),将主存储设置为源 cache pool,将次级存储设置为 array。将Mover 操作设置为缓存 → 阵列
  3. 进入标签并点击立即移动以将文件从 cache pool 转移到 array
  4. Mover 完成后,点击主标签中缓存条目旁边的文件夹图标检查文件是否已移动。
  5. 一旦所有文件都位于 array 上,您就可以安全地重新打开 Docker 和 VM 服务。

从阵列移动到池

Common 用例

在维护后或添加新的缓存设备以提高性能时将文件移回cache pool

要从 array 移动文件到一个存储池:

  1. 进入 设置 并关闭 Docker 和 VM 管理器,以防止任何打开的文件干扰。
  2. 共享 选项卡中,为每个要移动的共享(例如 appdatasystem),将 主存储 设置为目标 cache pool 并将 次存储 设置为 array。将 搬家操作 设置为 阵列 → 缓存
  3. 进入 主页面 选项卡并点击 立即移动,以开始将文件从 array 移动到 cache pool
  4. Mover 完成后,检查文件是否已在 cache pool 上。
  5. 移动完成后,在 设置 中重新开启 Docker 和 VM 管理器。
  6. (可选)要设置共享仅使用 cache pool:如果您希望某个共享的所有文件都保持在 cache pool 上,将 主存储 设置为您的 cache pool ,并将 次存储 设置为
为什么文件有时会出现在错误的池或缓存中? - 点击展开/折叠

When you move files between user shares at the Linux level (for example, using mv or within a Docker container), Linux tries to optimize the operation. If both the source and destination appear on the same mount point (/mnt/user), Linux might rename the file instead of moving it. This can result in files remaining on the original disk or pool, even if the share's "Use cache" setting is set to "No."

为确保文件按预期移动,请考虑以下选项:

  • 使用 Mover 工具。
  • 复制文件然后删除原件。
  • 通过网络移动文件。

这些方法有助于防止文件出现在错误的位置。


多个存储池

Unraid 允许您创建和管理最多 35 个独立的存储池,每个池最多可容纳 60 个设备。多个池为您提供灵活性,可根据需要分配存储、提高性能和定制冗余。每个池可以使用不同的文件系统、RAID 级别和设备类型(SSD、HDD、NVMe 等)。

为何使用多个存储池?

  • 优化性能:VMs、Docker 容器、下载或媒体设置单独的存储池可以提高速度并减少冲突。
  • 保护数据: 为每个存储池分配不同的 RAID 级别或文件系统,以实现定制化的冗余和备份选项。
  • 隔离工作负载: 将关键应用程序放在更快的冗余存储池中,将大容量数据存储在更具成本效益的设备上。
  • 灵活管理: 你可以独立地扩展、减少或格式化存储池而不影响其他池。

常见使用案例

使用场景配置示例好处
高性能 VMsNVMe SSD池,RAID 1BTRFSZFS快速 I/O 与冗余
Docker/Appdata 存储SSD池,RAID 1BTRFSZFS快速访问和数据保护
批量媒体下载Large HDD pool, RAID 0 or single, XFS/BTRFS高容量但冗余较少
项目/团队隔离为每个团队/项目设置单独的存储池减少资源冲突
快照和备份目标ZFS池,RAIDZ1/RAIDZ2(多设备)支持原生快照和备份
Supported File Systems
  • BTRFS: 适合多设备存储池(支持 RAID 0, RAID 1, RAID 10, RAID 5, RAID 6)。
  • ZFS: 非常适合单一设备和多设备池(Unraid 6.12+),支持成熟的 RAIDZ1 和 RAIDZ2。有关高级 ZFS 功能和配置,请参见 ZFS 存储
  • XFS: 适合单设备存储池。

When accessing a user share from multiple pools and array disks, Unraid merges the directory listings in this order:

  1. 分配给共享的存储池
  2. Array 磁盘(disk1、disk2、...、disk28)
  3. 其他存储池(按顺序)

在存储池之间移动文件

Unraid 不允许通过 WebGUI 直接在存储池间移动文件,但可以使用 Mover 工具或通过命令行实现。

:::note[Remember]

如果任何文件属于 Docker 容器和/或 VM ,必须禁用这些服务,以便文件可以成功移动。

:::

使用 Mover

  1. 进入设置并关闭Docker和VM管理器以防止打开文件。
  2. 将文件从池1移到array(缓存 → 阵列):
    • 进入共享选项卡。对于每个当前位于pool1上的共享,将主存储设置为pool1,并将备用存储设置为array
    • Mover操作 设置为 缓存 → 阵列
    • 选项卡中,点击立即移动以运行Mover。等待其完成。
  3. 将文件从array移到池2(阵列 → 缓存):
    • Shares 选项卡中,对于每个共享,设置 Primary storage 为 pool2,Secondary storagearray
    • Mover 动作 设置为 array → cache
    • 选项卡中,再次点击立即移动。文件将从array移动到pool2。
  4. 重新启用Docker和VM服务(如有需要)。

:::note[Timing]

移动大型数据集可能需要数小时,这取决于文件大小和设备速度。

:::

手动文件传输(高级)

  1. 如上所述禁用 Docker 和 VM 服务
  2. 使用 rsyncmv 命令在挂载点之间传输文件(例如,/mnt/pool1/share/mnt/pool2/share)。
  3. 在从原始存储池中删除文件之前,请核实这些文件。
  4. 重新启用 Docker 和 VM 服务。
注意

始终检查文件路径并使用正确的共享名称以防止数据丢失。

警告

If you remove a device from a BTRFS or ZFS pool and move it to a new pool, Unraid will erase all data on it when the array restarts. Always back up important data before changing pool configurations.