如何管理存储桶和密钥¶
有关如何创建、配置、查看和调整大小的说明,请参阅以下部分 存储桶 以及如何管理存储桶密钥。
配置 S3 地址¶
如果您想在本地存储上使用存储桶(因此在 dir
、btrfs
、lvm
或 zfs
池中),则必须为您的 Incus 服务器配置 S3 地址。这是您可以用来通过 S3 协议访问存储桶的地址。
要配置 S3 地址,请设置 core.storage_buckets_address
服务器配置选项。例如
incus config set core.storage_buckets_address :8555
管理存储桶¶
存储桶提供对使用 S3 协议公开的对象存储的访问。
与自定义存储卷不同,存储桶不会添加到实例中,但应用程序可以改为通过其 URL 直接访问它们。
有关详细信息,请参阅 存储桶。
创建存储桶¶
使用以下命令在存储池中创建存储桶
incus storage bucket create <pool_name> <bucket_name> [configuration_options...]
有关每个支持对象存储的驱动程序可用的存储桶配置选项列表,请参阅 存储驱动程序 文档。
要在集群成员上添加存储桶,请添加 --target
标志
incus storage bucket create <pool_name> <bucket_name> --target=<cluster_member> [configuration_options...]
注意
对于大多数存储驱动程序,存储桶不会在集群中复制,并且仅存在于为其创建的成员上。此行为对于 cephobject
存储池不同,在 cephobject
存储池中,存储桶可从任何集群成员访问。
配置存储桶设置¶
有关每个支持对象存储的存储驱动程序可用的配置选项,请参阅 存储驱动程序 文档。
使用以下命令设置存储桶的配置选项
incus storage bucket set <pool_name> <bucket_name> <key> <value>
例如,要设置存储桶的配额大小,请使用以下命令
incus storage bucket set my-pool my-bucket size 1MiB
您还可以使用以下命令编辑存储桶配置
incus storage bucket edit <pool_name> <bucket_name>
使用以下命令删除存储桶及其密钥
incus storage bucket delete <pool_name> <bucket_name>
查看存储桶¶
您可以显示存储池中所有可用存储桶的列表并检查其配置。
要列出存储池中所有可用的存储桶,请使用以下命令
incus storage bucket list <pool_name>
要显示有关特定存储桶的详细信息,请使用以下命令
incus storage bucket show <pool_name> <bucket_name>
调整存储桶大小¶
默认情况下,存储桶没有应用配额。
要设置或更改存储桶的配额,请设置其大小配置
incus storage bucket set <pool_name> <bucket_name> size <new_size>
重要
扩展存储桶通常有效(如果存储池有足够的存储空间)。
您不能将存储桶缩小到其当前使用大小以下。
管理存储桶密钥¶
要访问存储桶,应用程序必须使用由访问密钥和密钥组成的 S3 凭据集。您可以为特定存储桶创建多个凭据集。
每个凭据集都将获得一个密钥名称。密钥名称仅用于参考,不需要提供给使用凭据的应用程序。
每个凭据集都有一个角色,指定它们可以在存储桶上执行哪些操作。
可用的角色是
admin
- 对存储桶的完全访问权限read-only
- 对存储桶的只读访问权限(仅列出和获取文件)
如果在创建存储桶密钥时未指定角色,则使用的角色是 read-only
。
创建存储桶密钥¶
使用以下命令为存储桶创建凭据集
incus storage bucket key create <pool_name> <bucket_name> <key_name> [configuration_options...]
使用以下命令为存储桶创建具有特定角色的凭据集
incus storage bucket key create <pool_name> <bucket_name> <key_name> --role=admin [configuration_options...]
这些命令将生成并显示一组随机的凭据密钥。
编辑或删除存储桶密钥¶
使用以下命令编辑现有的存储桶密钥
incus storage bucket key edit <pool_name> <bucket_name> <key_name>
使用以下命令删除现有存储桶密钥
incus storage bucket key delete <pool_name> <bucket_name> <key_name>
查看存储桶密钥¶
使用以下命令查看为现有存储桶定义的密钥
incus storage bucket key list <pool_name> <bucket_name>
使用以下命令查看特定存储桶密钥
incus storage bucket key show <pool_name> <bucket_name> <key_name>