跳至内容

为什么我的 Amazon EMR 集群会终止?

2 分钟阅读
0

我的 Amazon EMR 集群意外终止。

解决方法

Amazon EMR 将集群日志存储在集群启动时指定的 Amazon Simple Storage Service (Amazon S3) 存储桶中。例如,s3://example-log-location/example-cluster-ID/node/example-EC2-instance-ID/

要确定您的 Amazon EMR 集群终止的原因,请查看存储在 Amazon S3 中的 Amazon EMR 预置日志。

“SHUTDOWN_STEP_FAILED (USER_ERROR)”错误

在 Amazon EMR 集群中提交步骤作业时,可以在 ActionOnFailure 参数中指定步骤失败行为。如果为 ActionOnFailure 参数选择 TERMINATE_CLUSTERTERMINATE_JOB_FLOW,则 Amazon EMR 集群将终止,且您可能会看到来自 AWS CloudTrail 的以下错误消息:

“{ "severity": "ERROR", "actionOnFailure": "TERMINATE_JOB_FLOW", "stepId": "s-2I0G########", "name": "Example Step", "clusterId": "j-2YJ#######", "state": "FAILED", "message": "Step s-2I0G####### (Example Step) in Amazon EMR cluster j-2YJ####### failed at 202#-1#-0# 0#:## UTC." }”

为避免此错误,请在提交步骤作业时在 ActionOnFailure 参数中使用 CONTINUECANCEL_AND_WAIT 选项。

有关详细信息,请参阅 StepConfig

“NO_SLAVES_LEFT (SYSTEM_ERROR)”错误

当以下条件成立时,您会收到“No_SLAVES_LEFT”错误:

  • 您关闭了 Amazon EMR 集群的终止保护。
  • 所有核心节点都超过了 yarn-site 配置分类中由最大利用率阈值指定的磁盘存储容量。默认的最大利用率阈值为 90%。
  • 核心实例为竞价型实例,该竞价型实例状态为 TERMINATED_BY_SPOT_DUE_TO_NO_CAPACITY。
    有关竞价型实例终止的详细信息,请参阅 Amazon EC2 为何中断我的竞价型实例?

要解决此错误,请执行以下操作:

“502 Bad Gatewa”错误

当 Amazon EMR 内部系统在一段时间内无法访问主节点时,您将会收到“502 Bad Gateway”错误。如果您关闭终止保护,则 Amazon EMR 会终止集群。

当 instance-controller 服务关闭时,请检查最新的 instance-controller 日志和实例状态日志。如果 instance-controller 的标准输出显示,由于内存不足导致服务终止,则表明主节点的内存不足。

以下是来自实例状态日志的错误消息示例:

# dump instance controller stdouttail -n 100 /emr/instance-controller/log/instance-controller.out
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007fb46c7c8000, 12288, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 12288 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid16110.log
# whats memory usage look like
free -m
              total        used        free      shared  buff/cache   available
Mem:          15661       15346         147           0         167          69
Swap:             0           0           0

为避免上述错误,请启动具有更大实例类型的 Amazon EMR 集群,以获取更多内存来满足您的集群需求。此外,请清理磁盘空间,以避免长时间运行的集群出现内存中断。有关详细信息,请参阅如何排查 Amazon EMR 中出现“502 Bad Gateway”或“504 Gateway Time-out”错误的主节点故障?

“KMS_ISSUE (USER_ERROR)”错误

使用 Amazon EMR 安全配置加密 Amazon EBS 根设备和存储卷时,角色必须具有适当的权限。如果缺少必要的权限,则您会在 AWS CloudTrail 中收到以下错误消息:

“The EMR Service Role must have the kms:GenerateDataKey* and kms:ReEncrypt* permission for the KMS key configuration when you enabled EBS encryption by default.You can retrieve that KMS key's ID by using the ec2:GetEbsDefaultKmsKeyId API.”

为避免上述错误,请确保用于加密 Amazon EBS 根设备和存储卷的安全配置具有必要的权限。此外,请确保 Amazon EMR 服务角色 (EMR_DefaultRole_V2) 具有使用指定 AWS Key Management Service (AWS KMS) 密钥的权限。

“Terminated with errors, The master node was terminated by user”错误

当 Amazon EMR 集群主节点因任何原因停止时,集群将终止,并显示“The master node was terminated by user”错误。

您会在 AWS CloudTrail 中收到以下错误消息:

eventTime": "2023-01-18T08:07:02Z",
    "eventSource": "ec2.amazonaws.com",
    "eventName": "StopInstances",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "52.##.##.##",
    "userAgent": "AWS Internal",
    "requestParameters": {
        "instancesSet": {
            "items": [
                {
                    "instanceId": "i-##f6c5###########"
                }
            ]
        },
        "force": false
},

由于停止 Amazon EMR 主节点或所有核心节点会导致集群终止,因此请不要停止或重启集群节点。

**注意:**您的 Amazon EMR 集群可能会因本文所列原因以外的其他原因而终止。有关详细信息,请参阅 Amazon EMR 集群操作期间的资源错误

AWS 官方已更新 9 个月前