本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
创建Amazon DMS以 Neptune 为目标的复制任务
创建表映射和图形映射配置后,使用以下过程将数据从源存储加载到 Neptune。有关所涉及 API 的详细信息,请参阅 Amazon DMS 文档。
第 1 步:创建Amazon DMS复制实例
创建Amazon DMS在您的 Neptune 数据库集群运行的 VPC 中的复制实例(请参阅使用AmazonDMS 复制实例和CreateReplicationInstance中的Amazon DMS) 用户指南)。您可以使用类似以下的 Amazon CLI 命令来执行此操作:
aws dms create-replication-instance \ --replication-instance-identifier
(the replication instance identifier)
\ --replication-instance-class(the size and capacity of the instance, like 'dms.t2.medium')
\ --allocated-storage(the number of gigabytes to allocate for the instance initially)
\ --engine-version(the DMS engine version that the instance should use)
\ --vpc-security-group-ids(the security group to be used with the instance)
第 2 步 为源数据库创建 Amazon DMS 终端节点
下一步是为您的源数据存储创建 Amazon DMS 终端节点。您可以使用Amazon DMS CreateEndpoint中的 APIAmazon CLI如下所示:
aws dms create-endpoint \ --endpoint-identifier
(source endpoint identifier)
\ --endpoint-type source \ --engine-name(name of source database engine)
\ --username(user name for database login)
\ --password(password for login)
\ --server-name(name of the server)
\ --port(port number)
\ --database-name(database name)
第 3 步 为 Neptune 设置 Amazon S3 存储桶以暂存数据
如果您没有可用来暂存数据的 Amazon S3 存储桶,请按照中所述创建一个存储桶。创建存储桶在 Amazon S3 入门指南中,或如何创建 S3 存储桶?在控制台用户指南中。
您需要创建 IAM 策略授予GetObject
、PutObject
、DeleteObject
和ListObject
如果您还没有权限,则对存储桶的权限:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "ListObjectsInBucket", "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::
(bucket-name)
" ] }, { "Sid": "AllObjectActions", "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListObject" ], "Resource": [ "arn:aws:s3:::(bucket-name)
/*" ] } ] }
如果您的 Neptune 数据库集群启用了 IAM 身份验证,则还需要包括以下策略:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": "neptune-db:*", "Resource": "
(the ARN of your Neptune DB cluster resource)
" } ] }
创建 IAM 角色作为将策略附加到的信任文档:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "dms.amazonaws.com" }, "Action": "sts:AssumeRole" }, { "Sid": "neptune", "Effect": "Allow", "Principal": { "Service": "rds.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }
将策略附加到角色后,将该角色附加到 Neptune 数据库集群。这将允许 Amazon DMS 使用存储桶暂存所加载的数据。
第 4 步 在 Neptune VPC 中创建 Amazon S3 终端节点
现在,在您的 Neptune 集群所在的 VPC 中,为中间 Amazon S3 存储桶创建 VPC 网关终端节点。您可以使用 Amazon Web Services Management Console或 Amazon CLI 完成此操作,如创建网关终端节点中所述。
第 5 步 创建Amazon DMSNeptune 的目标终端节点
创建Amazon DMS目标 Neptune 数据库集群的终端节点。您可将 Amazon DMS CreateEndpoint API 与 NeptuneSettings
参数一起使用,如下所示:
aws dms create-endpoint \ --endpoint-identifier
(target endpoint identifier)
\ --endpoint-type target \ --engine-name neptune \ --server-name(name of the server)
\ --port(port number)
\ --neptune-settings '{ \ "ServiceAccessRoleArn": "(ARN of the service access role)
", \ "S3BucketName": "(name of S3 bucket to use for staging files when migrating)
", \ "S3BucketFolder": "(name of the folder to use in that S3 bucket)
", \ "ErrorRetryDuration":(number of milliseconds to wait between bulk-load retries)
, \ "MaxRetryCount":(the maximum number of times to retry a failing bulk-load job)
, \ "MaxFileSize":(maximum file size, in bytes, of the staging files written to S3)
, \ "isIamAuthEnabled":(set to true if IAM authentication is enabled on the Neptune cluster)
}'
在其 NeptuneSettings
参数中传递到 Amazon DMS CreateEndpoint
API 的 JSON 对象具有以下字段:
ServiceAccessRoleArn
–(必需)IAM 角色的 ARN,该角色允许对用于暂存迁移到 Neptune 的 S3 存储桶进行精细访问。如果您的 Neptune 数据库集群启用了 IAM 授权,则此角色还应有权访问该数据库集群。S3BucketName
–(必需)对于完全负载迁移,复制实例将所有 RDS 数据转换为 CSV、four 文件并将其上传到 S3 中的此暂存存储桶,然后将其批量加载到 Neptune。S3BucketFolder
–(必需)要在 S3 暂存存储桶中使用的文件夹。ErrorRetryDuration
–(可选)Neptune 请求失败后在发出重试请求之前等待的毫秒数。默认值为 250。MaxRetryCount
–(可选)最大重试请求数Amazon DMS应在发生可重试的失败后进行。默认 为 5。MaxFileSize
–(可选)迁移期间,保存到 S3 的每个暂存文件的最大大小(以字节为单位)。默认值为 1048576 KB (1 GB)。IsIAMAuthEnabled
–(可选)设置为true
如果在 Neptune 数据库集群上启用了 IAM 身份验证,或false
如果没有。默认为false
。
第 6 步 测试与新终端节点的连接
您可以使用Amazon DMS url=” https://docs.aws.amazon.com/dms/latest/APIReference/API_TestConnection.html">TestConnection类似于以下内容:
aws dms test-connection \ --replication-instance-arn
(the ARN of the replication instance)
\ --endpoint-arn(the ARN of the endpoint you are testing)
第 7 步 创建 Amazon DMS 复制任务
成功完成上述步骤后,创建一个复制任务,用于将数据从源数据存储迁移到 Neptune,使用Amazon DMS CreateReplicationTask类似于以下内容:
aws dms create-replication-task \ --replication-task-identifier
(name for the replication task)
\ --source-endpoint-arn(ARN of the source endpoint)
\ --target-endpoint-arn(ARN of the target endpoint)
\ --replication-instance-arn(ARN of the replication instance)
\ --migration-type full-load \ --table-mappings(table-mapping JSON object or URI like 'file:///tmp/table-mappings,json')
\ --task-data(a GraphMappingConfig object or URI like 'file:///tmp/graph-mapping-config.json')
这些区域有:TaskData
参数提供GraphMappingConfig这指定要复制的数据应如何存储在 Neptune 中。
第 8 步 启动 Amazon DMS 复制任务
现在,您可以启动复制任务:
aws dms start-replication-task --replication-task-arn
(ARN of the replication task started in the previous step)
--start-replication-task-type start-replication