使用 neptune-export 命令行工具从 Neptune 导出数据 - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 neptune-export 命令行工具从 Neptune 导出数据

您可以使用以下步骤,通过 neptune-export 命令行实用程序将数据从 Neptune 数据库集群导出到 Amazon S3:

使用 neptune-export 命令行实用程序的先决条件

开始之前
  • 拥有 JDK 的版本 8 – 您需要安装 Java SE 开发工具包 (JDK) 的版本 8。

  • 下载 neptune-export 实用程序 – 下载并安装 neptune-export.jar 文件。

  • 确保 neptune-export 可以访问您的 Neptune VPC – 从可以访问您的 Neptune 数据库集群所在的 VPC 的位置运行 neptune-export。

    例如,您可以在 Neptune VPC 内的 Amazon EC2 实例上、在与 Neptune VPC 对等的独立 VPC 中或在单独的堡垒主机上运行它。

  • 确保 VPC 安全组授予对 neptune-export 的访问权限 – 检查连接到 Neptune VPC 的 VPC 安全组是否允许从与 neptune-export 环境关联的 IP 地址或安全组访问您的数据库集群。

  • 设置必要的 IAM 权限 – 如果您的数据库启用了 Amazon Identity and Access Management (IAM) 数据库身份验证,请确保 neptune-export 运行所使用的角色与允许连接 Neptune 的 IAM policy 相关联。有关 Neptune 策略的一般信息,请参阅使用 IAM 策略

    如果您想在查询请求中使用 clusterId 导出参数,则 neptune-export 运行所使用的角色需要以下 IAM 权限:

    • rds:DescribeDBClusters

    • rds:DescribeDBInstances

    • rds:ListTagsForResource

    如果要从克隆的集群中导出,则 neptune-export 运行所使用的角色需要以下 IAM 权限:

    • rds:AddTagsToResource

    • rds:DescribeDBClusters

    • rds:DescribeDBInstances

    • rds:ListTagsForResource

    • rds:DescribeDBClusterParameters

    • rds:DescribeDBParameters

    • rds:ModifyDBParameterGroup

    • rds:ModifyDBClusterParameterGroup

    • rds:RestoreDBClusterToPointInTime

    • rds:DeleteDBInstance

    • rds:DeleteDBClusterParameterGroup

    • rds:DeleteDBParameterGroup

    • rds:DeleteDBCluster

    • rds:CreateDBInstance

    • rds:CreateDBClusterParameterGroup

    • rds:CreateDBParameterGroup

    要将导出的数据发布到 Amazon S3,neptune-export 运行所使用的角色需要对 Amazon S3 位置具有以下 IAM 权限:

    • s3:PutObject

    • s3:PutObjectTagging

    • s3:GetObject

  • 设置 SERVICE_REGION 环境变量 - 设置 SERVICE_REGION 环境变量以标识数据库集群所在的区域(有关区域标识符的列表,请参阅连接到 Neptune)。

运行 neptune-export 实用程序以启动导出操作

使用以下命令从命令行运行 neptune-export 并启动导出操作:

java -jar neptune-export.jar nesvc \ --root-path (path to a local directory) \ --json (the JSON file that defines the export)

该命令有两个参数:

开始导出时 neptune-export 的参数
  • --root-path – 导出文件发布到 Amazon S3 之前写入的本地目录的路径。

  • --json – 用于定义导出的 JSON 对象。

使用命令行实用程序的 neptune-export 命令示例

要直接从源数据库集群导出属性图数据,请执行以下操作:

java -jar neptune-export.jar nesvc \ --root-path /home/ec2-user/neptune-export \ --json '{ "command": "export-pg", "outputS3Path" : "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint" : "(your neptune DB cluster endpoint)" } }'

要直接从源数据库集群导出 RDF 数据,请执行以下操作:

java -jar neptune-export.jar nesvc \ --root-path /home/ec2-user/neptune-export \ --json '{ "command": "export-rdf", "outputS3Path" : "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint" : "(your neptune DB cluster endpoint)" } }'

如果忽略 command 请求参数,则默认情况下,neptune-export 实用程序会从 Neptune 导出属性图数据。

要从数据库集群的克隆中导出,请执行以下操作:

java -jar neptune-export.jar nesvc \ --root-path /home/ec2-user/neptune-export \ --json '{ "command": "export-pg", "outputS3Path" : "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint" : "(your neptune DB cluster endpoint)", "cloneCluster" : true } }'

要使用 IAM 身份验证从数据库集群导出,请执行以下操作:

java -jar neptune-export.jar nesvc \ --root-path /home/ec2-user/neptune-export \ --json '{ "command": "export-pg", "outputS3Path" : "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint" : "(your neptune DB cluster endpoint)" "useIamAuth" : true } }'