Storj
Storj 正在重新定义云存储,以可持续且经济的方式支持数据的未来发展。Storj 利用全球大量未充分利用的资源,提供更安全、持久和高性能的服务。使用 Storj,你可以体验到成本降低达 90% 以及碳排放减少的优势。
Storj 是一种加密、安全且经济高效的对象存储服务,它允许你以去中心化的方式存储、备份和存档大量数据。
后端选项
Storj 既可以使用其原生后端,也可以结合 使用 Storj S3 兼容网关的 S3 后端(共享或私有)。
使用原生后端,你可以利用客户端加密功能,并获得尽可能好的下载性能。上传的数据将在本地进行纠删编码,因此上传 1GB 的数据将导致约 2.68GB 的数据被上传到网络中的存储节点。
使用 S3 后端和其中一个 S3 兼容的托管网关,可以提高上传性能,并减轻系统和网络的负载。上传的数据将在服务器端进行加密和纠删编码,因此上传 1GB 的数据仅需向网络中的存储节点上传 1GB 的数据。
以下是更详细的对比:
- 特性:
- Storj 后端:使用原生 RPC 协议,直接连接到存储数据的节点。需要更多的 CPU 资源进行编码/解码,并且存在网络放大效应(尤其是在上传过程中),会使用大量的 TCP 连接。
- S3 后端:通过共享网关使用 S3 兼容的 HTTP REST API。不存在网络放大效应,但性能取决于共享网关,并且加密密钥会与网关共享。
- 典型使用场景:
- Storj 后端:适用于有足够资源、网络速度和连接性的服务器环境和桌面设备,以及需要 Storj 客户端加密的应用程序。
- S3 后端:适用于资源、网络速度或连接性有限的桌面设备和类似环境。
- 安全性:
- 带宽使用(上传):
- Storj 后端:高。由于数据在客户端进行纠删编码,原始数据和奇偶校验数据都需要上传。大约需要上传约 2.7 倍的数据。客户端可能会先尝试连接更多的节点(约 3.7 倍),并放弃/停止较慢的上传。
- S3 后端:正常。仅上传原始数据,纠删编码在网关端进行。
- 带宽使用(下载)
- Storj 后端:几乎正常。仅需要最少数量的数据,但为了避免非常慢的数据提供者,会使用更多的数据源,并忽略最慢的数据源(最大开销为 1.2 倍)。
- S3 后端:正常。仅下载原始数据,纠删编码在共享网关端进行。
- CPU 使用:
- Storj 后端:高,但更可预测。纠删编码和加密/解密在本地进行,需要大量的 CPU 资源。
- S3 后端:低。纠删编码和加密/解密在共享的 S3 网关端进行(因此,这取决于网关的当前负载)。
- TCP 连接使用:
- Storj 后端:高。每个 Storj 节点都需要直接连接,每 64MB 数据段上传时会打开 110 个连接,下载时会打开 35 个连接。并非所有连接都会被积极使用(较慢的连接会被清理),但都会被打开。可能需要 调整最大打开文件限制。
- S3 后端:正常。每个下载/上传线程只需要一个连接到共享网关。
- 整体性能:
- Storj 后端:在有足够资源(CPU 和带宽)的情况下,Storj 后端的性能甚至可以提高 2 倍。数据直接从客户端下载/上传,而不是通过网关。
- S3 后端:在 CPU 和网络带宽有限的边缘设备上可能更快,因为共享的 S3 兼容网关负责加密/解密和纠删编码,并且没有下载/上传放大效应。
- 去中心化程度:
- Storj 后端:高。数据直接从分布式存储提供商的云网络中下载。
- S3 后端:低。需要一个运行的 S3 网关(可以是自托管或 Storj 托管)。
- 限制:
- Storj 后端:不下载数据就无法使用
rclone checksum
命令,因为上传时不会计算校验和元数据。 - S3 后端:加密密钥会与网关共享。
- Storj 后端:不下载数据就无法使用
配置
要创建新的 Storj 配置,你需要以下其中一项:
- 他人共享给你的访问授权。
- 你所属的 Storj 项目的 API 密钥。
以下是一个如何创建名为 remote
的远程存储的示例。首先运行:
rclone config
这将引导你完成一个交互式的设置过程:
使用访问授权进行设置
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> remote
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
[snip]
XX / Storj Decentralized Cloud Storage
\ "storj"
[snip]
Storage> storj
** See help for storj backend at: https://rclone.cn/storj/ **
Choose an authentication method.
Enter a string value. Press Enter for the default ("existing").
Choose a number from below, or type in your own value
1 / Use an existing access grant.
\ "existing"
2 / Create a new access grant from satellite address, API key, and passphrase.
\ "new"
provider> existing
Access Grant.
Enter a string value. Press Enter for the default ("").
access_grant> your-access-grant-received-by-someone-else
Remote config
Configuration complete.
Options:
- type: storj
- access_grant: your-access-grant-received-by-someone-else
Keep this "remote" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
使用 API 密钥和口令进行设置
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> remote
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
[snip]
XX / Storj Decentralized Cloud Storage
\ "storj"
[snip]
Storage> storj
** See help for storj backend at: https://rclone.cn/storj/ **
Choose an authentication method.
Enter a string value. Press Enter for the default ("existing").
Choose a number from below, or type in your own value
1 / Use an existing access grant.
\ "existing"
2 / Create a new access grant from satellite address, API key, and passphrase.
\ "new"
provider> new
Satellite Address. Custom satellite address should match the format: `<nodeid>@<address>:<port>`.
Enter a string value. Press Enter for the default ("us1.storj.io").
Choose a number from below, or type in your own value
1 / US1
\ "us1.storj.io"
2 / EU1
\ "eu1.storj.io"
3 / AP1
\ "ap1.storj.io"
satellite_address> 1
API Key.
Enter a string value. Press Enter for the default ("").
api_key> your-api-key-for-your-storj-project
Encryption Passphrase. To access existing objects enter passphrase used for uploading.
Enter a string value. Press Enter for the default ("").
passphrase> your-human-readable-encryption-passphrase
Remote config
Configuration complete.
Options:
- type: storj
- satellite_address: [email protected]:7777
- api_key: your-api-key-for-your-storj-project
- passphrase: your-human-readable-encryption-passphrase
- access_grant: the-access-grant-generated-from-the-api-key-and-passphrase
Keep this "remote" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
标准选项
以下是Storj(Storj去中心化云存储)特有的标准选项。
–storj-provider
选择一种认证方法。
属性:
- 配置项:provider
- 环境变量:RCLONE_STORJ_PROVIDER
- 类型:字符串
- 默认值:“existing”
- 示例:
- “existing”
- 使用现有的访问授权。
- “new”
- 根据卫星地址、API密钥和密码短语创建一个新的访问授权。
- “existing”
–storj-access-grant
访问授权。
属性:
- 配置项:access_grant
- 环境变量:RCLONE_STORJ_ACCESS_GRANT
- 认证方式:existing
- 类型:字符串
- 是否必需:否
–storj-satellite-address
卫星地址。
自定义卫星地址应符合格式:<节点ID>@<地址>:<端口>
。
属性:
- 配置项:satellite_address
- 环境变量:RCLONE_STORJ_SATELLITE_ADDRESS
- 认证方式:new
- 类型:字符串
- 默认值:“us1.storj.io”
- 示例:
- “us1.storj.io”
- 美国1区
- “eu1.storj.io”
- 欧洲1区
- “ap1.storj.io”
- 亚太1区
- “us1.storj.io”
–storj-api-key
API密钥。
属性:
- 配置项:api_key
- 环境变量:RCLONE_STORJ_API_KEY
- 认证方式:new
- 类型:字符串
- 是否必需:否
–storj-passphrase
加密密码短语。
要访问现有对象,请输入上传时使用的密码短语。
属性:
- 配置项:passphrase
- 环境变量:RCLONE_STORJ_PASSPHRASE
- 认证方式:new
- 类型:字符串
- 是否必需:否
高级选项
以下是Storj(Storj去中心化云存储)特有的高级选项。
–storj-description
远程存储的描述。
属性:
- 配置项:description
- 环境变量:RCLONE_STORJ_DESCRIPTION
- 类型:字符串
- 是否必需:否
使用方法
路径指定为 remote:bucket
(对于 lsf
命令,可使用 remote:
)。你也可以指定子目录,例如 remote:bucket/path/to/dir
。
配置完成后,你可以像下面这样使用 rclone
。
创建新的存储桶
使用 mkdir
命令创建新的存储桶,例如 bucket
。
rclone mkdir remote:bucket
列出所有存储桶
使用 lsf
命令列出所有存储桶。
rclone lsf remote:
注意命令行末尾的冒号 (:
) 字符。
删除存储桶
使用 rmdir
命令删除空的存储桶。
rclone rmdir remote:bucket
使用 purge
命令删除非空存储桶及其所有内容。
rclone purge remote:bucket
上传对象
使用 copy
命令上传一个对象。
rclone copy --progress /home/local/directory/file.ext remote:bucket/path/to/dir/
--progress
标志用于显示进度信息。如果你不需要此信息,可以移除该标志。
使用本地路径中的文件夹来上传其所有对象。
rclone copy --progress /home/local/directory/ remote:bucket/path/to/dir/
只会复制已修改的文件。
列出对象
使用 ls
命令递归列出存储桶中的所有对象。
rclone ls remote:bucket
在远程路径中添加文件夹,以递归列出该文件夹中的所有对象。
rclone ls remote:bucket/path/to/dir/
使用 lsf
命令非递归地列出存储桶或文件夹中的所有对象。
rclone lsf remote:bucket/path/to/dir/
下载对象
使用 copy
命令下载一个对象。
rclone copy --progress remote:bucket/path/to/dir/file.ext /home/local/directory/
--progress
标志用于显示进度信息。如果你不需要此信息,可以移除该标志。
在远程路径中使用文件夹来下载其所有对象。
rclone copy --progress remote:bucket/path/to/dir/ /home/local/directory/
删除对象
使用 deletefile
命令删除单个对象。
rclone deletefile remote:bucket/path/to/dir/file.ext
使用 delete
命令删除文件夹中的所有对象。
rclone delete remote:bucket/path/to/dir/
打印对象的总大小
使用 size
命令打印存储桶或文件夹中对象的总大小。
rclone size remote:bucket/path/to/dir/
同步两个位置
使用 sync
命令将源同步到目标,仅更改目标,删除任何多余的文件。
rclone sync --interactive --progress /home/local/directory/ remote:bucket/path/to/dir/
--progress
标志用于显示进度信息。如果你不需要此信息,可以移除该标志。
由于这可能会导致数据丢失,首先使用 --dry-run
标志进行测试,以确切了解哪些文件将被复制和删除。
同步也可以从Storj到本地文件系统进行。
rclone sync --interactive --progress remote:bucket/path/to/dir/ /home/local/directory/
或者在两个Storj存储桶之间进行。
rclone sync --interactive --progress remote-us:bucket/path/to/dir/ remote-europe:bucket/path/to/dir/
甚至可以在另一个云存储和Storj之间进行。
rclone sync --interactive --progress s3:bucket/path/to/dir/ storj:bucket/path/to/dir/
限制
rclone的Storj后端不支持 rclone about
命令。没有此功能的后端无法确定rclone挂载的可用空间,也不能在rclone联合远程存储中使用 mfs
(最大可用空间)策略。
请参阅 不支持rclone about的后端列表 和 rclone about
已知问题
如果你遇到像 too many open files
这样的错误,这通常是因为超过了系统最大打开文件的默认 ulimit
。原生的Storj协议会打开大量的TCP连接(每个连接都被视为一个打开的文件)。对于单个上传流,你可以预计会打开110个TCP连接。对于单个下载流,你可以预计会打开35个连接。每64 MiB的数据段都会打开一批这样的连接,并且你还应该预计TCP连接会被复用。如果你进行多次传输,最终会与大多数存储节点(数千个节点)建立连接。
要解决这些问题,请提高你的系统限制。你可以在运行rclone之前执行 ulimit -n 65536
来临时提高限制。要更永久地更改限制,你可以将其添加到你的shell启动脚本中,例如 $HOME/.bashrc
,或者更改系统范围的配置,通常是 /etc/sysctl.conf
和/或 /etc/security/limits.conf
,但请参考你的操作系统手册。