本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
要接收网关的激活密钥,请向网关虚拟机 (VM) 发出 Web 请求。VM 返回包含激活密钥的重定向,激活密钥作为 ActivateGateway
API 操作的参数之一传递,用于指定网关的配置。有关更多信息,请参阅 Storage Gateway API 参考ActivateGateway中的。
注意
如果未使用,网关激活密钥将在 30 分钟后过期。
您向网关 VM 发出的请求包括激活发生的 AWS 区域。响应中重定向返回的 URL 包含称为 activationkey
的查询字符串参数。此查询字符串参数是您的激活密钥。此查询字符串的格式如下所示:http://
。此查询的输出会返回激活区域和密钥。gateway_ip_address
/?activationRegion=activation_region
URL 还包括 vpcEndpoint
,即使用 VPC 端点类型连接的网关的 VPC 端点 ID。
注意
Storage Gateway 硬件设备、虚拟机映像模板和 EC2 亚马逊系统映像 (AMI) 已预先配置了接收和响应本页所述网络请求所需的 HTTP 服务。不要求也不建议在网关上安装任何其他服务。
Linux (curl)
以下示例向您显示如何使用 Linux (curl) 获取激活密钥。
注意
将突出显示的变量替换为您的网关的实际值。可接受的值如下所示:
-
gateway_ip_address
-您的网关 IPv4 地址,例如172.31.29.201
-
gateway_type
-您要激活的网关类型,例如STORED
CACHED
、VTL
、FILE_S3
、或FILE_FSX_SMB
。 -
region_code
-您要激活网关的区域。请参阅《AWS 一般参考指南》中的区域端点。如果未指定此参数,或者提供的值拼写错误或与有效区域不匹配,则该命令将默认为us-east-1
区域。 -
vpc_endpoint
-例如,您的网关的 VPC 终端节点名称vpce-050f90485f28f2fd0-iep0e8vq.storagegateway.us-west-2.vpce.amazonaws.com
。
要获取公有端点的激活密钥,请执行以下操作:
curl "http://
gateway_ip_address
/?activationRegion=region_code
&no_redirect"
要获取 VPC 端点的激活密钥,请执行以下操作:
curl "http://
gateway_ip_address
/?activationRegion=region_code
&vpcEndpoint=vpc_endpoint
&no_redirect"
Linux (bash/zsh)
以下示例显示如何使用 Linux (bash/zsh) 获取 HTTP 响应、分析 HTTP 标头以及获取激活密钥。
function get-activation-key() {
local ip_address=$1
local activation_region=$2
if [[ -z "$ip_address" || -z "$activation_region" || -z "$gateway_type" ]]; then
echo "Usage: get-activation-key ip_address activation_region gateway_type"
return 1
fi
if redirect_url=$(curl -f -s -S -w '%{redirect_url}' "http://$ip_address/?activationRegion=$activation_region&gatewayType=$gateway_type"); then
activation_key_param=$(echo "$redirect_url" | grep -oE 'activationKey=[A-Z0-9-]+')
echo "$activation_key_param" | cut -f2 -d=
else
return 1
fi
}
微软 Windows PowerShell
以下示例向您展示了如何使用 Microsoft Windows PowerShell 获取 HTTP 响应、解析 HTTP 标头和获取激活密钥。
function Get-ActivationKey {
[CmdletBinding()]
Param(
[parameter(Mandatory=$true)][string]$IpAddress,
[parameter(Mandatory=$true)][string]$ActivationRegion,
[parameter(Mandatory=$true)][string]$GatewayType
)
PROCESS {
$request = Invoke-WebRequest -UseBasicParsing -Uri "http://$IpAddress/?activationRegion=$ActivationRegion&gatewayType=$GatewayType" -MaximumRedirection 0 -ErrorAction SilentlyContinue
if ($request) {
$activationKeyParam = $request.Headers.Location | Select-String -Pattern "activationKey=([A-Z0-9-]+)"
$activationKeyParam.Matches.Value.Split("=")[1]
}
}
}
使用本地控制台
以下示例显示了如何使用本地控制台来生成和显示激活密钥。
从本地控制台获取网关的激活密钥
-
登录到本地控制台。如果您是从 Windows 计算机连接到您的亚马逊 EC2 实例,请以管理员身份登录。
-
登录并查看 AWS 设备激活 - 配置主菜单后,选择
0
来选择获取激活密钥。 -
选择 Storage Gateway 作为网关系列选项。
-
出现提示时,输入要激活网关的 AWS 区域。
-
对于公有端点,输入
1
,或对于 VPC 端点,输入2
作为网络类型。 -
对于标准端点,输入
1
,或对于美国联邦信息处理标准 (FIPS) 端点,输入2
作为端点类型。