外部存储#
¥External storage
Feature availability
- 适用于自托管企业版套餐。
¥Available on Self-hosted Enterprise plans
- 如果你想在 Cloud Enterprise 上使用此功能,请使用 联系 n8n。
¥If you want access to this feature on Cloud Enterprise, contact n8n.
n8n 可以将工作流执行生成的二进制数据存储在外部。此功能有助于避免依赖文件系统来存储大量二进制数据。
¥n8n can store binary data produced by workflow executions externally. This feature is useful to avoid relying on the filesystem for storing large amounts of binary data.
n8n 未来将引入对其他数据类型的外部存储支持。
¥n8n will introduce external storage for other data types in the future.
将 n8n 的二进制数据存储在 S3 中#
¥Storing n8n's binary data in S3
n8n 支持将 AWS S3 用作工作流执行生成的二进制数据的外部存储。你可以使用其他与 S3 兼容的服务,例如 Cloudflare R2 和 Backblaze B2,但 n8n 官方不支持这些服务。
¥n8n supports AWS S3 as an external store for binary data produced by workflow executions. You can use other S3-compatible services like Cloudflare R2 and Backblaze B2, but n8n doesn't officially support these.
Enterprise-tier feature
你需要一个 企业版许可证密钥 用于外部存储。如果你的许可证密钥过期且你仍处于 S3 模式,则实例可以读取 S3 存储桶,但无法写入。
¥You will need an Enterprise license key for external storage. If your license key expires and you remain on S3 mode, the instance will be able to read from, but not write to, the S3 bucket.
设置#
¥Setup
按照 AWS 文档 创建并配置存储桶。你可以使用以下策略,并将 <bucket-name> 替换为你创建的存储桶的名称:
¥Create and configure a bucket following the AWS documentation. You can use the following policy, replacing <bucket-name> with the name of the bucket you created:
1 2 3 4 5 6 7 8 9 10 11 | |
设置存储桶级别的生命周期配置,以便 S3 自动删除旧的二进制数据。n8n 将二进制数据的清理工作委托给 S3,因此除非你希望无限期地保留二进制数据,否则需要设置生命周期配置。
¥Set a bucket-level lifecycle configuration so that S3 automatically deletes old binary data. n8n delegates pruning of binary data to S3, so setting a lifecycle configuration is required unless you want to preserve binary data indefinitely.
创建存储桶完成后,你将获得主机、存储桶名称和区域,以及访问密钥 ID 和秘密访问密钥。你需要在 n8n 的环境中进行以下设置:
¥Once you finish creating the bucket, you will have a host, bucket name and region, and an access key ID and secret access key. You need to set them in n8n's environment:
1 2 3 4 5 | |
No region
如果你的提供商不需要区域,你可以将 N8N_EXTERNAL_STORAGE_S3_BUCKET_REGION 设置为 'auto'。
¥If your provider doesn't require a region, you can set N8N_EXTERNAL_STORAGE_S3_BUCKET_REGION to 'auto'.
指示 n8n 将二进制数据存储在 S3 中:
¥Tell n8n to store binary data in S3:
1 2 | |
Auth autodetection
要自动检测用于验证 S3 调用的凭据,请将 N8N_EXTERNAL_STORAGE_S3_AUTH_AUTO_DETECT 设置为 true。这将使用默认的 凭据提供程序链。
¥To automatically detect credentials to authenticate your S3 calls, set N8N_EXTERNAL_STORAGE_S3_AUTH_AUTO_DETECT to true. This will use the default credential provider chain.
重启服务器以加载新配置。
¥Restart the server to load the new configuration.
用法#
¥Usage
启用 S3 后,n8n 会向 S3 存储桶写入和读取任何新的二进制数据。n8n 会以以下格式将二进制数据写入你的 S3 存储桶:
¥After you enable S3, n8n writes and reads any new binary data to and from the S3 bucket. n8n writes binary data to your S3 bucket in this format:
1 | |
如果 filesystem 仍然在 N8N_AVAILABLE_BINARY_DATA_MODES 中列为选项,n8n 将继续从文件系统读取存储在文件系统中的旧二进制数据。
¥n8n continues to read older binary data stored in the filesystem from the filesystem, if filesystem remains listed as an option in N8N_AVAILABLE_BINARY_DATA_MODES.
如果你将二进制数据存储在 S3 中,之后切换到文件系统模式,只要 s3 仍然列在 N8N_AVAILABLE_BINARY_DATA_MODES 中,并且你的 S3 凭据仍然有效,实例就会继续读取存储在 S3 中的任何数据。
¥If you store binary data in S3 and later switch to filesystem mode, the instance continues to read any data stored in S3, as long as s3 remains listed in N8N_AVAILABLE_BINARY_DATA_MODES and your S3 credentials remain valid.
Binary data pruning
Binary data pruning operates on the active binary data mode. For example, if your instance stored data in S3, and you later switched to filesystem mode, n8n only prunes binary data in the filesystem. This may change in future.