# 阿里云 OSS

本指南介绍如何将[阿里云 OSS](https://intl.aliyun.com/product/oss) 配置为 Alluxio 的底层存储系统。

阿里云对象存储服务 (OSS) 是阿里云提供的一种海量、安全、高可靠的云存储服务。OSS 提供多种存储类别，帮助您管理和降低存储成本。

有关阿里云 OSS 的更多信息，请阅读其[文档](https://www.alibabacloud.com/help/en/oss/)。

## 先决条件

在开始之前，请确保您已准备好以下所需信息：

| `<OSS_BUCKET>`            | 在 [OSS 控制台中创建一个新存储桶](https://www.alibabacloud.com/help/en/oss/getting-started/create-buckets-6#task-2013189)或使用现有存储桶 |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `<OSS_DIRECTORY>`         | 您要在存储桶中使用的目录，可以是创建新目录或使用现有目录                                                                                         |
| `<OSS_ACCESS_KEY_ID>`     | 用于识别用户的 ID。请参阅[如何获取 AccessKey 对](https://www.alibabacloud.com/help/en/sls/developer-reference/accesskey-pair)        |
| `<OSS_ACCESS_KEY_SECRET>` | 用于验证用户身份的密钥。请参阅[如何获取 AccessKey 对](https://www.alibabacloud.com/help/en/sls/developer-reference/accesskey-pair)       |
| `<OSS_ENDPOINT>`          | 其他服务可用于访问 OSS 的域名。请参阅[公共云中的区域和 OSS 端点](https://www.alibabacloud.com/help/en/oss/user-guide/regions-and-endpoints)    |

## 基本设置

通用挂载机制和 `UnderFileSystem` CR 字段参考，请参阅[底层存储](https://documentation.alluxio.io/ee-ai-cn/ufs/pages/QHxxAwAliFxrTQ5jOZw7#基本挂载配置)。

{% tabs %}
{% tab title="Kubernetes (Operator)" %}
使用 operator 创建 OSS 挂载点的 `ufs.yaml` 示例：

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: UnderFileSystem
metadata:
  name: alluxio-oss
  namespace: alx-ns
spec:
  alluxioCluster: alluxio-cluster
  path: oss://<OSS_BUCKET>/<OSS_DIRECTORY>
  mountPath: /oss
  mountOptions:
    fs.oss.accessKeyId: <OSS_ACCESS_KEY>
    fs.oss.accessKeySecret: <OSS_ACCESS_KEY_SECRET>
    fs.oss.endpoint: <OSS_ENDPOINT>
```

{% endtab %}

{% tab title="Docker / 裸机" %}
如果不使用 operator，将 `oss://<OSS_BUCKET>/<OSS_DIRECTORY>` 挂载到 `/oss` 的示例命令：

```shell
bin/alluxio mount add --path /oss/ --ufs-uri oss://<OSS_BUCKET>/<OSS_DIRECTORY> \
  --option fs.oss.accessKeyId=<OSS_ACCESS_KEY> --option fs.oss.accessKeySecret=<OSS_ACCESS_KEY_SECRET> \
  --option fs.oss.endpoint=<OSS_ENDPOINT>
```

请注意，如果要挂载 OSS 存储桶的根目录，请在存储桶名称后添加一个尾部斜杠（例如 `oss://OSS_BUCKET/`）。
{% endtab %}
{% endtabs %}

## 高级设置

请注意，配置选项可以指定为挂载选项或 `conf/alluxio-site.properties` 中的配置属性。 以下各节将介绍如何将配置设置为属性，但它们也可以通过 `--option <key>=<value>` 设置为挂载选项。

### 启用 HTTPS

要启用 HTTPS 协议以与 OSS 进行安全通信，并为数据传输增加一层额外的安全性， 请在 conf/alluxio-site.properties 中配置以下设置：

```properties
alluxio.underfs.oss.secure.http.enabled=true
```

### OSS 分片上传

我们使用分片上传方法将一个文件分多个部分上传，每个部分将在一个线程中上传。上传时不会生成任何临时文件。

您可以在 `conf/alluxio-site.properties` 中指定其他参数以可能加快上传速度。

```properties
# Timeout for uploading part when using multipart upload.
alluxio.underfs.object.store.multipart.upload.timeout
```

```properties
# Thread pool size for OSS multipart upload.
alluxio.underfs.oss.multipart.upload.threads
```

```properties
# Multipart upload partition size for OSS. The default partition size is 16MB.
alluxio.underfs.oss.multipart.upload.part.size
```

禁用 OSS 分片上传，上传方法将一次性从头到尾完整上传一个文件。您需要修改 `conf/alluxio-site.properties` 以包含：

```properties
alluxio.underfs.oss.multipart.upload.enabled=false
```

### 设置请求重试策略

适用于所有对象存储 UFS 类型的重试配置，请参阅 UFS 概览中的[请求重试策略](https://documentation.alluxio.io/ee-ai-cn/ufs/pages/QHxxAwAliFxrTQ5jOZw7#请求重试策略)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-cn/ufs/aliyun-oss.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
