蓝光高清网

标题: 群晖 利用 Docker 运行 SnapRAID 的详细记录 [打印本页]

作者: Synology    时间: 2021-3-1 13:32
标题: 群晖 利用 Docker 运行 SnapRAID 的详细记录
开始之前

于 DSM 6.1.7 系统测试通过
最优方式应该是原生程序运行,期待未来会有人编译做出 spk 安装包我是弄不来了。
SnapRAID 这软件我也是刚刚开始使用,据说适合存有大量大文件并很少改动的家庭媒体中心。

详细优缺点,自行搜索了解




SnapRAID 是什么

SnapRAID 是一个目录级别的冗余存储方案,它与 RAID 的原理有相似的地方,但它并不是 RAID。SnapRAID 与 RAID 的主要区别有:
SnapRAID 相比 RAID 的优点主要有:
摘录自:目录级别的冗余存储:SnapRAID( https://wzyboy.im/post/1186.html )
               使用经验可以参考博文,非常受用



安装

使用这个 Docker 镜像: https://hub.docker.com/r/xagaba/snapraid
Docker 注册表里边搜索 snapriad ,选择 xagaba/snapraid 项目



 (  )



1)需要配置一个 /config 目录存放 snapraid.confsnapraid-runner.conf 两个配置文件

 (  )



2)需要保护的目录挂载到 /mnt
3)按挂载的路径配置好 snapraid.conf 文件, snapraid-runner.conf 按需改动,我默认配置了校验完成后进行数据擦洗同时开启了 log。
4)环境变量 PUID ,PGID 用 SSH 登陆机器,输入 id 命令可以得知。应该都是统一的数字,跟图片设置就行
      这个设置事关文件读写权限,配置好减少隐患与后续可能的麻烦

 (  )



使用

软件需要使用 docker exec 参数传递命令来操作
sync 命令建立校验数据,视乎硬盘数据量所需的时间可能要数小时


复制代码

 (  )



常用的 SnapRAID 命令:
  • snapraid sync:根据数据盘生成校验盘;
  • snapraid diff:查看有哪些数据需要 sync;
  • snapraid status:查看磁盘阵列的状态;
  • snapraid scrub:进行数据擦洗,提早发现磁盘阵列中的错误。

        SnapRAID 首次同步完成之后,可以将 snapraid syncsnapraid scrub 加入 cron / systemd timer,定时运行。后者默认配置下每次运行擦洗全部数据的 8%,并且会挑选最近 10 天内没有被擦洗过的数据进行擦洗。如果每天运行一次 snapraid scrub 的话,每 12.5 天所有数据都会被擦洗一遍,形成一个健康的循环。
        当擦洗发现有数据损坏,或是更糟糕地,某天整块磁盘挂了(不转了),就需要修复数据了。这时候应该做的是停掉所有的定时任务,然后换上新的磁盘,然后用 snapraid fix -d name_of_disk 命令,根据健在磁盘的内容,在新磁盘里重建坏掉磁盘里的内容。只要坏掉的磁盘数量小于等于校验盘的数量,SnapRAID 都能完整地修复数据。
由于 snapraid sync 是定期执行的,这意味着在下次同步之前,磁盘阵列是有机会恢复到上次同步的状态的,因此 snapraid fix 除了可以重建整个磁盘,也可以重建单个文件,也就是反删除。如果你误删除了文件,可以用 snapraid fix -f path/to/file 来恢复文件到上次同步时的状态。
摘录自:https://wzyboy.im/post/1186.html
官方使用手册:https://www.snapraid.it/manual





计划任务

1)Docker 自带的 corntab 计划任务,默认每天
北京时间 08:30 定时运行(容器是 UTC 时间)      想更灵活的自定时间可以用

复制代码


      命令把容器的 corntab 计划删了,改用群晖自带的任务计划

手动运行的效果
  • fejich@PVE-DSM:~$ sudo docker exec SnapRAID /usr/bin/python /app/snapraid-runner/snapraid-runner.py -c /config/snapraid-runner.conf
  • 2019-08-05 00:51:03,168 [INFO  ] ============================================================
  • 2019-08-05 00:51:03,169 [INFO  ] Run started
  • 2019-08-05 00:51:03,169 [INFO  ] ============================================================
  • 2019-08-05 00:51:03,169 [INFO  ] Running diff...
  • 2019-08-05 00:51:03,175 [OUTPUT] Loading state from /config/snapraid.content...
  • 2019-08-05 00:51:03,175 [OUTPUT] Comparing...
  • 2019-08-05 00:51:03,176 [OUTPUT] add F06中孔铁油缸-4.0s.PDF.pdf
  • 2019-08-05 00:51:03,176 [OUTERR] WARNING! UUID is unsupported for disks: 'mnt1', 'mnt2', 'mnt3'. Noons.
  • 2019-08-05 00:51:03,176 [OUTPUT]
  • 2019-08-05 00:51:03,177 [OUTPUT] 14 equal
  • 2019-08-05 00:51:03,177 [OUTPUT] 1 added
  • 2019-08-05 00:51:03,177 [OUTPUT] 0 removed
  • 2019-08-05 00:51:03,178 [OUTPUT] 0 updated
  • 2019-08-05 00:51:03,178 [OUTPUT] 0 moved
  • 2019-08-05 00:51:03,178 [OUTPUT] 0 copied
  • 2019-08-05 00:51:03,178 [OUTPUT] 0 restored
  • 2019-08-05 00:51:03,178 [OUTPUT] There are differences!
  • 2019-08-05 00:51:03,479 [INFO  ] ************************************************************
  • 2019-08-05 00:51:03,479 [INFO  ] Diff results: 1 added,  0 removed,  0 moved,  0 modified
  • 2019-08-05 00:51:03,480 [INFO  ] Running sync...
  • 2019-08-05 00:51:03,482 [OUTPUT] Self test...
  • 2019-08-05 00:51:03,858 [OUTPUT] Loading state from /config/snapraid.content...
  • 2019-08-05 00:51:03,859 [OUTPUT] Scanning disk mnt1...
  • 2019-08-05 00:51:03,859 [OUTPUT] Scanning disk mnt2...
  • 2019-08-05 00:51:03,860 [OUTPUT] Scanning disk mnt3...
  • 2019-08-05 00:51:03,860 [OUTPUT] Using 0 MiB of memory for the file-system.
  • 2019-08-05 00:51:03,860 [OUTERR] WARNING! UUID is unsupported for disks: 'mnt1', 'mnt2', 'mnt3'. Noons.
  • 2019-08-05 00:51:05,860 [OUTPUT] Initializing...
  • 2019-08-05 00:51:05,860 [OUTPUT] Resizing...
  • 2019-08-05 00:51:05,860 [OUTPUT] Saving state to /config/snapraid.content...
  • 2019-08-05 00:51:05,860 [OUTPUT] Saving state to /mnt1/snapraid.content...
  • 2019-08-05 00:51:05,870 [OUTPUT] Verifying /config/snapraid.content...
  • 2019-08-05 00:51:05,870 [OUTPUT] Verifying /mnt1/snapraid.content...
  • 2019-08-05 00:51:05,871 [OUTPUT] Syncing...
  • 2019-08-05 00:51:06,093 [OUTPUT] Using 32 MiB of memory for 32 cached blocks.
  • 2019-08-05 00:51:06,095 [OUTPUT] 100% completed, 1 MB accessed in 0:00
  • 2019-08-05 00:51:06,102 [OUTPUT]
  • 2019-08-05 00:51:06,102 [OUTPUT] mnt1  0% |
  • 2019-08-05 00:51:06,102 [OUTPUT] mnt2  0% |
  • 2019-08-05 00:51:06,103 [OUTPUT] mnt3  0% |
  • 2019-08-05 00:51:06,103 [OUTPUT] parity  0% |
  • 2019-08-05 00:51:06,103 [OUTPUT] raid 28% | *****************
  • 2019-08-05 00:51:06,103 [OUTPUT] hash  9% | *****
  • 2019-08-05 00:51:06,103 [OUTPUT] sched 60% | *************************************
  • 2019-08-05 00:51:06,103 [OUTPUT] misc  0% |
  • 2019-08-05 00:51:06,104 [OUTPUT] |______________________________________________________________
  • 2019-08-05 00:51:06,104 [OUTPUT] wait time (total, less is better)
  • 2019-08-05 00:51:06,104 [OUTPUT]
  • 2019-08-05 00:51:06,104 [OUTPUT] Everything OK
  • 2019-08-05 00:51:06,108 [OUTPUT] Saving state to /config/snapraid.content...
  • 2019-08-05 00:51:06,109 [OUTPUT] Saving state to /mnt1/snapraid.content...
  • 2019-08-05 00:51:06,111 [OUTPUT] Verifying /config/snapraid.content...
  • 2019-08-05 00:51:06,111 [OUTPUT] Verifying /mnt1/snapraid.content...
  • 2019-08-05 00:51:06,413 [INFO  ] ************************************************************
  • 2019-08-05 00:51:06,413 [INFO  ] All done
  • 2019-08-05 00:51:06,430 [ERROR ] Failed to send email because smtp host is not set
  • 2019-08-05 00:51:06,430 [INFO  ] Run finished successfully

复制代码



2)群晖计划任务

 (  )




复制代码






欢迎光临 蓝光高清网 (https://www.4kii.com/) Powered by Discuz! X3.4