Files
nexus/wiki/concepts/S3-兼容对象存储.md
2026-04-22 08:02:59 +08:00

97 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: S3-兼容对象存储
type: concept
tags: [storage, s3, minio]
date: 2025-12-29
---
# S3-兼容对象存储
## Definition
S3-兼容对象存储是指实现了 Amazon S3 API 的对象存储系统,可以在不修改代码的情况下替换 AWS S3 使用。包括 MinIO、Cloudflare R2、Backblaze B2、SeaweedFS 等。
## Core S3 Concepts
| 概念 | 说明 |
|------|------|
| Bucket | 存储桶,类似顶级文件夹 |
| Object | 对象,文件及其元数据 |
| Key | 对象的唯一标识符(路径) |
| Region | 区域,物理位置 |
| ACL | 访问控制列表 |
| Policy | IAM 策略 |
| Presigned URL | 预签名 URL限时访问 |
## S3 vs Traditional Storage
| 特性 | S3 对象存储 | 传统文件系统 |
|------|-------------|--------------|
| 访问方式 | HTTP API | 文件路径 |
| 扩展性 | 无限扩展 | 受限于单盘/RAID |
| 成本 | 按量计费 | 一次性硬件 |
| 元数据 | 键值对灵活扩展 | 固定属性 |
| 原子性 | 最终一致性 | 强一致性 |
| 版本控制 | 原生支持 | 需额外配置 |
## MinIO Configuration for Zipline
```yaml
environment:
STORAGE_ENGINE: s3
S3_BUCKET: zipline-bucket
S3_ENDPOINT: http://minio:9000
S3_ACCESS_KEY: admin
S3_SECRET_KEY: Abcd_1234
S3_REGION: us-east-1
S3_FORCE_PATH_STYLE: "true" # 重要MinIO 需要此设置
```
关键参数 `S3_FORCE_PATH_STYLE: "true"`
- MinIO 默认使用虚拟主机风格bucket.minio:9000
- 部分应用需要路径风格minio:9000/bucket
- 设置为 true 确保兼容性
## Anonymous Access with mc
```bash
# 设置别名
mc alias set local http://192.168.3.17:9000 admin password
# 创建 bucket
mc mb local/zipline-bucket
# 设置匿名访问权限
mc anonymous set public local/zipline-bucket # 公共读写
mc anonymous set download local/zipline-bucket # 仅下载
# 查看匿名策略
mc anonymous list local/zipline-bucket
```
## Cloud Provider Comparison
| 提供商 | S3 兼容 | 出口流量计费 | 最小存储量 | 特色 |
|--------|----------|--------------|------------|------|
| AWS S3 | 原生 | $0.09/GB | 无 | 功能最全 |
| Cloudflare R2 | 是 | **免费** | 无 | 无出口费 |
| Backblaze B2 | 是 | $0.01/GB | 无 | 性价比高 |
| MinIO | 是 | 0 | 无 | 自托管 |
| SeaweedFS | 是 | 0 | 无 | 大文件优化 |
## Use Cases
1. **备份存储**:低频访问但需高持久性
2. **静态资源**CDN 回源存储
3. **图床/媒体库**:直接 URL 访问
4. **AI 模型权重**:大文件存储
## Connections
- [[MinIO]] ← implements ← [[S3-兼容对象存储]]
- [[Zipline]] ← uses ← [[S3-兼容对象存储]]
- [[图床]] ← backed by ← [[S3-兼容对象存储]]
## Related Concepts
- [[对象存储]]
- [[图床]]
- [[数据一致性]]