選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

從來源將 PostgreSQL 資料庫傳輸到目的地

焦點模式
從來源將 PostgreSQL 資料庫傳輸到目的地 - Amazon Relational Database Service

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

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

在您完成 設定 以傳輸 PostgreSQL 資料庫 中的描述程序,您可以開始進行傳輸。若要這麼做,請執行目的地資料庫執行個體上的 transport.import_from_server 功能。您可以在下列語法中找到函數參數。

SELECT transport.import_from_server( 'source-db-instance-endpoint', source-db-instance-port, 'source-db-instance-user', 'source-user-password', 'source-database-name', 'destination-user-password', false);

範例中顯示的 false 值告訴函數這並非試轉。若要測試傳輸設定,您可以在呼叫函數時為 dry_run 選項指定 true,如下所示:

postgres=> SELECT transport.import_from_server( 'docs-lab-source-db.666666666666aws-region.rds.amazonaws.com', 5432, 'postgres', '********', 'labdb', '******', true); INFO: Starting dry-run of import of database "labdb". INFO: Created connections to remote database (took 0.03 seconds). INFO: Checked remote cluster compatibility (took 0.05 seconds). INFO: Dry-run complete (took 0.08 seconds total). import_from_server -------------------- (1 row)

因為 pg_transport.timing 參數設定為其預設值 ,所以會輸出資料INFO行true。在執行命令時將 dry_run 設定為 false,來源資料庫即會匯入目的地,如下所示:

INFO: Starting import of database "labdb". INFO: Created connections to remote database (took 0.02 seconds). INFO: Marked remote database as read only (took 0.13 seconds). INFO: Checked remote cluster compatibility (took 0.03 seconds). INFO: Signaled creation of PITR blackout window (took 2.01 seconds). INFO: Applied remote database schema pre-data (took 0.50 seconds). INFO: Created connections to local cluster (took 0.01 seconds). INFO: Locked down destination database (took 0.00 seconds). INFO: Completed transfer of database files (took 0.24 seconds). INFO: Completed clean up (took 1.02 seconds). INFO: Physical transport complete (took 3.97 seconds total). import_from_server -------------------- (1 row)

此功能需要提供資料庫使用者密碼。因此,我們建議您在傳輸完成之後變更您所使用的使用者密碼。或者,您可以使用SQL繫結變數來建立臨時使用者角色。使用暫時的角色進行傳輸,並在之後捨棄該角色。

如果傳輸失敗,您可能會看到類似以下內容的錯誤訊息:

pg_transport.num_workers=8 25% of files transported failed to download file data

"Failed to download file data" (下載檔案資料失敗) 錯誤訊息表示工作者程序的數量未正確設定為資料庫的大小。您可能需要增加或減少為 pg_transport.num_workers 設定的值。每次失敗都會報告完成的百分比,以便您可以查看變更的影響。例如,在一種情況下,將設定從 8 變更為 4 會導致以下結果:

pg_transport.num_workers=4 75% of files transported failed to download file data

請記住,在傳輸過程中也會考慮 max_worker_processes 參數。換言之,您可能需要修改 pg_transport.num_workersmax_worker_processes 才能成功傳輸資料庫。當 pg_transport.num_workers 設定為 2 時,顯示的範例最終可運作:

pg_transport.num_workers=2 100% of files transported

如需有關 transport.import_from_server 功能及其參數的詳細資訊,請參閱 可傳輸資料庫函數參考

隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。