V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tediorelee
V2EX  ›  NAS

Unraid 缓存盘相关疑问

  •  
  •   tediorelee · 330 天前 · 3388 次点击
    这是一个创建于 330 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    • 因为只有 128G ,如果我还在进行文件的拷贝移动操作,会被很快写满,导致一些虚拟机会报错"readonly file system"
    • 假定我配置的共享 SMB 文件夹为 Files ,在我给它设置 cache pool 为 yes 的时候,貌似 appdata/domains/system/isos 这几个系统自带的目录也被自动设置上了缓存,这个操作是正常的吗?
    • 因为更换了 NAS 系统,在我 unraid 安装好之后,我把之前 NAS 上备份的数据重新拷贝回去,为了避免一次性数据量太大我是分开好几次拷贝回去,每次几百 G 左右,这个时候会很快写满缓存盘,导致后续的拷贝直接报错提示没有剩余空间
    • 接上条如果我把缓存更换成比如 1T 或者 2T 的 SSD 这个情况会不会得到解决?大家的缓存盘一般都是多大的呢
    • 查资料发现有个说法是说 Unraid 下,存放电影电视等大文件数据的目录不应该设置缓存,类似配置文件 /相片等等零散的小文件则可以把缓存设置为 yes ,这个说法是否正确?
    • 缓存配置里的 Prefer 和 Only 是应用在哪些场景呢?

    img

    12 条回复    2023-06-03 14:46:21 +08:00
    justNoBody
        1
    justNoBody  
       330 天前
    我没记错的话 unraid 的缓存盘是一个定时任务,每隔多久执行一次同步到存储盘,所以你做数据迁移反而不应该开启缓存盘?
    tediorelee
        2
    tediorelee  
    OP
       330 天前
    @justNoBody 看上去是应该这样,目前我是直接关掉了缓存
    mrzx
        3
    mrzx  
       330 天前
    首先你要明白一个概念

    缓存里分读和写。

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

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

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

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


    缓存最大的目的是提高小文件的写入读取速度。。如果你常存照片类的,搞缓存意义很大。
    对于大文件来说,意义不大,但是也可以设置缓存,这样做没有对错之分。。只是意义大不大的问题。。
    BugCry
        4
    BugCry  
       330 天前
    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
        5
    theohateonion  
       330 天前
    如果有大量的数据写入需求,unraid 的缓存盘不够大的话其实就已经失去作用了。
    建议是 system ,docker 相关的,缓存策略一直选仅缓存,放在 ssd 上速度能快一点,同时小文件写入也不会频繁唤醒 HDD 。
    其余的看情况,我主要的需求是存照片,所以我一般是 Yes ,写入到缓存 SSD ,然后定时 mover 放到 HDD 里面。
    optional
        6
    optional  
       330 天前 via iPhone
    缓存盘你应该当成“系统盘”用,arrays 长期休眠,需要常驻的文件放缓存盘( doctor 虚拟机)。
    还有的就是写入的文件照片什么的,暂存一下。
    richardhan
        7
    richardhan  
       330 天前
    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
        8
    HashV2  
       330 天前
    unraid 的缓存盘机制有些特殊,你可以看一下这个视频

    https://www.bilibili.com/video/BV1kB4y1c7ES/
    tediorelee
        9
    tediorelee  
    OP
       330 天前
    @mrzx
    @theohateonion
    @optional
    @richardhan
    感谢大佬回复,现在基本懂了,准备下单 SSD 去~
    zeze0556
        10
    zeze0556  
       330 天前   ❤️ 1
    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
        11
    mrzx  
       328 天前
    @zeze0556 你是不是说的是 sshfs?
    zeze0556
        12
    zeze0556  
       326 天前
    @mrzx 不是 sshfs, unraid 用于合并文件系统的那个名字叫 shfs,类似 mergerfs ,但感觉不如 mergerfs 效率高
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1017 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:18 · PVG 04:18 · LAX 13:18 · JFK 16:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.