创建安装目标时,其传输加密类型必须反映共享的允许传输加密方式。 如果要由不同 VPC 中的资源使用,那么可以为共享创建多个安装目标。 每个 VPC 可为文件共享创建一个挂载目标。
从 CLI 创建文件共享
从 CLI 收集信息
在运行 ibmcloud is share-create
命令之前,您可以通过查看有关其他文件共享,安装目标和文件存储器概要文件的信息来收集供应共享所需的信息。
创建文件共享的详细信息。
详细信息 |
列出选项 |
它提供的内容 |
文件共享 |
ibmcloud is shares |
列出区域内的所有股份。 |
文件共享详细信息 |
ibmcloud is share SHARE_ID |
查看共享的详细信息。 |
文件共享快照 |
ibmcloud is share-snapshots |
列出区域中可用的快照。 |
文件共享概要文件 |
ibmcloud is share-profiles |
列出区域内的所有文件共享配置文件。 只能使用 dp2 来创建文件共享。 |
安装目标 |
ibmcloud is share-mount-targets SHARE_ID |
列出文件共享的所有挂载目标。 |
子网 |
ibmcloud is subnets |
列出所有子网。 |
保留的 IP 地址 |
ibmcloud is subnet-reserved-ips |
列出子网中所有保留的 IP 地址。 |
安全组 |
ibmcloud is security-groups |
列出所有安全组。 |
从 CLI 创建没有安装目标的文件共享
您可以使用 ibmcloud is share-create
命令通过 dp2
概要文件以及特定容量和 IOPS 值在所选区域中供应文件共享。 以下示例显示如何在 us-south-2 区域中使用 1000 IOPS 创建 1000-GB 文件共享。 此文件共享是使用缺省安全组访问方式和提供者管理的加密创建的。
$ ibmcloud is share-create --name my-file-share --zone us-south-2 --profile dp2 --size 1000 --iops 1000
Creating file share my-file-share under account Test Account as user test.user@ibm.com...
ID r006-446e7246-9a7f-4585-b4fc-38b549f71ab3
Name my-file-share
CRN crn:v1:bluemix:public:is:us-south-2:a/a1234567::share:r006-446e7246-9a7f-4585-b4fc-38b549f71ab3
Lifecycle state pending
Access control mode security_group
Accessor binding role none
Allowed transit encryption modes user_managed,none
Zone us-south-2
Profile dp2
Size(GB) 1000
IOPS 1000
Encryption provider_managed
Mount Targets ID Name
No mounted targets found.
Resource group ID Name
6edefe513d934fdd872e78ee6a8e73ef defaults
Created 2025-04-18T19:18:37+00:00
Replication role none
Replication status none
Replication status reasons Status code Status message
- -
Snapshot count 0
Snapshot size 0
Source snapshot -
安全组访问方式是缺省设置和建议设置。 但是,您可以选择使用 VPC 访问方式创建文件共享,该方式允许 VPC 中的每个计算主机安装文件共享。 请参阅以下示例。
$ ibmcloud is share-create --name my-vpc-file-share --zone us-south-2 --profile dp2 --size 1000 --iops 500 --access-control-mode vpc
Creating file share my-vpc-file-share under account Test Account as user test.user@ibm.com...
ID r006-5016920c-a53a-44ad-86c3-ea0f76e88876
Name my-vpc-file-share
CRN crn:v1:bluemix:public:is:us-south-2:a/a1234567::share:r006-5016920c-a53a-44ad-86c3-ea0f76e88876
Lifecycle state pending
Access control mode vpc
Accessor binding role none
Zone us-south-2
Profile dp2
Size(GB) 1000
IOPS 500
Encryption provider_managed
Mount Targets ID Name
No mounted targets found.
Resource group ID Name
6edefe513d934fdd872e78ee6a8e73ef defaults
Created 2025-04-18T19:22:41+00:00
Replication role none
Replication status none
Replication status reasons Status code Status message
- -
Snapshot count 0
Snapshot size 0
Source snapshot -
有关命令选项的更多信息,请参阅 ibmcloud is share-create
。
从 CLI 为文件共享创建安装目标
要为文件共享创建安装目标,请运行 share-mount-target-create
命令。 在开始之前,请收集一些必要的信息。
创建安装目标时,必须指定其用于的文件共享。 您可以使用文件共享的名称或标识。 您还必须指定 VPC 及其标识或名称。 VPC 对于每个安装目标都必须是唯一的。 您还必须指定将用于管理对共享的访问权的安全访问组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。
最后,必须为为安装目标创建 虚拟网络接口 所需的选项指定值。 使用相应的 CLI 命令来列出可用的 子网,子网中的保留 IP 地址 和 安全组,以获取所需的信息。
以下示例为具有安全组访问方式的文件共享创建具有虚拟网络接口的安装目标。
$ ibmcloud is share-mount-target-create my-file-share --subnet my-subnet --name my-cli-share-mount-target-1 --vni-name my-share-vni-1 --vni-sgs my-sg --resource-group-name Default --vpc my-vpc
Mounting target for share r006-b696742a-92ee-4f6a-bfd7-921d6ddf8fa6 under account Test Account as user test.user@ibm.com...
ID r006-dd497561-c7c9-4dfb-af0a-c84eeee78b61
Name my-cli-share-mount-target-1
VPC ID Name
r006-6e8fb140-5668-45b8-b98a-d5cb0e0bf39b my-vpc
Access control mode security_group
Resource type share_mount_target
Virtual network interface ID Name
r006-13c070d8-d038-49c6-95f5-e8503c5595e3 my-share-vni-1
Lifecycle state pending
Mount path -
Transit Encryption none
以下示例为具有 VPC 访问方式的文件共享创建安装目标。
$ ibmcloud is share-mount-target-create my-vpc-file-share --vpc my-vpc --name my-vpc-mount-target
Mounting target for share r006-b1707390-3825-41eb-a5bb-1161f77f8a58 under account Test Account as user test.user@ibm.com...
ID r006-5ed68506-860e-4dea-a1eb-9634704e3c4d
Name my-vpc-mount-target
VPC ID Name
r006-6e8fb140-5668-45b8-b98a-d5cb0e0bf39b my-vpc
Access control mode vpc
Resource type share_mount_target
Lifecycle state pending
Mount path -
Transit Encryption none
Created 2023-10-18T23:09:43+00:00
有关命令选项的更多信息,请参阅 ibmcloud is share-mount-target-create
。
从 CLI 创建与安装目标的文件共享
您可以使用 ibmcloud is share-create
命令在一个步骤中创建与一个或多个安装目标的文件共享。 您需要提供区域名称,文件共享概要文件,文件共享大小和 IOPS。 您还可以指定名称,用户标记,甚至初始所有者 UID。 要创建安装目标,需要提供 JSON 格式的安装目标信息。
以下示例显示如何在 us-south-2
区域中创建具有 500 GB 容量和 2000 IOPS 的文件共享。 文件共享使用 env:dev
进行标记,并且具有安全组访问控制方式。 可以使用安装目标 my-new-mount-target
在授权虚拟服务器上安装文件共享。
$ ibmcloud is share-create --name my-new-file-share --zone us-south-2 --profile dp2 --size 500 --iops 2000 --allowed-transit-encryption-modes user_managed,none --user-tags env:dev --mount-targets '
>[{"name":"my-new-mount-target","virtual_network_interface": {"name":"my-vni","subnet": {"id":"r006-298acd6c-e71e-4204-a04f-fe4a4dd89805"}}}]'
Creating file share my-new-file-share under account Test Account as user test.user@ibm.com...
ID r006-925214bc-ded5-4626-9d8e-bc4e2e579232
Name my-new-file-share
CRN crn:v1:bluemix:public:is:us-south-2:a/a1234567::share:r006-925214bc-ded5-4626-9d8e-bc4e2e579232
Lifecycle state pending
Access control mode security_group
Accessor binding role origin
Allowed transit encryption modes user_managed,none
Zone us-south-2
Profile dp2
Size(GB) 500
IOPS 2000
User Tags env:dev
Encryption provider_managed
Mount Targets ID Name
r006-ad313f6b-ccb5-4941-a5f7-0c953f1043df my-new-mount-target
Resource group ID Name
db8e8d865a83e0aae03f25a492c5b39e Default
Created 2023-10-19T00:30:11+00:00
Replication role none
Replication status none
Replication status reasons Status code Status message
- -
以下示例创建具有 VPC 访问方式的文件共享以及可供 VPC 中的任何虚拟服务器实例使用的安装目标。
$ ibmcloud is share-create --name my-file-share-8 --zone us-south-1 --profile dp2 --size 40 --iops 2000 --user-tags env:dev --mount-targets '[{"name": "my-new-mount-target","vpc": {"name": "my-vpc"}}]'
Creating file share my-file-share-8 under account Test Account as user test.user@ibm.com...
ID r006-95ec87ba-c5fd-4178-a114-2a55c4d907d4
Name my-file-share-8
CRN crn:v1:bluemix:public:is:us-south-1:a/a1234567::share:r006-95ec87ba-c5fd-4178-a114-2a55c4d907d4
Lifecycle state pending
Access control mode vpc
Accessor binding role none
Zone us-south-1
Profile dp2
Size(GB) 40
IOPS 2000
User Tags env:dev
Encryption provider_managed
Mount Targets ID Name
r006-8b917757-ad19-4bec-8417-83157b047cea my-new-mount-target
Resource group ID Name
6edefe513d934fdd872e78ee6a8e73ef defaults
Created 2025-04-18T19:36:35+00:00
Replication role none
Replication status none
Replication status reasons Status code Status message
- -
Snapshot count 0
Snapshot size 0
Source snapshot -
通过 CLI 使用客户管理的加密创建文件共享
缺省情况下,File Storage for VPC 共享使用 IBM管理的加密进行加密。 但是,您还可以使用其中一个受支持的密钥管理服务来创建或导入自己的根密钥,从而为文件共享创建包络加密。 有关更多信息,请参阅 使用包络加密保护数据
有关如何使用客户管理的加密创建文件共享的更多信息,请参阅 使用客户管理的加密创建文件共享。
通过 CLI 从快照创建文件共享
您可以使用文件共享快照在同一区域创建另一个文件共享。 要根据快照创建文件共享,请运行 ibmcloud is share-create
命令。
您可以指定快照的名称、ID 或 CRN。 如果选择指定快照的名称,还需要指定快照所属文件共享的名称或 ID。 快照名称在文件共享级别必须是唯一的,但另一个文件共享可以有相同名称的快照。
ibmcloud is share-create --snapshot r026-7647ba64-9728-4bb4-be2f-d958f738fdae
有关如何从快照创建文件共享的详细信息及其他示例,请参阅 从文件共享快照恢复数据。
使用 CLI 创建文件共享时添加补充 ID
通过 CLI,您可以为 --initial-owner-uid
和 --initial-owner-gid
属性设置 UID
和 GID
值,以控制对文件共享的访问。 无论您在何处安装文件共享,根文件夹都会使用该用户标识和组标识所有者。 创建共享时,您可以设置 UID
或 GID
,或两者都设置。
如果从虚拟服务器实例更改补充标识 (UID 或 GID),那么无法确定其是否已更改。 因此,initial_owner
只在文件存储系统中发生变化,但变化不会反映在 CLI 或 API 响应中。
表 1 显示了可以设置的 UID 和 GID 值以及保留的值。
Unix/Linux® supplemental ID values.
标识值 |
描述 |
UID |
|
UID 0 |
保留用于 root 用户。 |
UID 1-99 |
保留用于预定义帐户。 |
UID 100-999 |
由系统为管理系统帐户和组保留。 |
UID 1000-10000 |
由应用程序帐户使用。 |
UID 10000 + |
可用于用户帐户。 |
GID |
|
GID 0 |
保留用于 root 用户。 |
GID 1-99 |
保留供系统和应用程序使用。 |
100 + GID |
已分配给用户的组。 |
要在创建共享时设置补充 ID,请运行 ibmcloud is share-create
命令,并用补充 ID 指定 --initial-owner-gid
和 --initial-owner-gid
属性。 请参阅以下示例。
$ ibmcloud is share-create --name my-file-share --zone us-south-2 --profile dp2 --size 1000 --iops 1000 --initial-owner-gid 101 --initial-owner-uid 10001
Creating file share my-file-share under account Test Account as user test.user@ibm.com...
ID r006-1579b805-1b6f-4a2e-be9b-e0041ef018c9
Name my-file-share
CRN crn:v1:bluemix:public:is:us-south-2:a/a123456::share:r006-1579b805-1b6f-4a2e-be9b-e0041ef018c9
Lifecycle state pending
Access control mode security_group
Accessor binding role none
Allowed transit encryption modes user_managed,none
Zone us-south-2
Profile dp2
Size(GB) 1000
IOPS 1000
Encryption provider_managed
Mount Targets ID Name
No mounted targets found.
Resource group ID Name
6edefe513d934fdd872e78ee6a8e73ef defaults
Created 2024-12-04T22:35:22+00:00
Replication role none
Replication status none
Replication status reasons Status code Status message
- -
Snapshot count 0
Snapshot size 0
创建与 API 的文件共享
您可以通过直接调用 REST API 来创建文件共享和安装目标。
准备工作
设置 API 环境 定义 IAM 令牌、API 端点和 API 版本的变量。 有关指示信息,请参阅设置 API 和 CLI 环境。
必须提供 generation
参数并指定 generation=2
。 有关详细信息,请参阅 虚拟私有云 API 参考资料 中的生成。
要了解有关 API 的更多信息,一个好办法是在 IBM Cloud 控制台中的供应页面上单击获取样本 API 调用。 您可以查看正确的 API 请求序列,并更好地了解操作及其依赖项。
创建与 API 的文件共享
发出 POST /shares
请求以创建文件共享。 指定文件共享,名称,IOPS 概要文件和区域的大小。 如果希望创建具有细粒度访问授权的文件共享,请指定 "security_group
为访问模式。 具有安全组访问模式的共享也可配置为支持传输中加密、跨区挂载、快照和备份。 请参阅以下示例。
curl -X POST \
"$vpc_api_endpoint/v1/shares?version=2024-05-06&generation=2"\
-H "Authorization: $iam_token" \
-d '{
"access_control_mode": "security-group",
"allowed_transit_encryption_modes": ["none", "user-managed"],
"size": 4800,
"iops": 3000,
"name": "myshare-1",
"profile": {"name": "dp2"},
"zone": {"name": "us-south-1"}
}
确保在创建挂载目标时,还指定了一个虚拟网络接口,该接口是虚拟服务器实例所属安全组的成员。
下面的示例显示了创建 4800 GB 文件共享的请求。 它指定访问控制方式 vpc
,这使每个安装目标的 VPC 中的所有客户机都能够访问此文件共享。 该选项安全性较低,而且不支持更新的功能。
curl -X POST \
"$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token" \
-d '{
"size": 4800,
"iops": 3000,
"name": "myshare-1",
"profile": {"name": "dp2"},
"access_control_mode": "vpc",
"zone": {"name": "us-south-1"}
}'
成功回复的示例如下
{
"access_control_mode": "vpc",
"created_at": "2023-08-08T22:31:50Z",
"crn": "crn:[...]",
"encryption": "provider_managed",
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/acd96d70-b8d3-4b56-ad7f-9c1035df93b2",
"id": "acd96d70-b8d3-4b56-ad7f-9c1035df93b2",
"initial_owner": {
"gid": 0,
"uid": 0
},
"iops": 3000,
"lifecycle_state": "pending",
"name": "myshare-1",
"profile": {
"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
"name": "dp2",
"resource_type": "share_profile"
},
"replication_role": "none",
"replication_status": "none",
"replication_status_reasons": [],
"resource_group": {
"crn": "crn:v1:public:resource-controller::a/e2f80b84-bc75-4f53-8737-8193ef1d1a7b::resource-group:e96d1fa9-76f2-4c87-a737-dbab3a947b24",
"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/e96d1fa9-76f2-4c87-a737-dbab3a947b24",
"id": "e96d1fa9-76f2-4c87-a737-dbab3a947b24",
"name": "Default"
},
"resource_type": "share",
"size": 4800,
"mount_targets": [],
"zone": {
"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
"name": "us-south-1"
}
}
使用 API 为文件共享创建安装目标
此请求将创建安装目标或将安装目标添加到现有文件共享。 在此示例中,指定了 vpc
属性,因为文件共享的访问控制方式为 vpc
。 无法启用传输中的数据加密。
安装目标和共享的访问控制方式必须匹配。 两者都必须是 vpc
或 security_group
。 使用 security_group
访问方式创建安装目标时,请注意共享的 allowed_transit_encryption_modes
。 transit_encryption
值必须反映共享所允许的内容。
curl -X POST \
"$vpc_api_endpoint/v1/shares/$share_id/mount_targets?version=2023-08-08&generation=2"\
-H "Authorization: Bearer $iam_token"\
-H 'Content-Type: application/json'\
-d '{
"access_control_mode": "vpc"
"name": "mount-target-name1",
"vpc": {"id": "6e01bc24-4a6e-4a0c-a1bd-4caa0c8159e7"},
"transit_encryption": "none"
}'
成功回复的示例如下
{
"access_control_mode": "vpc",
"created_at": "2023-08-08T23:31:59Z",
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/ff859972-8c39-4528-91df-eb9160eae918/mount_targets/9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
"id": "9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
"lifecycle_state": "pending",
"mount_path": "domain.com:/vol_xyz_2891fd0a_63aa_4deb_9ed5_1159e37cb5aa",
"name": "mount-target-name1",
"resource_type": "share_target",
"transit_encryption": "none",
"vpc": {
"crn": "crn:[...]",
"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/e6ff7b61-feb4-4c87-94aa-277d6f93e164",
"id": "e6ff7b61-feb4-4c87-94aa-277d6f93e164",
"name": "vpc-name1",
"resource_type": "vpc"
}
}
通过指定子网和安全组将安装目标添加到现有文件共享
发出 POST /shares/{share_id}/mount_targets
请求并指定安装目标网络接口的子网和安全组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。
此示例将安装目标添加到现有文件共享 (由标识标识),并提供子网和安全组以定义网络接口。
curl -X POST "$vpc_api_endpoint/v1/shares/f1ab81ef-dd30-459a-85e0-9094164978b1/mount_targets/?version=2023-07=18&generation=2"\
-d '{
"virtual_network_interface": {
"subnet": {"id": "1a0b3d75-8a62-4c78-9263-f9bcd25a8759"},
"security_groups": [{"id": "b2599112-7027-480e-ad1b-fd917d2fcb84"}]
},
"transit_encryption": "user_managed"
}'
使用 API 创建文件共享和安装目标
以下示例请求将创建一个文件共享,该文件共享具有 VPC 范围的访问方式以及可供指定 VPC 中的每个虚拟服务器实例使用的安装目标。 它还将 用户标记 添加到共享。
对安装目标的访问是 VPC 范围的; VPC 中的所有实例都有权访问此文件共享。 不支持跨区安装和传输中数据加密等新功能。
curl -X POST \
"$vpc_api_endpoint/v1/shares?version=2025-04-08&generation=2\
-H "Authorization: Bearer $iam_token"\
-H 'Content-Type: application/json'\
-d '{
"access_control_mode": "vpc",
"size": 4800,
"iops": 48000,
"mount_targets": [
{
"name": "mount-target-name1",
"vpc": {"id": "a1fb6c4f-6a63-4d34-8bf6-55fab89e932a"}
}
],
"name": "share-name1",
"profile": {"name": "dp2"},
"user_tags": [
"env:test",
"env:prod"
],
"resource_group": {},
"zone": {"name": "us-south-1"}
}'
成功回复的示例如下
{
"access_control_mode": "vpc",
"allowed_transit_encryption_modes": "none",
"created_at": "2025-04-08T23:31:59Z",
"crn": "crn:[...]",
"encryption": "provider_managed",
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/ff859972-8c39-4528-91df-eb9160eae918",
"id": "ff859972-8c39-4528-91df-eb9160eae918",
"iops": 48000,
"lifecycle_state": "stable",
"name": "share-name1",
"profile": {
"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
"name": "dp2",
"resource_type": "share_profile"
},
"replication_role": "none",
"replication_status": "none",
"replication_status_reasons": [],
"resource_group": {
"crn": "crn:[...]",
"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/6b45d0aa-e0a6-478b-a5d9-bb45b106676d",
"id": "6b45d0aa-e0a6-478b-a5d9-bb45b106676d",
"name": "Default"
},
"resource_type": "share",
"size": 4800,
"mount_targets": [
{
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/ff859972-8c39-4528-91df-eb9160eae918/mount_targets/9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
"id": "9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
"name": "mount-target-name1",
"resource_type": "share_target",
"vpc": {
"crn": "crn:[...]",
"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/e6ff7b61-feb4-4c87-94aa-277d6f93e164",
"id": "e6ff7b61-feb4-4c87-94aa-277d6f93e164",
"name": "vpc-name1",
"resource_type": "vpc"
}
}
],
"user_tags": ["env:test","env:prod"],
"zone": {
"href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
"name": "us-south-1"
}
}
通过指定子网来创建文件共享和安装目标
文件共享的缺省访问控制方式为 security_group
。 它比全 vpc 选项更安全,而且支持更新的功能。 要在创建文件共享的同时使用网络接口创建挂载目标,请发出 "POST /shares
请求并指定子网。 如果不指定 虚拟网络接口,则需要指定 "subnet
属性。
下面的示例创建了一个 虚拟网络接口,并将其附加到挂载目标上,同时保留了一个 IP 地址,并应用了所选安全组的规则。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。
在此示例中,安装目标部分指定子网标识。 创建安装目标时,系统将从该子网中为 虚拟网络接口 选择保留 IP。
curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token"\
-d '{
"allowed_transit_encryption_modes": ["user-managed"],
"size": 10,
"name": "my-share-1",
"profile": {"name": "dp2"},
"zone": {"name": "us-south-1"},
"mount_targets": [{
"virtual_network_interface": {"subnet": {"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde"}},
"transit_encryption": {"user_managed"}}]
}'
当 transit_encryption
属性设置为 user_managed
时,将使用实例身份证书启用传输中的加密。 transit_encryption
属性的默认值为 "none
,即在传输过程中禁用加密。 但是,如果将“allowed_transit_encryption_modes
指定为”user-managed
,则挂载目标必须将“user_managed
作为”transit_encryption
的值。
成功回复的示例如下
{
"access_control_mode": "security_group",
"allowed_transit_encryption_modes": ["user-managed"],
"created_at": "2023-08-08T12:15:12Z",
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/90c4bb62-1724-47bd-8c45-f7d37d7c3508/mount_targets/7e5bdb52-676d-43b2-991f-2053cf6855eb",
"id": "7e5bdb52-676d-43b2-991f-2053cf6855eb",
"lifecycle_state": "pending",
"mount_path": "",
"name": "myshare-1",
"primary_ip": {"address": ""},
"resource_type": "share_target",
"snapshot_count": 10,
"snapshot_size": 10,
"subnet": {
"crn": "crn:[...]",
"href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/4e95744c-7e64-48c9-b5d2-3b6481b1dfde",
"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde",
"name": "subnet-2",
"resource_type": "subnet"
},
"transit_encryption": "user-managed",
"virtual_network_interface": {
"crn": "crn:[...]",
"href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interface/710y-b8aa945c-7eac-4c15-bad6-a56db9d1e9bd",
"id": "710y-b8aa945c-7eac-4c15-bad6-a56db9d1e9bd",
"name": "enlace-traverse-oat-console",
"resource_type": "VirtualNetworkInterface"
},
"vpc": {
"crn": "crn:[...]",
"href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/82fa21ae-a645-4dd5-9136-d48a723bf00e",
"id": "82fa21ae-a645-4dd5-9136-d48a723bf00e",
"name": "my-vpc-2",
"resource_type": "vpc"
},
"user_tags": []
}
通过指定子网和安全组来创建文件共享和安装目标
要创建安装目标网络接口,请发出 POST /shares
请求并指定子网和安全组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。
在此示例中,mount_targets
属性指定子网标识和安全组标识。 当 transit_encryption
属性设置为 user_managed
时,它将通过使用实例身份证书来启用传输中的加密。 缺省值为 none,这将禁用传输中的加密。
curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token" \
-d '{
"size": 20,
"iops": 100,
"name": "myshare-3",
"profile": {"name": "dp2"},
"zone": {"name": "us-south-1"},
"allowed_transit_encryption_modes": ["user-managed"],
"mount_targets": [{
"virtual_network_interface": {
"subnet": {"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde"},
"security_groups": [{"id": "34c09abb-37bf-4ef6-88bb-f63a0ef28915"}]
},
"transit_encryption": {"user_managed"}}
]
}'
以下响应显示访问控制方式为 security_group
,这是缺省值。
{
"access_control_mode": "security_group",
"allowed_transit_encryption_modes": ["user-managed"],
"created_at": "2023-08-08T12:55:40Z",
"crn": "crn:[...]",
"encryption": "provider_managed",
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/r006-56f91d4a-2801-470a-b368-176bde64e954",
"id": "r006-56f91d4a-2801-470a-b368-176bde64e954",
"initial_owner": {
"gid": 0,
"uid": 0
},
"iops": 100,
"lifecycle_state": "pending",
"name": "myshare-3",
"mount_targets": [
{
"href": "https://us-south.iaas.cloud.ibm.com/v1/shares/r006-56f91d4a-2801-470a-b368-176bde64e954/mount_targets/r006-b8573e2c-60ee-4ecc-9eae-c52f890a8195",
"id": "r006-b8573e2c-60ee-4ecc-9eae-c52f890a8195",
"name": "sticky-idealist-spoiled-sloppily",
"resource_type": "share_target",
"transit_encryption": {"user_managed"}
}
],
"profile": {
"href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
"name": "dp2",
"resource_type": "share_profile"
},
"replication_role": "none",
"replication_status": "none",
"replication_status_reasons": [],
"resource_group": {
"crn": "crn:[...]",
"href": "https://resource-controller.cloud.ibm.com/v2/resource_groups//678523bcbe2b4eada913d32640909956",
"id": "678523bcbe2b4eada913d32640909956",
"name": "Default"
},
"resource_type": "share",
"size": 20,
"snapshot_count": 10,
"snapshot_size": 10,
"user_tags": [],
"zone": {
"href": "https://us-south.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
"name": "us-south-1"
}
}
通过指定虚拟网络接口来创建文件共享和安装目标
要执行此操作,您必须已经拥有一个 虚拟网络接口,且该虚拟网络接口不得连接到其他资源。
发出 POST /shares
请求并使用虚拟网络接口创建安装目标。 在挂载目标的 "virtual_network_interface
属性中指定未连接虚拟网络接口的 ID。
curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2" \
-H "Authorization: $iam_token" \
-d '{
"size": 10,
"name": "my-share-sc-2",
"profile": {"name": "dp2"},
"zone": {"name": "us-south-3"},
"allowed_transit_encryption_modes": ["none"],
"mount_targets": [{
"name": "mount-target-1",
"transit_encryption": {"none"},
"virtual_network_interface": {"id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9"}
}]
}'
使用 API 创建文件共享时添加补充标识
通过该 API,您可以为 initial_owner
属性设置 UID
和 GID
值,以控制对文件共享的访问。 无论您在何处安装文件共享,根文件夹都会使用该用户标识和组标识所有者。 在 POST /shares
调用中创建共享时设置 UID
和/或 GID
。
如果从虚拟服务器实例更改补充标识 (UID 或 GID),那么无法确定其是否已更改。 因此,initial_owner
不会在 API 数据库中进行更改,而是仅在文件存储系统中进行更改。
表 1 显示了可以设置的 UID 和 GID 值以及保留的值。
Unix/Linux® supplemental ID values.
标识值 |
描述 |
UID |
|
UID 0 |
保留用于 root 用户。 |
UID 1-99 |
保留用于预定义帐户。 |
UID 100-999 |
由系统为管理系统帐户和组保留。 |
UID 1000-10000 |
由应用程序帐户使用。 |
UID 10000 + |
可用于用户帐户。 |
GID |
|
GID 0 |
保留用于 root 用户。 |
GID 1-99 |
保留供系统和应用程序使用。 |
100 + GID |
已分配给用户的组。 |
要在创建共享时设置补充标识,请发出 POST /shares
调用并使用补充标识指定 initial_owner
属性。 请参阅以下示例。
curl -X POST \
"$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token" \
-d '{
"initial_owner": {"gid": 101,"uid": 10001},
"size": 4800,
"name": "share-name",
"profile": {"name": "dp2"},
"zone": {"name": "us-south-1"}
.
.
.
}'