缓存池
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]
- 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.
- **选择合适的替换磁盘:**新磁盘的大小必须与您要替换的磁盘相同或更大。
- **热插拔能力:**如果您的硬件支持热插拔,您不需要关闭系统电源来更换磁盘。
:::
在池中更换磁盘:
- 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.
- (可选)删除旧磁盘:如果您没有支持热插拔的设置,您将需要物理地断开旧磁盘。确保以免造成任何损坏。
- 安装替换磁盘:将新磁盘插入系统,确保它连接良好并安全。
- 刷新 WebGUI:返回到 主 选项卡并刷新页面,以便系统检测您的新磁盘。
- 分配新磁盘:一旦检测到,在旧磁盘所在的池插槽中找到并将新磁盘分配到该插槽。
- 启动 array:点击 启动 按钮,开始将新磁盘集成到 array 中的过程。
- 监控重建进度:系统将自动开始将 数据重构到新磁盘上。您可以在 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。
媒体共享将地板设置为 20GB,这对于该共享中的文件来说是合适的。但是,如果您还在池中使用 VM 并希望留有缓冲空间以防虚拟磁盘增长,则可以将池地板设置为 50GB。这样,在池的空余空间少于 50GB 之后,对媒体共享的任何传输将直接转到阵列。
将最小可用空间设置为您期望的最大文件大小,最好是该大小的两倍。例如,如果您的最大文件是 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 和 VM 服务。这可以防止在传输过程中跳过打开的文件。
- 池到阵列
- 数组到缓存
在执行维护或升级之前,从 cache pool 移动文件到 array 确保您的数据安全。
将文件从池移动到 array:
- 禁用 Docker 和 VM 服务:转到 设置 并关闭 Docker 和 VM 管理器。这可防止文件被占用,使 Mover 能够顺利传输所有内容。
- 设置共享存储和 Mover 操作(缓存 → 阵列):在 共享 选项卡中,为您想要移动的每个共享(如
appdata或system),将 主存储 设置为源 cache pool,将 次存储 设置为 array。将 Mover 操作 设置为 缓存 → 阵列。 - 运行 Mover: 转到主选项卡,然后单击立即移动将文件从 cache pool 转移到array。
- 验证移动: 在 Mover 完成后,点击主选项卡中缓存条目的文件夹图标,检查文件是否已经被移动。
- 重新启用 Docker 和 VM 服务: 当所有文件都在array上后,可以安全地重新开启这些服务。
在维护后或添加新的缓存设备以提高性能时将文件移回cache pool。
要从 array 移动文件到一个存储池:
- 禁用 Docker 和 VM 服务: 前往设置并关闭 Docker 和 VM 管理器以防止任何打开的文件干扰。
- Set share storage and Mover action (array → cache): In the Shares tab, for each share you want to move (like
appdataorsystem), set Primary storage to the destination cache pool and Secondary storage to the array. Set Mover action to array → cache. - 运行 Mover: 转到主选项卡并点击立即移动开始将文件从array移动到cache pool。
- 验证移动: 在 Mover 完成后,检查文件是否已经移动到cache pool。
- 重新启用 Docker 和 VM 服务: 移动完成后,在设置中重新打开 Docker 和 VM 管理器。
- (可选)将共享设置为仅使用 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 级别或文件系统,以实现定制化的冗余和备份选项。
- 隔离工作负载: 将关键应用程序放在更快的冗余存储池中,将大容量数据存储在更具成本效益的设备上。
- 灵活管理: 你可以独立地扩展、减少或格式化存储池而不影响其他池。
常见使用案例
| 使用场景 | 配置示例 | 好处 |
|---|---|---|
| 高性能 VMs | NVMe SSD池,RAID 1,BTRFS 或 ZFS | 快速 I/O 与冗余 |
| Docker/Appdata 存储 | SSD池,RAID 1,BTRFS 或 ZFS | 快速访问和数据保护 |
| 批量媒体下载 | Large HDD pool, RAID 0 or single, XFS/BTRFS | 高容量但冗余较少 |
| 项目/团队隔离 | 为每个团队/项目设置单独的存储池 | 减少资源冲突 |
| 快照和备份目标 | ZFS池,RAIDZ1/RAIDZ2(多设备) | 支持原生快照和备份 |
When accessing a user share from multiple pools and array disks, Unraid merges the directory listings in this order:
- 分配给共享的存储池
- Array 磁盘(disk1、disk2、...、disk28)
- 其他存储池(按顺序)
在存储池之间移动文件
Unraid 不允许通过 WebGUI 直接在存储池间移动文件,但可以使用 Mover 工具或通过命令行实现。
:::note[Remember]
如果任何文件属于 Docker 容器和/或 VM ,必须禁用这些服务,以便文 件可以成功移动。
:::