没弄 NAS,家里之前买的都去吃灰去了,主要是没有公网 IP,也无法稳定获取,运营商也可能随时回收,到时候还要 FRP 之类的搞内网穿透,还不知道能不能 P2P 打洞成功,还有什么 V6 之类的,目前在国内的环境下,弄来弄去还是放弃了这个方案
让我再相信一次公有云吧
打算把所有个人核心数据迁移到 Seafile 了,这里当然不是指什么那些大文件之类的热门公共资源,个人数据撑死 1 TiB,成本尚可接受,还有一定冗余灾备,分布式,还可以套娃 Alist 自身也映射为一个 S3 (不过只支持有限的基本操作)

这里暂时没弄那么多,主要是把腾讯云对象存储 COS 同可用区走内网接入免部分流量费,还有个赛博活佛的 R2、开源方案本地自建对象存储 MinIO

请输入图片描述

稍微踩了下坑,环境如下

  • Seafile:Seafile Pro v12.0.11 非 Docker部署
  • MinIO:RELEASE.2025-04-22T22-12-26Z
  • Ubuntu 22.04.5 LTS

我的 Seafile 顶层目录路径: /home/seafile/seafile
具体配置 /home/seafile/seafile/conf/seafile_storage_classes.jsonmemcached 自行先安装好

[
{
"storage_id": "tencentcloudcos_GZ",
"name": "腾讯云COS-广州",
"is_default": false,
"commits": {"backend": "s3", "bucket": "gz01-114514", "host": "cos.ap-guangzhou.myqcloud.comm", "path_style_request":false,  "use_v4_signature": true, "key_id": "114514","key": "1919810"},
"fs": {"backend": "s3", "bucket": "gz02-114514", "host": "cos.ap-guangzhou.myqcloud.com", "path_style_request":false, "use_v4_signature": true, "key_id": "114514", "key": "1919810"},
"blocks": {"backend": "s3", "bucket": "gz03-114514", "host": "cos.ap-guangzhou.myqcloud.com", "path_style_request":false, "use_v4_signature": true, "key_id": "114514", "key": "1919810"}
},


{
"storage_id": "local_storage",
"name": "本地存储",
"is_default": true,
"fs": {"backend": "fs", "dir": "/home/seafile/seafile/seafile-data"},
"commits": {"backend": "fs", "dir": "/home/seafile/seafile/seafile-data"},
"blocks": {"backend": "fs", "dir": "/home/seafile/seafile/seafile-data"}
},

{
"storage_id": "minio_storage",
"name": "MinIO-洛杉矶 MultaCom 机房",
"is_default": false,
"commits": {"backend": "s3", "bucket": "minio-01", "host": "minio.example.com", "aws_region":"us-LosLA-01", "path_style_request":true, "use_https": true, "use_v4_signature": true, "key_id": "114514", "key": "1919810"},
"fs": {"backend": "s3", "bucket": "minio-02", "host": "minio.example.com", "aws_region":"us-LosLA-01", "path_style_request":true, "use_https": true, "use_v4_signature": true, "key_id": "114514", "key": "1919810"},
"blocks": {"backend": "s3", "bucket": "minio-03", "host": "minio.example.com", "aws_region":"us-LosLA-01", "path_style_request":true, "use_https": true, "use_v4_signature": true, "key_id": "114514", "key": "1919810"}
},

{
"storage_id": "cloudflare_r2",
"name": "Cloudflare R2 APAC",
"is_default": false,
"commits": {"backend": "s3", "bucket": "sf-commits", "host": "example.r2.cloudflarestorage.com", 
"aws_region":"apac", "path_style_request":true, "use_https": true, "use_v4_signature": true, "key_id": 
"114514", "key": "1919810"},
"fs": {"backend": "s3", "bucket": "sf-fs", "host": "example.r2.cloudflarestorage.com", 
"aws_region":"apac", "path_style_request":true, "use_https": true, "use_v4_signature": true, "key_id": 
"114514", "key": "1919810"},
"blocks": {"backend": "s3", "bucket": "sf-blocks", "host": "example.r2.cloudflarestorage.com", 
"aws_region":"apac", "path_style_request":true, "use_https": true, "use_v4_signature": true, "key_id": 
"114514", "key": "1919810"}
}
]

并在 seafile.conf 文件开启多存储后端配置

 [storage]
enable_storage_classes = true
storage_classes_file = /home/seafile/seafile/conf/seafile_storage_classes.json

[memcached]
memcached_options = --SERVER=127.0.0.1:11211 --POOL-MIN=10 --POOL-MAX=100

另外,国内服务器直连 Cloudflare R2 回传数据时 ,还需要优化一下这些参数,不然文件上传极易失败,修改 seafile.conf 文件,修改 [fileserver] 配置项,对其追加/修改这些参数

[fileserver]
max_indexing_threads = 1
fixed_block_size=100

可能还是国内直连国外吧,如果 max_indexing_threads 参数改大经常会失败,比如 10
存储后端还需配置存储策略,修改 seahub_settings.py 文件,追加

# 存储后端
ENABLE_STORAGE_CLASSES = True
STORAGE_CLASS_MAPPING_POLICY = 'USER_SELECT'

这里策略为用户手动选择,可以在新建资料库时选择已有策略,更多策略、高级自定义详见官网文档

最后重启一次 seafile 相关服务

  • 遇到的一些问题

    • 小坑 1 :腾讯云 COS 自 2024-01-01 创建的 存储桶不再支持 path_style 域名,仅支持使用 virtual-hosted-style 域名,之前创建的存储桶依然可以使用 path_style 域名不会报错,但是按新的来 virtual-hosted-style 使用,万能兼容,所以这里需要改为 "path_style_request":false,如果使用不支持 path_style 域名的存储桶,上传完进度会卡在 保存文件中,fileserver.log 日志输出

      [2025-05-06 23:35:28] [ERROR] path /upload-aj/069984e0-c076-450e-bb15-25564654dbdf internal server error: failed to index blocks: failed to write chunk: failed to write block: The bucket you are attempting to access must be addressed using COS virtual-styled domain.

    • 小坑 2:对于 MinIO 对象存储,需要配置填写 aws_region 字段,可以在 MinIO 的控制台 Configuration → Region 查看,仅配置 host 不够, host 在英文官网的文档描述为 <s3 api endpoint host>:<port>,如果使用了反向代理位于 WebServer 后面,如使用 Nginx 统一管理对外暴露端口、配置 SSL 证书之类的,只需填写域名,也无需指定协议和端口
      示例: MinIO API 后端运行在 http://127.0.0.1:1145,Nginx 反向代理之后对外暴露 API 地址为:https://minio-api.example.comhost填写 minio-api.example.com就行了
    • 小坑 3:R2 以此类推,不用管 cf 控制面板显示的 S3 API 完整地址格式 协议 + 域名 + 端口 + 路径,如 https://example.r2.cloudflarestorage.com/sf-fshost 字段直接仅填写域名部分 example.r2.cloudflarestorage.com, aws_region 可到 CF R2 控制面板查看: 点击某个具体 bucket → settings → General → Location: Asia-Pacific (APAC),括号里面的大写字母形式就是你的 aws_region 字段的值

再重启下服务,我这里是非 docker 部署,直接 systemctl restart seafile && systemctl restart seahub,最后进行测试
如果异常就去 logs 目录下检查 seafile.log、fileserver.log、seahub.log 日志
我没开启资料库加密,简单看了下数据存储形式,以 R2 为例,直接原始数据原样存到了 sf-blocks 存储桶下面去了,只是做了重命名去后缀而已,下载后改名就能恢复原样了,如果上传的单文件大小大于 seafile.conf 配置文件定义的分片存储大小 fixed_block_size,则会被分割,不会原样存到 R2 存储桶

没在服务端、用户端配置代理,用户端、服务器裸连 R2 上传,发现不是用户端直传到 CF R2 存储桶,而是先到服务端,服务端再传到 R2,所以上传速度随便跑满我这 50 Mbps 上行小水管,当上传进度显示为 保存中,说明服务端正在把数据回传到你选的存储后端,可以服务端监控出口流量就知道了,可能后期可以优化下,给服务端配置代理和规则分流,对国外方向的流量出口进行代理,加速提升国内服务器到 Cloudflare R2 连接稳定性
不过这样好像有点尴尬?带宽瓶颈就卡在了 seafile 部署的服务器了,没法 存储桶直传 / 302 直链下载,可能是还有什么没配置,或者尚不支持,因为数据没加密,可以自己给各种存储后端绑定自定义域名,然后自己去它的存储桶里面找原始数据,通过自定义域名绕过 seafile 直接下载

请输入图片描述

最后修改:2025 年 05 月 12 日
如果觉得我的文章对你有用,请随意赞赏