티스토리 뷰

Spark 프로그램을 yarn에서 돌리다보면, 종종 아래와 같은 메시지가 드라이버 프로그램 로그에 찍히면서, 이미 처리된 Task를 재시도 하다가 결국 실패하는 현상이 발생한다.

15/07/30 10:18:13 ERROR cluster.YarnScheduler: Lost executor 8 on myhost1.com: remote Rpc client disassociated


Yarn container에 돌고 있는 Spark Executor 로그를 살펴보면, 아래와 같이 SIGTERM 으로 인해 Executor 프로세스가 종료된 것을 확인할 수 있다. (Executor 로그 확인하는 위치는 아래를 참조)

ERROR executor.CoarseGrainedExecutorBackend: RECEIVED SIGNAL 15: SIGTERM 

구글에서 검색해보면,  SIGTERM이 발생하는 원인은 메모리 부족이라고 한다.



yarn으로 spark을 돌릴 때 메모리 관련 설정은 아래 두가지가 있는데, 충분한 메모리를 설정하여 문제를 해결할 수 있다.                   


spark.executor.memory : Amount of memory to use per executor process (default: 1G)


spark.yarn.executor.memoryOverhead : The amount of off-heap memory (in megabytes) to be allocated per executor. This is memory that accounts for things like VM overheads, interned strings, other native overheads, etc. This tends to grow with the executor size (typically 6-10%). (default: executorMemory * 0.10, with minimum of 384)


spark.executor.memory는 Executor 프로세스가 최대 사용할 수 있는 메모리 설정이고,

spark.yarn.executor.memoryOverhead는 위 설명을 참조(무슨 내용인지 잘 모르겠음.) 

위 두 개의 설정은 spark-submit 스크립트를 실행할 때 아래와 같이 지정할 수 있다. 

spark-submit --master yarn-client --class blog.service.StatsDriver  --conf spark.yarn.executor.memoryOverhead=4000  --files=log4j.properties --executor-memory 14000M --executor-cores 1 --num-executors 10 

spark.yarn.executor.memoryOverhead=4000 → 4000MB

이때, spark.executor.memory + spark.yarn.executor.memoryOverhead는 yarn.nodemanager.resource.memory-mb(yarn-site.xml에 설정됨) 보다 작아야 하며,

클 경우 시작과 동시에 바로 실패한다.

yarn.nodemanager.resource.memory-mb가 너무 작은 경우, 이 값을 수정하고 yarn nodemanager를 재시작해주어야 한다. 


Executor log 확인 방법

spark executor는 yarn container에서 돌아가기 때문에, 관련 로그는 yarn.nodemanager.log-dirs에 설정된 디렉토리에 남게 된다. 해당 디렉토리의 로그 파일을 확인하자.

yarn.log-aggregation-enable 설정이 true로 set되어 있는 경우, 스팍 작업이 끝나고 난 후

아래 명령을 통해 전체 로그 파일을 확인할 있다.

yarn logs -applicationId [app_id]


app_id는 yarn.resourcemanager.webapp.address.rm1에 설정된 주소에서 확인할 수 있다.

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함