# 阿里云 OSS

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

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

有关阿里云对象存储服务的更多信息，请阅读其[文档](https://www.alibabacloud.com/help/zh/oss/)

## 先决条件

如果尚未了解，请在开始使用前查看[先决条件](https://documentation.alluxio.io/ee-ai-cn/ai-3.4/ufs/pages/Yuv0VQPH1cwpyWDjSIpk#先决条件)。

准备与 Alluxio 一起使用 OSS：

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

## 基本设置

使用 [挂载表操作](https://documentation.alluxio.io/ee-ai-cn/ai-3.4/ufs/pages/oDewb6KbLdrwss4HRo4S#挂载表操作) 来增加一个新的挂载点, 指定Alluxio路径在其上创建挂载，指定OSS的路径作为UFS URI。 密钥和配置选项也可以通过指定 `--option` 标志作为挂载命令的一部分来指定，如[配置挂载点](https://documentation.alluxio.io/ee-ai-cn/ai-3.4/ufs/pages/oDewb6KbLdrwss4HRo4S#对不同挂载点使用不同的配置)所述。

一个将 `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 bucket的根，请在bucket名称后面添加一个斜杠（例如`oss://OSS_BUCKET/`).

## 高级设置

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

### \[实验性] OSS 多部分上传

默认的上传方法是一次性从头到尾上传一个文件。我们使用多部分上传方法分多个部分上传一个文件，每个部分都将在一个线程中上传。上传时不会生成任何临时文件。

要启用 OSS 多部分上传，需要修改 `conf/alluxio-site.properties`，将以下内容包括在内：

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

您还可以在 `conf/alluxio-site.properties` 中指定其他参数，以使程序更快更好地运行。

```properties
# 使用分片上传时，上传分片的超时时间。
alluxio.underfs.object.store.multipart.upload.timeout
```

```properties
# OSS 分片上传的线程池大小。
alluxio.underfs.oss.multipart.upload.threads
```

```properties
# OSS 分片上传的分区大小。默认分区大小为 64MB。 
alluxio.underfs.oss.multipart.upload.partition.size
```


---

# 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/ai-3.4/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.
