如何解决 Amazon Neptune 批量加载程序中的处理错误?

2 分钟阅读
0

我尝试使用 Amazon Neptune 批量加载程序从 Amazon Simple Storage Service (Amazon S3) 存储桶加载数据。但是,有些请求失败了。如何解决此问题?

简短描述

要解决数据请求持续失败的问题,请检查每项作业的状态。然后,通过执行以下操作来确定失败的作业:

  • 为每个单独负载使用默认批量加载程序 API,然后检查每项作业的状态。
  • 在一项作业中使用管理员脚本和自动化脚本。您可以在 Linux 或 UNIX 系统上创建并运行自动化脚本。

请注意以下限制:

  • Neptune 批量加载程序 API 不提供所有负载操作的快照视图。
  • 如果在 Neptune 集群上启用了 AWS Identity and Access Management (IAM) 授权,那么必须对批量负载 API 请求进行签名。
  • 批量加载程序 API 仅缓存关于最近 1024 项负载作业的信息。它只存储关于每项作业最近 10000 个错误的错误详细信息。

解决方法

使用默认的批量加载程序 API

1.    检索加载程序 ID:

$ curl -G  'https://neptunedemo-cluster.cluster-cw7ehemc1eeo.us-east-1.neptune.amazonaws.com:8182/loader'|jq
{
  "status": "200 OK",
  "payload": {
    "loadIds": [
      "c32bbd24-99a7-45ee-972c-21b7b9cab3e2",
      "6f6342fb-4ea3-452c-ac69-b4d117e37d5a",
      "647114a6-6ed4-4018-896c-e84a08fcf864",
      "521d33fa-7050-44d7-a961-b64ef4e2d1db",
      "d0d4714e-7cf8-415e-89f5-d07ed2732bf2"
    ]
  }
}

2.    逐个检查每项作业的状态,以确认作业是否成功。

curl -G 'https://neptunedemo-cluster.cluster-cw7ehemc1eeo.us-east-1.neptune.amazonaws.com:8182/loader/c32bbd24-99a7-45ee-972c-21b7b9cab3e2?details=true&errors=true&page=1&errorsPerPage=3'|jq
{
  "status": "200 OK",
  "payload": {
    "feedCount": [
      {
        "LOAD_COMPLETED": 2
      }
    ],
    "overallStatus": {
      "fullUri": "s3://demodata/neptune/",
      "runNumber": 5,
      "retryNumber": 0,
      "status": "LOAD_COMPLETED",
      "totalTimeSpent": 3,
      "startTime": 1555574461,
      "totalRecords": 8,
      "totalDuplicates": 8,
      "parsingErrors": 0,
      "datatypeMismatchErrors": 0,
      "insertErrors": 0
    },
    "errors": {
      "startIndex": 0,
      "endIndex": 0,
      "loadId": "c32bbd24-99a7-45ee-972c-21b7b9cab3e2",
      "errorLogs": []
    }
  }
}

使用管理员脚本

您可以使用管理员脚本来确定生产过程中失败的 Neptune 批量加载程序作业。管理员脚本可为所有负载作业生成以下格式的输出:

Startime-loadid:status,S3location,Errors

**注意:**可以从任何能够访问 Neptune 集群的 Linux 系统使用管理员脚本。

在 Linux 或 UNIX 系统上创建并运行自动化脚本

1.    使用文本编辑器创建此脚本:

$ vi script

2.    确保使用相应的值替换 cluster-endpoint:Port

cluster_ep="https://cluster-endpoint:Port/loader"

for loadId in $(curl --silent -G "${cluster_ep}?details=true" | jq '.payload.loadIds[]');
do
        clean_loadId=$(echo -n ${loadId} | tr -d '"')
        time=$(date -d@$(curl --silent -G "${cluster_ep}/${clean_loadId}?details=true" | jq '.payload.overallStatus.startTime'))
        echo -n $time '-'
        echo -n ${clean_loadId}: $(curl --silent -G "${cluster_ep}/${clean_loadId}?details=true" | jq '.payload.overallStatus.status')
        echo -n ',S3 LOCATION': $(curl --silent -G "${cluster_ep}/${clean_loadId}?details=true" | jq '.payload.overallStatus.fullUri')
        echo -n ',ERRORS': $(curl --silent -G "${cluster_ep}/${clean_loadId}?details=truei&errors=true&page=1&errorsPerPage=3" | jq '.payload.errors.errorLogs')

        echo
done

3.    保存脚本,然后提供脚本运行的权限:

chmod +x script

4.    安装依赖项库:

sudo yum install jq

5.    运行脚本:

$ ./script

以下是示例输出:

Thu Apr 18 08:01:01 UTC 2019 -c32bbd24-99a7-45ee-972c-21b7b9cab3e2: "LOAD_COMPLETED",S3 LOCATION: "s3://demodata/neptune/",ERRORS: null
Fri Apr 5 07:04:00 UTC 2019 -6f6342fb-4ea3-452c-ac69-b4d117e37d5a: "LOAD_COMPLETED",S3 LOCATION: "s3://demodata/neptune/",ERRORS: null
Fri Apr 5 07:01:30 UTC 2019 -647114a6-6ed4-4018-896c-e84a08fcf864: "LOAD_COMPLETED",S3 LOCATION: "s3://demodata/neptune/",ERRORS: null
Tue Mar 19 17:36:02 UTC 2019 -521d33fa-7050-44d7-a961-b64ef4e2d1db: "LOAD_COMPLETED",S3 LOCATION: "s3://demodata/neptune/",ERRORS: null
Tue Mar 19 17:35:45 UTC 2019 -d0d4714e-7cf8-415e-89f5-d07ed2732bf2: "LOAD_COMPLETED",S3 LOCATION: "s3://demodata/neptune/",ERRORS: null

相关信息

示例:将数据加载到 Neptune 数据库实例中

Neptune 加载程序获取状态 API

AWS 官方
AWS 官方已更新 4 年前