Aliyun OSS
OSS:对象存储服务
Aliyun Object Storage Service(阿里云 OSS)被广泛使用,尤其在中国云用户中颇受欢迎,可为多种使用场景提供云对象存储。
依赖
Apache Fluss 将 OSS 文件系统插件发布到 Maven Central:
| 组件 | Jar |
|---|---|
| Fluss OSS filesystem plugin | fluss-fs-oss-1.1-SNAPSHOT.jar |
Maven 坐标:
<dependency>
<groupId>org.apache.fluss</groupId>
<artifactId>fluss-fs-oss</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>可使用校验说明校验下载的 JAR。
配置设置
要将 OSS 启用为远端存储,需要在 Fluss 的 server.yaml 中添加一些必填配置:
# 用作 Fluss 远端存储的目录
remote.data.dir: oss://<your-bucket>/path/to/remote/storage
# 要连接的 Aliyun OSS endpoint,例如:oss-cn-hangzhou.aliyuncs.com
fs.oss.endpoint: <your-endpoint>
# 要连接的 Aliyun STS endpoint,用于获取 STS token,例如:sts.cn-hangzhou.aliyuncs.com
fs.oss.sts.endpoint: <your-sts-endpoint>
# STS endpoint 获取的 STS token 对应的角色,例如:acs:ram::123456789012:role/testrole
fs.oss.roleArn: <your-role-arn>
# 认证(从以下两种选项中选择一种)
# 选项 1:直接凭据
# Aliyun access key ID
fs.oss.accessKeyId: <your-access-key>
# Aliyun access key secret
fs.oss.accessKeySecret: <your-secret-key>
# 选项 2:安全的凭据提供器
fs.oss.credentials.provider: <your-credentials-provider>为了避免在 server.yaml 中直接暴露敏感的 access key 信息,你可以选择选项 2,通过设置 fs.oss.credentials.provider 属性来使用凭据提供器。
例如,使用环境变量进行凭据管理:
fs.oss.credentials.provider: com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider然后,在启动 Fluss 服务之前设置以下环境变量:
export OSS_ACCESS_KEY_ID=<your-access-key>
export OSS_ACCESS_KEY_SECRET=<your-secret-key>这种方式通过将敏感凭据排除在配置文件之外,提高了安全性。
基于 Token 的认证
对于客户端访问远端存储(如读取快照或分层日志),客户端必须从 Fluss 集群获取 STS token。因此你必须配置 fs.oss.sts.endpoint 和 fs.oss.roleArn。 fs.oss.sts.endpoint 是用于获取 STS token 的 STS endpoint,例如杭州区域的 sts.cn-hangzhou.aliyuncs.com,你可以在 Aliyun STS Endpoint 中找到不同区域的 endpoint。 fs.oss.roleArn 用于 STS endpoint 获取的 STS token 对应的角色,格式应为 acs:ram::<aliyun-account-id>:role/<role-name>,例如 acs:ram::123456789012:role/testrole。由于客户端将使用 STS token 读取远端存储,该角色必须被授予远端存储的读权限。更多细节请参阅 AssumeRole。
除了上述配置外,你还可以在 Fluss 的 server.yaml 中定义 Hadoop OSS 文档 中提到的配置键。这些在 Hadoop OSS 文档中定义的配置属于高级配置,通常用于性能调优。