Amazon S3 檔案閘道文件已移至什麼是 Amazon S3 檔案閘道?
Amazon FSx 檔案閘道文件已移至什麼是 Amazon FSx 檔案閘道?
磁碟區閘道文件已移至什麼是磁碟區閘道?
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
取得您閘道的啟用金鑰
若要取得您閘道的啟用金鑰,您必須向閘道 VM 傳送 Web 請求,便會傳回包含啟用金鑰的重新導向。此啟用金鑰會做為其中一項參數傳遞到 ActivateGateway
API 動作,指定您閘道的組態。如需詳細資訊,請參閱 ActivateGatewayS torage Gateway API 參考中的。
您對閘道虛擬機器發出的要求包含啟用發生的AWS區域。重新導向在回應中傳回的 URL 會包含稱為 activationkey
的查詢字串參數。此查詢字串參數便是您的啟用金鑰。查詢字串的格式如下:
http://
。gateway_ip_address
/?activationRegion=activation_region
重新導向傳回的 URL 也包含下列查詢字串參數:
-
gatewayType
-接收要求的閘道類型 -
endpointType
-閘道用來連線的端點類型AWS -
vpcEndpoint
-使用 VPC 端點類型連線之閘道的 VPC 端點識別碼
Storage Gateway 硬體設備、VM 映像範本和 EC2 AMI 已預先設定好接收和回應本頁所述 Web 要求所需的 HTTP 服務。您不需要或建議您在閘道上安裝任何其他服務。
AWS CLI
若您尚未執行此作業,您必須安裝及設定 AWS CLI。若要執行此作業,請遵循AWS Command Line Interface 使用者指南中的這些說明:
下列範例說明如何使用擷AWS CLI取 HTTP 回應、剖析 HTTP 標頭以及取得啟動金鑰。
wget '
ec2_instance_ip_address
/?activationRegion=eu-west-2
' 2>&1 | \ grep -i location | \ grep -oE 'activationKey=[A-Z0-9-]+' | \ pipe pipe pipe> cut -f2 -d=
卷曲
下列範例顯示如何使用 Linux (curl) 取得啟用金鑰。
以適用於閘道的實際值。可接受的值如下:
-
閘道位址-
例如,閘道器的 IPv4 位址172.31.29.201
-
閘道類型
-您要啟動的閘道類型,例如STORED
CACHED
、VTL
、VTL_SNOW
、FILE_S3
、或FILE_FSX_SMB
。 -
區域代碼
-您要在其中啟用閘道的區域。請參閱《AWS一般參考指南》中的區域端點。 -
vpc_端點/端點
-例如,閘道的虛擬私人雲端端點名稱vpce-050f90485f28f2fd0-iep0e8vq.storagegateway.us-west-2.vpce.amazonaws.com
。
若要取得公用端點的啟動金鑰:
curl "http://
gateway_ip_address
/?gatewayType=gateway_type
&activationRegion=region_code
&no_redirect"
若要取得 VPC 端點的啟動金鑰:
curl "http://
gateway_ip_address
/?gatewayType=gateway_type
&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" ]]; then echo "Usage: get-activation-key ip_address activation_region" return 1 fi if redirect_url=$(curl -f -s -S -w '%{redirect_url}' "http://$ip_address/?activationRegion=$activation_region"); 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 Windows Windows Windows PowerShell
下列範例說明如何使用微軟視窗擷 PowerShell 取 HTTP 回應、剖析 HTTP 標頭,以及取得啟用金鑰。
若要啟用檔案閘道,虛擬機器無需具有連接埠 80 的存取權。
function Get-ActivationKey { [CmdletBinding()] Param( [parameter(Mandatory=$true)][string]$IpAddress, [parameter(Mandatory=$true)][string]$ActivationRegion ) PROCESS { $request = Invoke-WebRequest -UseBasicParsing -Uri "http://$IpAddress/?activationRegion=$ActivationRegion" -MaximumRedirection 0 -ErrorAction SilentlyContinue if ($request) { $activationKeyParam = $request.Headers.Location | Select-String -Pattern "activationKey=([A-Z0-9-]+)" $activationKeyParam.Matches.Value.Split("=")[1] } } }