오늘의 인기 글
최근 글
최근 댓글
Today
Total
04-28 07:25
관리 메뉴

우노

[Spark] java.lang.IllegalArgumentException: Required executor memory (13312), overhead (2496 MB), and PySpark memory (0 MB) is above the max threshold (12288 MB) of this cluster! 에러 원인 및 해결 방법 본문

Data/Spark

[Spark] java.lang.IllegalArgumentException: Required executor memory (13312), overhead (2496 MB), and PySpark memory (0 MB) is above the max threshold (12288 MB) of this cluster! 에러 원인 및 해결 방법

운호(Noah) 2020. 10. 27. 15:50
  • 우선 YARN Resource의 개념에 대해 간단하게 알고 넘어가자

YARN Resource 개념

  • 클러스터에 있는 노드 하나의 물리적 자원이 다음과 같다고 가정했을 때

    • CPU : 24
    • Memory : 128GB
  • 다음 그림과 같이 YARN 리소스를 할당할 수 있다.

    • yarn.nodemanager.resource.memory-mb

      • nodemanager의 메모리 크기
      • 한 노드의 물리 메모리가 128GB이므로, OS를 위한 8GB 정도를 제외해 120GB로 설정
    • yarn.scheduler.maximum-allocation-mb

      • ResourceManager가 하나의 컨테이너 할당에 필요한 최대 메모리 크기
    • 따라서, "yarn.scheduler.maximum-allocation-mb" 값은 "yarn.nodemanager.resource.memory-mb" 값 이하로 설정해야한다.

에러

  • Amazon EMR에서 Spark 실험 도중 아래와 같은 오류가 발생했다.

      java.lang.IllegalArgumentException: Required executor memory (13312), overhead (2496 MB), and PySpark memory (0 MB) is above the max threshold (12288 MB) of this cluster! 
      Please check the values of 'yarn.scheduler.maximum-allocation-mb' and/or 'yarn.nodemanager.resource.memory-mb'.

원인

  • 1개의 Executor에 할당하고자 하는 메모리가, Worker node의 "yarn.scheduler.maximum-allocation-mb" 설정 값을 초과했기 때문이다.

    • "yarn.scheduler.maximum-allocation-mb"는 ResourceManager가 하나의 컨테이너에 할당 가능한 최대 메모리 크기를 의미한다.
    • 즉, 1개의 Executor 메모리는 컨테이너 메모리를 넘을 수 없다.
  • 예를 들어, Worker node(CPU 8, Memory 32GB)의 "yarn.scheduler.maximum-allocation-mb" default 값이 24576M 라면

    • spark-shell --num-executors 1 --executor-cores 8 --executor-memory 21G
      • 1개의 Executor에 할당하고자하는 메모리(21G)가 maximum(24G)에 근사하기 때문에 오류 발생
    • spark-shell --num-executors 2 --executor-cores 4 --executor-memory 14G
      • 오류 미발생

해결방법

  • EMR 생성 시 "yarn.scheduler.maximum-allocation-mb"의 값은 Worker node의 메모리에 따라 다르게 설정된다.

    • yarn-site.xml 파일 수정을 통해 "yarn.scheduler.maximum-allocation-mb" 값을 바꿀 순 있지만
    • 처음 주어지는 default 값이 Maximum 값이기 때문에, 해당 값 아래로만 수정이 유효하다.
  • default 값을 Maximum을 넘지 않는 선에서 수정하고 싶다면 다음과 같이 진행하면 된다.

    • EMR에서 yarn-site.xml(yarn 설정 파일)의 위치는 아래와 같다.

        /etc/hadoop/conf/yarn-site.xml
    • yarn-site.xml 파일의 "yarn.scheduler.maximum-allocation-mb" 값을 원하는 값으로 수정한다.

      • 대신, "yarn.scheduler.maximum-allocation-mb" 값은 "yarn.nodemanager.resource.memory-mb" 값 이하로 설정해야한다.
    • yarn resource를 재시작한다.

        sudo systemctl stop hadoop-yarn-resourcemanager
        sudo systemctl status hadoop-yarn-resourcemanager
        sudo systemctl start hadoop-yarn-resourcemanager

참고

Comments