Alluxio 命名空间和底层文件系统命名空间

Slack Docker Pulls

简介

Alluxio 可跨不同存储系统实现有效的数据管理。 Alluxio 通过使用挂载表将 Alluxio 中的路径映射到这些存储系统,从而提供所有数据源的统一视图。

我们使用 “Under File System(UFS,底层文件系统)”一词来表示由 Alluxio 管理和缓存的存储系统。 Alluxio 构建在存储层之上,提供缓存加速和其他各类数据管理功能。因此,这些存储系统位于 Alluxio 层 “之下”。

用户将 UFS “挂载”到 Alluxio 路径上。以下示例说明用户如何将 S3 存储桶和 GCS 存储桶挂载到 Alluxio。

Alluxio Namespace

上述示例的挂载表如下所示:

Alluxio Paths       UFS Paths
=================== =========================
/s3/                s3://bucketA/data/
/gcs/               gcs://bucketB/records/

配置挂载表

Alluxio 支持使用 ETCD 来存储挂载表信息。 将挂载表存储在 ETCD 中后,所有 Alluxio 进程(client, worker, FUSE 等)都将从 ETCD 中读取挂载表信息。

要使用 ETCD 作为挂载表的后端,请在 alluxio-site.properties 中添加以下配置:

alluxio.mount.table.source=ETCD
alluxio.etcd.endpoints=<connection URI of etcd cluster>

alluxio.etcd.endpoints 设置为 ETCD 集群中的实例列表,例如:

# Typically an etcd cluster has at least 3 nodes, for high availability
alluxio.etcd.endpoints=http://etcd-node0:2379,http://etcd-node1:2379,http://etcd-node2:2379

Alluxio 进程启动时会连接到 ETCD,并要求 ETCD 处于运行状态。 然后,Alluxio 会定期读取 ETCD 来获取挂载表的更新。 读取间隔在下面的 alluxio-site.properties 中进行配置。

# By default a poll happens every 3s
alluxio.mount.table.etcd.polling.interval.ms=3s

在拥有数千个 Alluxio client 和数百个 Alluxio Worker 的大型集群中,最好设置稍大的时间间隔来减轻 ETCD 的压力。 如果挂载表的更新很少,则可使用更大的时间间隔,如 30 秒或以上。

挂载表操作

您可以使用 Alluxio 命令行轻松添加或删除挂载点:

# Add a new mount point
$ bin/alluxio mount add --path /s3/ --ufs-uri s3://bucketA/data/
Mounted ufsPath=s3://bucketA/data to alluxioPath=/s3 with 0 options

# Remove an existing mount point
$ bin/alluxio mount remove --path /s3/
Unmounted /s3 from Alluxio.

您可以使用 bin/alluxio mount list 命令列出当前的挂载表:

$ bin/alluxio mount list
Listing all mount points
s3a://data/                                                    on  /s3/    properties={}
file:///tmp/underFSStorage/                                    on  /local/ properties={}

注意:所有 Alluxio 组件从 ETCD 重新加载更新后的挂载表需要一点时间。 所需时间取决于 alluxio.mount.table.etcd.polling.interval.ms

配置 UFS

指定挂载点后,当 Alluxio 进程与相应的 UFS 交互时,还需要有专门针对 UFS 的配置,如安全凭证。

对所有挂载点使用相同的配置

您可以将所有 UFS 配置留在 alluxio-site.properties 文件中,Alluxio 会把这些配置用于所有挂载点。例如:

# Configure the S3 credentials for all mount points
s3.accessKeyId=<S3 ACCESS KEY>
s3.secretKey=<S3 SECRET KEY>
alluxio.underfs.s3.region=us-east-1
alluxio.underfs.s3.endpoint=http://s3.amazonaws.com

# Configure the HDFS configurations for all mount points
alluxio.underfs.hdfs.configuration=/path/to/hdfs/conf/core-site.xml:/path/to/hdfs/conf/hdfs-site.xml

这样的话,您的所有挂载点都将使用相同的 S3 凭证和 HDFS 配置。在所有挂载点都可以使用相同配置的情况下,这是配置 Alluxio 挂载点最简单的方法。 这也是在 alluxio-site.properties 文件中管理所有配置属性最简单的方法。

对不同挂载点使用不同的配置

一般来说,用户可能希望对不同的挂载点使用不同的配置。 例如,如果用户有两个 S3-flavor 路径的挂载点,一个使用 AWS S3 作为存储后端,另一个使用 MinIO 作为存储后端,用户可能希望对每个挂载点使用不同的凭证和不同的端点。

Alluxio Paths       UFS Paths
=================== ===========================
/s3-images          s3://bucketA/data/images
/minio-tables       s3://bucketB/data/tables

您可以在添加新的挂载点时指定挂载选项。

$ bin/alluxio mount add --path /s3/ --ufs-uri s3://<S3_BUCKET>/ \ 
  --option s3.accessKeyId=<AWS_ACCESS_KEY> --option s3.secretKey=<AWS_SECRET_KEY> \
  --option alluxio.underfs.s3.endpoint=http://s3.amazonaws.com \
  --option alluxio.underfs.s3.region=us-east-1

通过这种方式,您可以为该挂载点指定配置属性。

注意:如果您在命令行中指定了挂载选项,请从 alluxio-site.properties文件中删除这些配置选项,避免冲突或混淆。

您还可以更新现有挂载点的挂载选项。但是,您需要先卸载该挂载点,然后使用更新后的选项重新挂载该挂载点。

$ bin/alluxio mount remove --path /s3/ --ufs-uri s3://alluxio-jliu/

$ bin/alluxio mount add --path /s3/ --ufs-uri s3://alluxio-jliu/ \ 
  --option s3.accessKeyId=<access key> --option s3.secretKey=<secret key> \
  --option alluxio.underfs.s3.endpoint=http://s3.amazonaws.com \
  --option alluxio.underfs.s3.region=us-west-2

高级

一个更复杂的挂载表

下面我们来看一个更复杂的挂载表示例。

Alluxio Paths       UFS Paths
=================== ===========================================
/s3-images          s3://my-bucket/data/images
/s3-tables          s3://my-bucket/data/tables
/hive-data          hdfs://hdfs-cluster.company.com/user/hive
/presto-data        hdfs://hdfs-cluster.company.com/user/presto
/gcs                gcs://my-bucket/data

以上示例中的挂载表包括5个挂载点。 第一列是 Alluxio 命名空间中挂载点的路径。 第二列列出了挂载在 Alluxio 上的对应 UFS 路径。

第一个挂载点定义了从 S3 路径 s3://my-bucket/data/images到 Alluxio 路径 /s3-images 的映射关系。 因此,所有带有 S3 前缀 s3://my-bucket/data/images 的对象将在 Alluxio 目录 /s3-images 下。 例如,s3://my-bucket/data/images/collections/20240101/sample.png 可在 Alluxio 路径 /s3-images/collections/20240101/sample.png下找到。

第二个挂载点定义了从 S3 路径 s3://my-bucket/data/tables 到 Alluxio 路径/s3-tables 的映射关系。UFS 路径实际上与第一个挂载条目来自同一个存储桶。 如本示例所示,用户可以自由选择 UFS 命名空间中的部分内容挂载到 Alluxio。

第三个和第四个条目定义了 Alluxio 路径 /hive/presto 与同一 HDFS 中两个目录 (分别为 hdfs://hdfs-cluster.company.com/user/hivehdfs://hdfs-cluster.company.com/user/presto )之间的映射关系。 同样,这两个 HDFS 目录树下的文件和目录也可在相应的 Alluxio 路径下找到。 例如,在 Alluxio 命名空间中,hdfs://hdfs cluster.company.com/user/hive/schema/table/part1.parquet 变为/hive/schema/table/part1.parquet

挂载表规则

在 Alluxio 中定义挂载点时必须遵循几条规则。

规则 1. 必须直接挂载到根路径 /

Alluxio 中的挂载点必须是根路径 / 的直接子路径。例如 s3-images/hive/presto都是有效的挂载点。 根路径 / 只是 Alluxio 命名空间中的一个虚拟节点。它不会映射到任何 UFS 路径上。

# This is invalid, you cannot mount to the root path directly
/          s3://my-bucket/

# This is invalid, a mount point can only be directly under /
/s3-images/dataset1   s3://my-bucket/data/images/dataset1

# This is valid
/s3-images   s3://my-bucket/data/images/dataset1

规则 2. 不得嵌套挂载点

挂载点不能嵌套。 一个挂载点的 Alluxio 路径不能位于另一个挂载点的 Alluxio 路径下。 同样,一个挂载点的 UFS 路径也不能位于另一个挂载点的 UFS 路径之下。

# Suppose we have this mount point
/data     s3://bucket/data

# This new mount point is invalid -- the Alluxio path is under an existing mount point
/data/hdfs     hdfs://host:port/data

# This is also invalid -- the UFS path is under an existing mount point
/images   s3://bucket/data/images