使用 Neptune-Export 服務匯出 Neptune 資料 - Amazon Neptune

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Neptune-Export 服務匯出 Neptune 資料

您可以使用以下步驟,來使用 Neptune-Export 服務,將資料從 Neptune 資料庫叢集匯出至 Amazon S3:

安裝 Neptune-Export 服務

使用 AWS CloudFormation 範本建立堆疊:

安裝 Neptune-Export 服務
  1. 在 AWS CloudFormation 主控台啟動 AWS CloudFormation 堆疊,方法是在下表中選擇其中一個啟動堆疊按鈕。

    區域 檢視 在設計工具中檢視 啟動
    美國東部 (維吉尼亞北部) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    美國東部 (俄亥俄) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    美國西部 (加利佛尼亞北部) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    美國西部 (奧勒岡) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    加拿大 (中部) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    南美洲 (聖保羅) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    歐洲 (斯德哥爾摩) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    歐洲 (愛爾蘭) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    歐洲 (倫敦) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    歐洲 (巴黎) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    歐洲 (法蘭克福) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    中東 (巴林) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    中東 (阿拉伯聯合大公國) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    以色列 (特拉維夫) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    非洲 (開普敦) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    亞太區域 (香港) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    亞太區域 (東京) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    亞太區域 (首爾) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    亞太區域 (新加坡) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    亞太區域 (雪梨) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    亞太區域 (孟買) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    中國 (北京) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    中國 (寧夏) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    AWS GovCloud (美國西部) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
    AWS GovCloud (美國東部) 檢視 在設計工具中檢視 Orange button labeled "Launch Stack" with an arrow icon.
  2. Select Template (選取範本) 頁面上,請選擇 Next (下一步)。

  3. 指定詳細資訊頁面上,設定下列參數。

    • VPC – 設定 Neptune-Export 服務的最簡單方法是將其安裝在與 Neptune 資料庫相同的 Amazon VPC 中。如果要將其安裝在個別的 VPC 中,您可以使用 VPC 對等互連,在 Neptune 資料庫叢集的 VPC 與 Neptune-Export 服務 VPC 之間建立連線。

    • Subnet1 – Neptune-Export 服務必須安裝在 VPC 中的子網路中,該子網路允許從子網路到網際網路的傳出 IPv4 HTTPS 流量。這樣,Neptune-Export 服務可以呼叫 AWS 批次 API,來建立和執行匯出工作。

      如果已使用 Neptune 文件中 建立資料庫叢集 頁面上的 CloudFormation 範本,建立了 Neptune 叢集,則您可以使用來自該堆疊的 PrivateSubnet1PrivateSubnet2 輸出,來填入此參數和下一個參數。

    • Subnet2 – VPC 中的第二個子網路,其允許從子網路到網際網路的傳出 IPv4 HTTPS 流量。

    • EnableIAM – 將其設為 true,以使用 AWS Identity and Access Management (IAM) 保護 Neptune-Endpoint API。建議您這樣做。

      如果您確實啟用 IAM 身分驗證,則必須以 Sigv4 簽署對端點的所有 HTTPS 請求。您可以使用 awscurl 等工具代表您簽署請求。

    • VPCOnly – 將其設為 true,使匯出端點成為唯一 VPC,以便您只能從安裝 Neptune-Export 服務的 VPC 內存取它。這會限制 Neptune-Export API 只能從該 VPC 內使用。

      建議您將 VPCOnly 設定為 true

    • NumOfFilesULimit – 在 ulimits 容器屬性中,為 nofile 指定介於 10,000 與 1,000,000 之間的值。預設值為 10,000,除非您的圖形包含大量的唯一標籤,否則我們建議您保留預設值。

    • PrivateDnsEnabled (布林值) – 指示是否要將私有託管區域與指定的 VPC 建立關聯。預設值為 true

      在啟用此旗標的情況下建立 VPC 端點時,所有 API Gateway 流量都會透過 VPC 端點路由傳送,且公用 API Gateway 端點呼叫會變成停用狀態。如果將 PrivateDnsEnabled 設為 false,則會啟用公用 API Gateway 端點,但 Neptune 匯出服務無法透過私有 DNS 端點連線。然後,您可以使用 VPC 端點的公用 DNS 端點呼叫匯出服務,如這裡所述。

  4. 選擇 Next (下一步)

  5. Options (選項) 頁面上,選擇 Next (下一步)。

  6. 檢閱頁面上,選取第一個核取方塊以確認 AWS CloudFormation 將建立 IAM 資源。選取第二個核取方塊,確認新堆疊 CAPABILITY_AUTO_EXPAND

    注意

    CAPABILITY_AUTO_EXPAND 明確確認在建立堆疊時,無需事先檢閱,即可擴充巨集。使用者通常會在處理過的範本中建立變更集,以便在實際建立堆疊之前,檢閱巨集所做的變更。如需詳細資訊,請參閱 AWS CloudFormationCreateStack API。

    然後選擇 Create (建立)

啟用從 Neptune-Export 存取 Neptune

Neptune-Export 安裝完成後,更新您的 Neptune VPC 安全群組,以允許從 Neptune-Export 存取。建立 Neptune-Export AWS CloudFormation 堆疊後,輸出索引標籤會包含 NeptuneExportSecurityGroup ID。更新您的 Neptune VPC 安全群組,以允許從這個 Neptune-Export 安全群組存取。

啟用從 VPC 型 EC2 執行個體存取 Neptune-Export 端點

如果您讓 Neptune-Export 端點成為唯一 VPC,則只能從安裝 Neptune-Export 服務的 VPC 內存取它。若要在您可以從中進行 Neptune-Export API 呼叫的 VPC 中,允許來自 Amazon EC2 執行個體的連線,請將 AWS CloudFormation 堆疊建立的 NeptuneExportSecurityGroup 附加至該 Amazon EC2 執行個體。

使用 Neptune-Export API 執行 Neptune-Export 工作

AWS CloudFormation 堆疊的輸出索引標籤也包含 NeptuneExportApiUri。每當您將請求傳送到 Neptune-Export 端點時,請使用此 URI。

執行匯出工作
  • 請確定匯出執行所在的使用者或角色已獲授與 execute-api:Invoke 許可。

  • 如果在安裝 Neptune-Export 時,於 AWS CloudFormation 堆疊中將 EnableIAM 參數設為 true,則您需要以 Sigv4 簽署對 Neptune-Export API 的所有請求。我們建議您使用 awscurl 向 API 提出請求。這裡的所有範例都假設 IAM 身分驗證已啟用。

  • 如果在安裝 Neptune-Export 時,於 AWS CloudFormation 堆疊中將 VPCOnly 參數設為 true,則必須從 VPC 內呼叫 Neptune-Export API,通常從位於 VPC 的 Amazon EC2 執行個體進行此呼叫。

若要開始匯出資料,請使用 commandoutputS3Path 請求參數以及 endpoint 匯出參數,將請求傳送至 NeptuneExportApiUri 端點。

以下是請求範例,其會從 Neptune 匯出屬性圖資料,並將其發佈至 Amazon S3:

curl \ (your NeptuneExportApiUri) \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "command": "export-pg", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)" } }'

同樣地,以下是將 RDF 資料從 Neptune 匯出至 Amazon S3 的請求範例:

curl \ (your NeptuneExportApiUri) \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "command": "export-rdf", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)" } }'

如果您省略了 command 請求參數,根據預設,Neptune-Export 會嘗試從 Neptune 匯出屬性圖資料。

如果上一個命令執行成功,輸出將如下所示:

{ "jobName": "neptune-export-abc12345-1589808577790", "jobId": "c86258f7-a9c9-4f8c-8f4c-bbfe76d51c8f" }

監控您剛開始的匯出工作

若要監控執行中工作,請將其 jobID 附加到您的 NeptuneExportApiUri,如下所示:

curl \ (your NeptuneExportApiUri)(the job ID)

如果服務尚未啟動匯出工作,回應將如下所示:

{ "jobId": "c86258f7-a9c9-4f8c-8f4c-bbfe76d51c8f", "status": "pending" }

當您在匯出工作開始之後重複此命令時,回應會如下所示:

{ "jobId": "c86258f7-a9c9-4f8c-8f4c-bbfe76d51c8f", "status": "running", "logs": "https://us-east-1.console.aws.amazon.com/cloudwatch/home?..." }

如果您使用狀態呼叫所提供的 URI 開啟 CloudWatch Logs 中的日誌,則接著可以詳細監控匯出的進度:

CloudWatch Logs 顯示畫面的螢幕擷取畫面。

取消執行中的匯出工作

使用 AWS Management Console 取消執行中的匯出工作
  1. https://console.aws.amazon.com/batch/ 開啟 AWS Batch 主控台。

  2. 選擇 Jobs (任務)

  3. 根據 jobID 找出您要取消的執行中工作。

  4. 選取取消工作

若要使用 Neptune 匯出 API 取消執行中的匯出工作

HTTP DELETE 請求傳送到附加 jobIDNeptuneExportApiUri,如下所示:

curl -X DELETE \ (your NeptuneExportApiUri) (the job ID)