# 火山引擎 TOS

本指南介绍如何将[火山引擎对象存储服务(TOS)](https://www.volcengine.com/product/TOS) 配置为 Alluxio 的底层存储系统。 火山引擎对象存储服务 (TOS) 是火山引擎提供的海量、安全、低成本、易用、高可靠、高可用的分布式云存储服务。

## 先决条件

在将 TOS 用于 Alluxio 之前，请按照 [TOS 快速入门指南](https://www.volcengine.com/docs/6349/74830) 注册 TOS 并创建一个 TOS 存储桶。

如果该步骤尚未完成，请参阅 [部署条件](https://documentation.alluxio.io/ee-ai-cn/ai-3.3/ufs/pages/LiNnwRBulfuBSrfBRinf#先决条件)完成安装。

将 TOS 用于 Alluxio 前的准备：

| `<TOS_BUCKET>`            | 创建一个新的 TOS 存储桶或使用一个现有的存储桶                                                                                                                                   |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `<OS_DIRECTORY>`          | 要在存储桶中使用的目录，可以是新创建的一个目录或者一个现有目录                                                                                                                             |
| `<TOS_ACCESS_KEY_ID>`     | TOS 的 [Access Key ID](https://www.volcengine.com/docs/6291/65568)， 在 [TOS AccessKey 管理控制台](https://console.volcengine.com/iam/keymanage/) 中创建和管理            |
| `<TOS_ACCESS_KEY_SECRET>` | TOS 的 [Secret Access Key](https://www.volcengine.com/docs/6291/65568)， 在 [TOS AccessKey 管理控制台](https://console.volcengine.com/iam/keymanage/) 中创建和管理        |
| `<TOS_ENDPOINT>`          | 存储桶的网络接口，可在存储桶概览页面找到，其值类似 `tos-cn-beijing.volces.com` 和 `tos-cn-guangzhou.volces.com`。 可用的接口列在 [TOS 网络接口文档](https://www.volcengine.com/docs/6349/107356) 中。 |
| `<TOS_REGION>`            | 存储桶所在的区域，例如 `cn-beijing` 或 `cn-guangzhou`。 可用的区域列在 [TOS 区域文档](https://www.volcengine.com/docs/6349/107356) 中。                                               |

## 基本设置

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

将`tos://<TOS_BUCKET>/<TOS_DIRECTORY>` 挂载到 `/tos`的命令示例如下：

```shell
bin/alluxio mount add --path /tos/ --ufs-uri tos://<TOS_BUCKET>/<TOS_DIRECTORY> \
  --option fs.tos.accessKeyId=<TOS_ACCESS_KEY> --option fs.tos.accessKeySecret=<TOS_ACCESS_KEY_SECRET> \
  --option fs.tos.endpoint=<TOS_ENDPOINT> --option fs.tos.region=<TOS_REGION>
```

请注意，如果要挂载 TOS 存储桶的根目录，请在存储桶名称后添加斜线（如 `tos://TOS_BUCKET/`）。

## 进阶设置

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

### TOS 分片上传

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

要启用 TOS 分片上传，需要修改 `conf/alluxio-site.properties` 以包含：

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

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

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

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

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

### 高并发调优

将 Alluxio 与 TOS 集成时，可以通过调整以下配置来优化性能：

* `alluxio.underfs.tos.retry.max`： 控制 TOS 的重试次数。默认值为 3。
* `alluxio.underfs.tos.read.timeout`： 控制 TOS 的读取超时时间。默认值为 30000 毫秒。
* `alluxio.underfs.tos.write.timeout`： 控制 TOS 写超时时间。默认值为 30000 毫秒。
* `alluxio.underfs.tos.streaming.upload.partition.size`： 控制 TOS 流式上传的分区大小。默认值为 64MB。
* `alluxio.underfs.tos.connect.timeout`： 控制 TOS 的连接超时时间。默认值为 30000 毫秒


---

# 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.3/ufs/tos.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.
