data engineering

hadoop echo system의 기반지식 hadoop, zookeeper, yarn등 정리

qkqhxla1 2020. 10. 11. 19:35

하둡 에코 시스템을 회사에 들어와서 처음 사용해보는데, 회사에서는 당연히 실질적으로 필요한 지식인 스파크, 카프카 이런것들만 어떻게 설치해서 사용해왔다. 근데 이제 어느정도 여유가 생기니까 기반 지식들이 부족하다 보니 공부해야 할 필요성을 느꼈다.

왜 스파크는 하둡 위에서 돌아가는지, 왜 카프카는 주키퍼라는게 필요한지. yarn은 또 뭔지. 마치 c언어로 어떻게 프로그래밍을 하는데 내부에 포인터가 어떻게 어떻게 주소를 참조하는지 등 하나도 모르고 그냥 되니까 코딩하는 느낌이라.. 기반 지식에 대해 공부를 좀 더 하기 위해서 글들을 찾아보고 정리한다.



0. hadoop이란 무엇인가. 

https://dongvelopment.tistory.com/47

https://rachelsdotcom.tistory.com/75

https://m.blog.naver.com/sincc0715/221740872284


대용량 데이터를 분산 처리할 수 있는 자바 기반의 프레임워크. hdfs라는 하둡 분산 파일 시스템과 map reduce가 큰 특징임.



1. zookeeper란 무엇인가.

https://jdm.kr/blog/125

https://bcho.tistory.com/1016


분산 어플리케이션 관리를 위한 서비스. 분산 시스템을 설계 하다보면, 가장 문제점 중의 하나가 분산된 시스템간의 정보를 어떻게 공유할것이고, 클러스터에 있는 서버들의 상태를 체크할 필요가 있으며 또한, 분산된 서버들간에 동기화를 위한 락(lock)을 처리하는 것들이 문제로 부딪힌다. 이러한 문제를 해결하는 시스템을 코디네이션 서비스 시스템 (coordination service)라고 하는데, Apache Zookeeper가 대표적이다. 출처: https://bcho.tistory.com/1016 [조대협의 블로그]




2. hadoop과 zookeeper가 너무 비슷해보이는데 이 둘은 무슨 차이가 있는거지..?

https://stackoverflow.com/questions/10732834/why-do-we-need-zookeeper-in-the-hadoop-stack

https://stackoverflow.com/questions/43173968/differences-between-hdfs-and-zookeeper

https://www.edureka.co/community/1106/what-zookeeper-what-the-purpose-zookeeper-hadoop-ecosystem


Hadoop adopted Zookeeper as well starting with version 2.0. The purpose of Zookeeper is cluster management. 이런 답변도 있고 다른 답변도 읽어보면 하둡은 hdfs같은 분산 처리 환경 자체에 무게를 둔 개념같고 zookeeper는 분산 처리 환경을 매니징해주는것에 더 무게를 둔 개념같다.




2.5 하둡과 주키퍼가 함께 쓰이는 이유

https://www.quora.com/Why-is-Apache-ZooKeeper-used-along-with-Hadoop


Distributed application are difficult to coordinate and work with as they are much more error prone due to huge number of machine attached to network. as many machine involved race condition and deadlocks are common problems when implementing distributed application . Race condition occurs when a machine tries to perform two or more operations at a time and this can be taken care by serialisation property of ZooKeeper. Deadlocks are when two or more machines try to access same shared resource at the same time. More precisely they try to access each other’s resources which leads to lock of system as none of the system is releasing the resource but waiting for other system to release it. Synchronisation in Zookeeper helps to solve the deadlock. Another major issue with distributed application can be partial failure of process, which can lead to inconsistency of data. Zookeeper handles this through atomicity, which means either whole of the process will finish or nothing will persist after failure.

요약 : 분산 시스템에서 여러 어플리케이션이 동시에 한 오퍼레이션을 수행할때 생기는 레이스 컨디션이나 동시에 공유된 자원을 요청할때 생기는 데드락같은 문제, 혹은 분산 시스템에서 생기는 데이터 불일치 문제들을 해결하기 위해 zookeeper가 쓰인다.




3. yarn이란?

https://www.upgrad.com/blog/what-is-hadoop-yarn-architecture-its-components/


YARN is the main component of Hadoop v2.0. YARN helps to open up Hadoop by allowing to process and run data for batch processing, stream processing, interactive processing and graph processing which are stored in HDFS


YARN이란 하둡 2.0버전부터 쓰이는 hdfs내의 데이터를 배치나 스트리밍 등으로 처리하는 메인 컴포넌트이다.




3.5 yarn과 zookeeper의 차이점?

https://www.codingular.com/2017/05/difference-between-yarn-and-zookeeper/


YARN is the new Map Reduce daemon (MRv1) and it’s primary job is to take jobs and run them in the Hadoop cluster. So it primarily farms out and manages cluster work load. Zookeeper provides a distributed configuration service, a synchronization service and a naming registry for distributed systems. It is used by many daemons (including YARN) to manage their peers in a multiple node setup for high availability.

yarn은 새로운 map reduce데몬이고, 하둡 클러스터에서 잡들을 처리한다. 주키퍼는 분산 환경 시스템을 조율하는 역할을 하며 yarn을 비롯해 많은 데몬들이 사용한다. -> 넓게 분산 처리 환경 시스템을 조율하는게 주키퍼면 yarn은 그중에서도 map reduce잡을 어떻게 더 효율적으로 처리하는 엔진같은 개념인것같다.




4.하둡은 왜 스파크와 같이 쓰이는가? 스파크를 사용할때 하둡이 반드시 필요한가?

https://www.whizlabs.com/blog/do-you-need-hadoop-to-run-spark/

https://stackoverflow.com/questions/32022334/can-apache-spark-run-without-hadoop


HDFS is the main need of Hadoop to run Spark in distributed mode.

스파크와 하둡은 같이 안 쓰여도 된다.(standalone모드일 경우에는 mesos와 같은걸 써도 되어서 상관없다고 링크에 쓰여있다.) 다만 하둡과 같이 쓰이는 이유는 hdfs와 같은 분산 시스템이 주된 이유이다. 




5. 카프카는 왜 주키퍼와 같이 쓰이는가?

https://www.cloudkarafka.com/blog/2018-07-04-cloudkarafka_what_is_zookeeper.html

https://stackoverflow.com/questions/23751708/is-zookeeper-a-must-for-kafka


첫번째 링크에 정석적인 답이 잘 적혀져있다. 컨트롤러 투표나 토픽들의 설정을 위해 필요하다. 두번째 스택오버플로우 링크에는 그럼 카프카를 싱글 노드로 쓸 경우 주키퍼가 굳이 필요하냐? 는 질문인데 답변이 좋다.

One of the biggest design goals of Kafka are cluster deployments. That is the problem they are solving, and it would be silly to make a zk-less version for a standalone server. I have the feeling that kafka is not the tool for your job, but that you would be better of just using a vanilla file.

카프나는 애초에 클러스터 배포용으로 설계된거라서 주키퍼 없이 standalone으로 사용하면 애초에 용도와 맞지가 않다. 싱글 노드로 카프카를 사용할거면 이보다 더 다른 좋은 솔루션이 있을것같다.


그리고 스파크가 standalone이면 하둡 없이도 사용가능한 반면 카프카는 반드시 주키퍼가 필요하다.

'data engineering' 카테고리의 다른 글

sql group by having  (0) 2020.10.23
airflow 삽질  (0) 2020.10.20
make simple spark docker image  (0) 2020.10.09
spark mongo data processing, write csv to s3 삽질 정리.  (1) 2020.09.21
mongodb set ttl  (0) 2020.08.15