EMR scale in시 core node가 감소하지 않는 현상 해결방안

2021-08-12

.

Data_Engineering_TIL(20210812)

[학습내용]

  • 문제현상

core node instance group을 3대에서 1대로 감소요청을 하였고, 2대까지는 감소하였으나 resizing중이라는 상태에서 더이상 노드가 감소하지 않음

  • 해결방안

EMR 클러스터의 Events메뉴에서 아래와 같은 로그를 확인할 수 있다. 1시간 간격을 두고 두번에 걸쳐 resizing 요청이 있었지만 완료되었다는 이벤트가 보이지 않는다.

A resize for instance group ig-xxxxxxxxxxxxxxx in Amazon EMR cluster j-xxxxxxxxxx (my-emr-cluster) was initiated by user at 2021-08-12 12:09 UTC

A resize for instance group ig-xxxxxxxxxxxxxxx in Amazon EMR cluster j-xxxxxxxxxx (my-emr-cluster) was initiated by user at 2021-08-12 12:09 UTC. it is resizing from an instance count of 3 to 1

A resize for instance group ig-xxxxxxxxxxxxxxx in Amazon EMR cluster j-xxxxxxxxxx (my-emr-cluster) was initiated by user at 2021-08-12 13:10 UTC

A resize for instance group ig-xxxxxxxxxxxxxxx in Amazon EMR cluster j-xxxxxxxxxx (my-emr-cluster) was initiated by user at 2021-08-12 13:10 UTC. it is resizing from an instance count of 2 to 1

instance-controller.log를 확인해보니 아래와 같은 로그를 확인할 수 있었다.

2021-08-12 12:12:24,610 INFO Poller: Core numTargetNodes:1 numActiveNodes:3 instancesToDrop:0 instancesToKeep:0

2021-08-12 12:12:24,610 INFO Poller: Limited DFS Remaining capacity 150GB. Disallow shrinking 1 more DFS nodes

HDFS에 사용공간이 부족하여 instance-controller가 추가 노드의 감소를 허가하지 않았다. 하지만 다른 로그에서 DFS 사용률이 16.09%이고 남은 공간이 603.43GB으로 위에 instance-controller 로그와는 또 다른것을 확인할 수 있었다.

2021-08-09 12:12:23,845 INFO Poller: bash -l -c "hdfs dfsadmin -report":
Configured Capacity : 801687... (746.63GB)
Present Capacity : 77219... (719.16GB)
DFS Remaining : 64792... (603.43GB)
DFS Used : 12426... (115.73GB)
DFS Used% : 16.09%
Replicated Blocks : 
    Under replicated blocks:0
    Blocks with corrupt replicas:0

AWS에서 내부적으로 조사를 하던중에 클러스터가 resizing을 수행하던 중 노드가 terminate 되어 “decommissioning” 상태로 남아 있는 노드들이 있는 경우 DFS용량을 정확하게 계산하지 못하는 이슈가 있는 것을 확인하였다.

이를 해결하기 위해 아래와 같이 EMR 마스터노드에서 명령어를 실행해보자.

STEP 1) dfsadmin report 명령 실행

$ hadoop dfsadmin -report

위와 같이 명령을 실행하면, 아래와 같은 형식으로 노드들이 표시된다.

Live datanodes (n):

...

Decommissioning datanodes(n):

...

STEP 2) 위 명령을 수행했을때 Decommissiong datanodes 항목에 포함된 노드들의 IP가 마스터 노드에서의 “/emr/instance-controller/lib/dfs.hosts.exclude” 파일에 존재하는지 확인하고 존재한다면 제거한다.

STEP 3) 아래의 명령어로 HDFS의 정보를 갱신한다.

$ hadoop dfsadmin -refreshNodes

대부분의 경우 다시 아래와 같은 명령어를 실행했을때 Decommissiong datanodes 항목의 노드가 사라진것을 확인할 수 있는데 그래도 남아있다면 NameNode를 재시작하는 방법이 있다.

$ hadoop dfsadmin -report

NameNode를 재시작하는 방법은 아래와 같다.

step 1) Restart Namenode

$ sudo systemctl restart hadoop-hdfs-namenode

step 2) Namenode를 재시작했을때 HDFS가 safe mode 상태인 경우가 있는데, 이런경우에는 수동으로 safe mode off 상태로 변경해줘야 한다.

safe mode 여부 확인 : hadoop dfsadmin -safemode get

safe mode 변경 : hadoop dfsadmin -safemode leave

주의해야 할점은 네임노드를 재시작하게 되면 실행중인 job에 영향을 줄수있기 때문에 실행중인 job이 없거나 적은 시간대에 수행하는 것을 권고한다. 이후에 dfsadmin report 명령을 수행하여 다시 확인해본다.