Amazonrds 简明教程
Amazon RDS - PostgreSQL Data Import
Amazon RDS PostgreSQL 提供简单的方法,可以将数据导入到数据库和从数据库中导出数据。在成功连接到 PostgreSQL 数据库后,我们可以使用 CLI 工具运行导入和导出命令,以获取 RDS 数据库中其他数据源中的数据。
Amazon RDS PostgreSQL provides easy ways of importing data into the DB and exporting data from the DB. After we are able to successfully connect to the PostgreSQL database we can use CLI tools to run the import and export commands to get the data from other sources in and out of the RDS database.
以下是使用导出和导入机制的 PostgreSQL 数据迁移步骤。
Below are the steps through which the PostgreSQL data migration happens using the export and import mechanisms.
Importing from an Amazon EC2 Instance
当 Amazon EC2 实例上有一个 PostgreSQL 服务器并且需要将其移动到 RDS - PostgreSQL 数据库实例时,我们将使用以下步骤来执行此操作。
When there is a PostgreSQL server on an Amazon EC2 instance and it needs to be moved to a RDS - PostgreSQL DB instance, we use the below steps to do that.
Export The Data
使用包含要加载数据的 pg_dump 创建一个文件。使用 pg_dump 实用程序创建一个包含数据和数据库所有元数据的转储文件。psql 实用程序中的以下命令从名为 mydbname 的数据库创建转储文件。
Create a file using pg_dump that contains the data to be loaded. A dump file containing data and all the meta data of the database is created using the pg_dump utility. The following command in the psql utility cerates the dump file from the database named mydbname.
pg_dump dbname=mydbname -f mydbnamedump.sql