跳到主要内容

缓存池

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%% 都支持在后期添加设备以创建镜像池。关于文件系统选择和兼容性的更多信息,请参见 文件系统

单设备模式简单明了。您可以轻松添加或移除设备,但不会有冗余或扩展等高级功能选项。

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

  • 数据保护:在进行硬件更改或升级之前保护您的重要文件。
  • 防止意外丢失:减少重新格式化或替换设备时丢失数据的风险。
  • 轻松恢复:确保在维护后您能快速恢复应用程序和虚拟机数据。
important

此过程将停止所有 Docker 容器和虚拟机,因此请确保计划一些停机时间,并在必要时通知用户。有关管理 Docker 容器的更多信息,请参见管理和定制容器

备份您的 cache pool

  1. 停止所有运行的Docker容器和虚拟机:这是顺利备份过程的关键。
  2. 禁用虚拟机:
    • 进入 设置 → 虚拟机管理器
    • 关闭虚拟机,点击 应用
  3. 禁用Docker:
    • 进入 设置 → Docker
    • 关闭Docker并点击 应用
  4. 设定共享存储与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操作 设置为 缓存 → 阵列
  5. 检查 array 上的空间: 确保有足够的可用空间来存储您的文件。
  6. 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.
  7. 验证您的池是空的:Mover 完成后,检查 cache pool 中是否没有剩余的文件。
备注

请记住,直接位于池设备上的文件(不属于任何共享)必须手动移动。

将文件恢复到缓存池

完成维护或更换设备后,可以按以下步骤将文件从 array 恢复到 cache pool

  1. 设定共享存储和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
  2. 检查池上的空间: 确保 cache pool 上有足够的可用空间。
  3. 将文件移回池: 转到页面,然后单击立即移动,将文件传输回 cache pool
  4. 验证池中的内容: 移动完成后,请检查您的 cache pool 是否包含预期的文件以及 array 上的共享是否为空。
  5. 重新启用Docker:进入 设置 → Docker 并重新启用Docker,然后点击 应用
  6. 重新启用虚拟机:进入 设置 → 虚拟机管理器 并重新启用虚拟机,然后点击 应用
  7. 重启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 未格式化为 BTRFSZFS,请按照以下简单步骤操作:

  1. 备份您的数据: 首先,确保您备份所有重要内容。(请参见备份缓存池到阵列
  2. 停止 array 确保停止 array 以开始转换过程。
  3. 更改文件系统:在 主页面 点击池,选择BTRFSZFS作为文件系统格式。
  4. 启动 array 更改格式后,启动 array
  5. 格式化池: 池将显示为不可挂载,并提供格式化选项。确认并单击格式化按钮。
  6. 完成格式化: 格式化完成后,您将获得一个 BTRFSZFS 池,但此时它只有一个设备。
  7. 如果需要添加其他磁盘:您可以为池添加更多磁盘。
  8. 恢复您的数据:最后,按照备份步骤将您的数据移回到池中。

向多设备池中添加磁盘

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

为冗余添加更多磁盘:

  1. 停止 array 同样,首先停止当前 array
  2. 分配额外的磁盘:在 主页面,您可以分配一个或多个新设备到池中。
  3. 启动 array 一旦分配了驱动器,请重新启动 array
  4. 自动平衡/重银化: Unraid 将自动将新设备并入池,并启动一个 平衡BTRFS)或 重银化ZFS)以在设备间分配和保护数据。
  5. 监控进度: 标签中,单击第一个池设备,然后检查 平衡状态(对于 BTRFS)或 zpool 状态(对于 ZFS)以跟踪进度并确认新设备已成功添加。
  6. 池已进入多设备模式:一旦平衡完成,您的池将以多设备模式运行,拥有增强的容量和冗余。
提示

您可以使用 BTRFS磁盘使用计算器 估算根据您选择的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.

向池中添加磁盘的方法:

  1. 停止 array 开始时,停止当前 array 以确保流程顺利进行。
  2. 打开主选项卡: 在 WebGUI 中转到选项卡。您将在此管理您的磁盘。
  3. 找到池设备部分: 向下滚动直到您看到 池设备 部分。您可以在这里更改磁盘设置。
  4. 调整插槽数量:插槽设置为您添加的额外设备的确切数量。不能留有多余的空插槽;阵列不会在未使用的池插槽下启动。
  5. 分配设备:选择要添加到池的设备(磁盘)并将其分配到可用插槽中。
  6. 启动 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.

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

要通过 WebGUI 删除磁盘:

  1. 停止 array:前往 选项卡,找到停止 array 的选项。
  2. 取消分配池驱动器:在 选项卡中找到要移除的驱动器并取消分配。
  3. 启动 array:重启 array 以应用更改。
  4. 验证移除:点击 选项卡中的第一个池设备,然后查看 均衡状态(对此使用 BTRFS)或 zpool 状态(对此使用 ZFS),以确认设备已被正确移除。
Timing

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

改变池的 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可承受 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. 在普通模式下启动 array 如果它尚未运行。
  2. 点击池名称 选项卡上。
  3. 滚动到均衡状态:查看当前的 RAID 等级,适用于数据和元数据。
  4. 选择新的 RAID 配置:从预定义配置的下拉菜单中选择。
  5. 启动平衡操作:点击 均衡 开始转换。

将%%RAID 1|raid1%%转换为单个配置文件

示例:将RAID 1转换为单个配置文件

  1. 监控进度:平衡操作可能需要几小时到几天,取决于池中的数据量、驱动器速度和所选 RAID 等级的复杂性。
故障排除平衡操作如被卡住 - 点击展开/折叠

如果平衡操作似乎卡住或无响应,请遵循以下步骤:

  1. 检查日志:转到 工具 → 日志 并过滤 btrfs 条目。
  2. 停止并重新启动操作
    • 点击 取消均衡
    • 重启 array
    • 再次启动均衡操作。
  3. 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.
  4. 检查可用空间:确保池上至少有 10-15% 的可用空间。
  5. 发布诊断: 如果问题仍然存在,请在Unraid 论坛上分享日志。有关捕获诊断的指导,请参见捕获诊断和日志

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


在池中更换磁盘

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

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. Stop the array: Go to the Main tab, find the Array Operation section, and click the Stop button. This will safely halt the array to prepare for disk replacement.
  2. (可选)移除旧磁盘: 如果您没有热插拔功能的设置,您需要物理断开旧磁盘。请小心操作,以免造成损坏。
  3. 安装替换磁盘: 将新磁盘插入您的系统。确保它正确连接和固定。
  4. 刷新 WebGUI:返回到 选项卡并刷新页面,以便系统检测您的新磁盘。
  5. 分配新磁盘:一旦检测到,在旧磁盘所在的池插槽中找到并将新磁盘分配到该插槽。
  6. 启动 array:点击 启动 按钮,开始将新磁盘集成到 array 中的过程。
  7. 监控重建: 系统将自动开始将数据重构到新磁盘。您可以在 WebGUI 中查看进度。
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.

Example

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

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

原理

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

媒体共享的楼层设置为 20GB,这对于该共享中的文件来说是合适的。然而,如果您还使用池来运行虚拟机并希望为 vdisk 生长时留出缓冲区,您可以将池楼层设置为 50GB。这样,任何媒体共享的传输在池中空闲少于 50GB 时,将直接进入阵列。

Best 实践

将最小空闲空间设置为您预期的最大文件大小,最好是该大小的两倍。例如,如果您的最大文件为 30 GB,则将最小空闲空间设置为 60 GB。

注意

不要将最小空闲空间设置为 0。 这可能会导致磁盘填满错误。始终使用合理的数值。


在池和数组之间移动文件

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. Unraid provides a built-in tool called Mover to automate this process for user shares.

提示

在使用 Mover 移动文件之前始终禁用 Docker 和虚拟机服务。这可以防止在传输过程中跳过打开的文件。

Common 用例

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

将文件从池移动到 array

  1. 禁用 Docker 和 VM 服务: 前往设置并关闭 Docker 和 VM 管理器以防止任何文件被打开,这样 Mover 就可以顺利传输所有文件。
  2. 设置共享存储和 Mover 操作(缓存 → 阵列):共享标签中,对于每个要移动的共享(如appdatasystem),将主存储设置为源 cache pool,并将次存储设置为 array。 设置Mover 操作缓存 → 阵列
  3. 运行 Mover: 转到选项卡,然后单击立即移动将文件从 cache pool 转移到array
  4. 验证移动: 在 Mover 完成后,点击选项卡中缓存条目的文件夹图标,检查文件是否已经被移动。
  5. 重新启用 Docker 和 VM 服务: 当所有文件都在array上后,可以安全地重新开启这些服务。
为什么文件有时会到达错误的池或缓存? - 点击展开/折叠

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 文件系统
  • 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 工具或通过命令行实现。

Remember

如果文件属于 Docker 容器和/或%VM|vm%%,则必须禁用这些服务才能让文件成功移动。

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

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

警告

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.