本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
取得閘道的啟用金鑰
若要接收閘道的啟用金鑰,請向閘道虛擬機器 (VM) 發出網頁請求。虛擬機器會傳回包含啟用金鑰的重新導向,該重新導向會當做 ActivateGateway
API 動作的其中一個參數傳遞,以指定閘道的組態。如需詳細資訊,請參閱 Storage Gateway API 參考資料中的 ActivateGateway。
注意
如果未使用,閘道啟用金鑰會在 30 分鐘內過期。
您對閘道 VM 提出的請求包含進行啟用 AWS 的區域。重新導向在回應中傳回的 URL 會包含稱為 activationkey
的查詢字串參數。此查詢字串參數便是您的啟用金鑰。查詢字串的格式如下:http://
。此查詢的輸出傳回啟用區域和金鑰。gateway_ip_address
/?activationRegion=activation_region
此 URL 也包含 vpcEndpoint
使用 VPC 端點類型連線之閘道的 VPC 端點識別碼。
注意
AWS Storage Gateway硬體設備、VM 映像範本和 Amazon EC2 Amazon Machine Image (AMI) 已預先設定 HTTP 服務,以接收和回應此頁面所述的 Web 請求。您不需要或建議您在閘道上安裝任何其他服務。
Linux (curl)
以下範例顯示如何使用 Linux (curl) 取得啟用金鑰。
注意
將反白顯示的變數取代為閘道的實際值。可接受的值如下:
-
gateway_ip_address
:例如,閘道器的 IPV4 地址172.31.29.201
-
gateway_type
- 您要啟用的閘道類型,例如STORED
、CACHED
、FILE_S3
、VTL
或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 }
Microsoft 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 電腦連線到您的 Amazon EC2 執行個體,請以 admin 身分登入。
-
登入並查看 AWS 設備啟用 - 設定主功能表後,選取
0
以選擇取得啟用金鑰。 -
為閘道系列選項選取 Storage Gateway。
-
出現提示時,輸入您要啟用閘道 AWS 的區域。
-
輸入
1
公用端點或2
VPC 端點做為網路類型。 -
輸入
1
標準或2
美國聯邦資訊處理標準 (FIPS) 做為端點類型。