Unraid 缓存盘相关疑问

340 天前
 tediorelee

接上周的提问 /t/943120 ,已经在周末把 unraid 安装好并且各种 docker 虚拟机也都迁移完成了,目前使用下来的体验感觉还是不错,不过对于 unraid 的缓存盘还有一点疑问

目前 NAS 上除开机械硬盘还有两个 SSD ,一个 256G 作为虚拟机的数据盘,一个 128G 打算作为缓存盘,这两个都是以前电脑升级换下来的 SSD ,在我把共享目录的“Use cache pool”设置设置为 Yes 的时候,遇到了不少的问题,求一个正确使用缓存盘的姿势

3424 次点击
所在节点    NAS
12 条回复
justNoBody
340 天前
我没记错的话 unraid 的缓存盘是一个定时任务,每隔多久执行一次同步到存储盘,所以你做数据迁移反而不应该开启缓存盘?
tediorelee
340 天前
@justNoBody 看上去是应该这样,目前我是直接关掉了缓存
mrzx
340 天前
首先你要明白一个概念

缓存里分读和写。

读缓存需要 2 块 ssd 才行,
写缓存最低要 1 块 ssd (但是数据极度不安全)

此外,ssd 缓存当然越大越好,128G 太小了,最少 256G 起步。搞 2 个容量一致的 ssd 做缓存盘省心。。

模式调成 Prefer ,就可以了,它保存了一部分常用数据在 ssd 里用于常规读取,然后缓存满了,应该会自动写入到机械硬盘阵列里。。你这种现象不应该的。。

而且一次性拷贝的数据量超过缓存盘的最大空间,就会变成蜗牛速度,很正常的,所以缓存盘要越大越好吗。。
现在固态这么便宜,不搞 2 块 512G 的 ssd 弄弄?


缓存最大的目的是提高小文件的写入读取速度。。如果你常存照片类的,搞缓存意义很大。
对于大文件来说,意义不大,但是也可以设置缓存,这样做没有对错之分。。只是意义大不大的问题。。
BugCry
340 天前
Specify whether new files and directories written on the share can be written onto the Cache disk/pool if present. This setting also affects mover behavior.

No prohibits new files and subdirectories from being written onto the Cache disk/pool. Mover will take no action so any existing files for this share that are on the cache are left there.

Yes indicates that all new files and subdirectories should be written to the Cache disk/pool, provided enough free space exists on the Cache disk/pool. If there is insufficient space on the Cache disk/pool, then new files and directories are created on the array. When the mover is invoked, files and subdirectories are transferred off the Cache disk/pool and onto the array.

Only indicates that all new files and subdirectories must be written to the Cache disk/pool. If there is insufficient free space on the Cache disk/pool, create operations will fail with out of space status. Mover will take no action so any existing files for this share that are on the array are left there.

Prefer indicates that all new files and subdirectories should be written to the Cache disk/pool, provided enough free space exists on the Cache disk/pool. If there is insufficient space on the Cache disk/pool, then new files and directories are created on the array. When the mover is invoked, files and subdirectories are transferred off the array and onto the Cache disk/pool.

NOTE: Mover will never move any files that are currently in use. This means if you want to move files associated with system services such as Docker or VMs then you need to disable these services while mover is running.


总的来说,除非你需要数据一直保持在缓存盘上不回写机械盘,可以选 Yes ,其他场景建议选 Prefer
theohateonion
340 天前
如果有大量的数据写入需求,unraid 的缓存盘不够大的话其实就已经失去作用了。
建议是 system ,docker 相关的,缓存策略一直选仅缓存,放在 ssd 上速度能快一点,同时小文件写入也不会频繁唤醒 HDD 。
其余的看情况,我主要的需求是存照片,所以我一般是 Yes ,写入到缓存 SSD ,然后定时 mover 放到 HDD 里面。
optional
340 天前
缓存盘你应该当成“系统盘”用,arrays 长期休眠,需要常驻的文件放缓存盘( doctor 虚拟机)。
还有的就是写入的文件照片什么的,暂存一下。
richardhan
340 天前
unraid 的缓存机制并不是 CPU cache 那种原理。

设为 only 的时候是“数据只会放在缓存盘,不写入 array”,也就是类似以前 PC 上 ssd+hdd 时代,那块 ssd 的作用;

剩下俩模式是针对 HDD array 的随机读写性能差而设计的( unraid 本质上是单盘读写):
设为 yes 的时候是“写入数据”的时候,数据会先被写到 cache 里面,然后 mover 定期往 array 里面搬运,这个一般是各种定时备份文件夹(经常有少量零碎文件写入需求,但是读取需求很少);
设为 prefer 是 mover 会把经常访问的数据定期从 array 复制到 cache 里面,但是写入是直写 array 的,这个一般是各种工作文件夹(比如训练模型的数据集),单次写入但后面会频繁随机读取;

电影这种大型连续文件,不存在 hdd 的随机读写问题,过大的尺寸又容易直接塞爆 cache ,所以推荐不设缓存。

——————————————————————————————————————
6.12 以后,unraid 修改了缓存机制,改成了 primary 和 secondary ,并且由用户自行选择 mover 方向,其实就是把上述选项剥离成了三个部分,提高了用户自定义的空间
HashV2
340 天前
unraid 的缓存盘机制有些特殊,你可以看一下这个视频

https://www.bilibili.com/video/BV1kB4y1c7ES/
tediorelee
340 天前
@mrzx
@theohateonion
@optional
@richardhan
感谢大佬回复,现在基本懂了,准备下单 SSD 去~
zeze0556
340 天前
unraid 的 shfs 效率很低的。对于大量数据的写入,如果最后还是要往 array 中的话,不如命令行直接放到 /mnt/user0 中,比直接写入 /mnt/user 的效率要高, /mnt/user 中是合并了 /mnt/cache 和 /mnt/user0 的内容,/mnt/user0 仅仅合并了 array 的内容,对于频繁的打开和读写而言,/mnt/user 的效率是最低的。/mnt/cache 的效率是最高的。一般使用场景下,先写入 /mnt/cache ,然后 unraid 会定时移动到 array 中。docker 的镜像目录建议放到 /mnt/cache 中并提前分配和大小。数据库之类频繁读写的建议直接 /mnt/cache 中,然后定时备份到 array 中。即使模式设置为 Prefer ,从 /mnt/user 中对文件操作的效率也不高。
mrzx
338 天前
@zeze0556 你是不是说的是 sshfs?
zeze0556
336 天前
@mrzx 不是 sshfs, unraid 用于合并文件系统的那个名字叫 shfs,类似 mergerfs ,但感觉不如 mergerfs 效率高

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/944117

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX