SPARK
-
spark에서 hadoop file system 경로를 읽어오지 못할 때 해결카테고리 없음 2021. 3. 24. 18:14
hadoop HDFS Name node를 변경에 따라 spark가 실행되는 노드들의 fs.defaultFS(core-site.xml)를 변경하였다. 하지만 spark cluster 환경과 shell 환경에서 fs.getUri를 하면 default 값인 hdfs:/// 로 경로가 잡혔다. HADOOP_HOME, HADOOP_CONF_DIR 환경 변수가 제대로 잡히지 않아 발생한 문제였다. HADOOP_CONF_DIR가 없으니 conf 설정(core-site.xml)을 읽어오지 못한 문제... 다음과 같이 설정해주니 문제가 해결되었다. vi ~/.bashrc JAVA_HOME= '경로에 맞춰서 설정' HADOOP_HOME='경로에 맞춰서 설정' SPARK_HOME='경로에 맞춰서 설정' HADOOP_CONF..
-
spark shuffle 피하고 broadcast join 으로 속도 빠르게 하기카테고리 없음 2020. 12. 5. 16:35
import org.apache.spark.sql.functions.broadcast BigDF.join(broadcast(SmallDF), SmallDF.col("ID") === BigDF.col("ID")) SELECT /*+ BROADCAST(SmallDF) */ * FROM LargeDF JOIN SmallDF ON LargeDF.key = SmallDF.key 너무 큰 테이블(BigDF)과 작은 테이블(SmallDF)을 JOIN하였는데 나머지는 excutor는 모두 끝났는데 한 executor에서 계속 task 실행 중이라 작업이 오래 걸렸다. spark의 shffle join은 두 테이블에서 각 executor에 알맞는 서로 data를 복사하기 때문에 속도가 느려진다. 한 테이블이 작다면 브로..
-
scala dataframe에서 null 값 coalesce으로 채우기프로그래밍/Scala 2020. 12. 3. 20:05
coalesce은 partition을 줄여주는 역할 뿐만 아니라 null 값을 채워줄 때도 사용할 수 있다. 위와 같은 data frame이 있을 때, first라고 기술하였기 때문에 DT 정렬 기준으로 첫번째 값(1)으로 null이 채워진다. import org.apache.spark.sql.expressions.Window val w = Window.orderBy("DT") ex_df.withColumn("ex_col", coalesce(col("ex_col"), first(col("ex_col"), true).over(w))) 가장 마지막 값인 3으로 채워지길 바란다면 window에 desc을 걸거나 val w = Window.orderBy("DT").desc ex_df.withColumn("ex_..
-
spark error no space left on device 에러 해결빅데이터/Spark 2020. 12. 1. 03:22
join 작업이 많은 코드를 돌렸더니 ERROR: no space left on device 가 발생했다. stack overflow 검색 결과, spark.local.dir를 변경하라고 나왔다. Spark Application Properties 중 하나였는데 spark.local.dir Directory to use for "scratch" space in Spark, including map output files and RDDs that get stored on disk. This should be on a fast, local disk in your system. It can also be a comma-separated list of multiple directories on different..
-
Zeppelin Setting빅데이터/Spark 2020. 11. 30. 22:44
spark를 편리하게 사용하기 위해 Zeppelin을 셋팅하였다. 셋팅은 쭈우루미 블로그를 참고하였다. iamksu.tistory.com/66 zeppelin 설치 □ Apache Zeppelin ▶ Apache Zeppelin은 Apache Spark을 기반으로 한 웹기반 노트북&시각화 툴 ▶ 처음 Spark를 시작하는 분과 보고서 제출용 그래프를 그리려는 분들에게 추천 □ 파일 다운로드.. iamksu.tistory.com Download Apache Zeppelin zeppelin.apache.org/download.html Download Note: From Zeppelin version 0.6.2, Spark interpreter in binary package is compatible with..
-
spark executor core, memory 설정빅데이터/Spark 2020. 11. 30. 22:12
spark property 설정은 SparkConf, spark-shell, spark-submit, spark-defaults.conf 에서 할 수 있는데 spark-submit 상에서 core와 memory를 효율적으로(최대한으로) 쓰고 싶어서 다음과 같이 설정해보았다. 전체 node 수는 9개, 각 node당 core는 40개, 각 node당 memory는 92GB 전체 core 갯수 ≥ 총 executor 갯수 * executor당 core 갯수 executor가 여러 노드에 걸쳐서 띄워지지 않으므로 executor memory를 설정할 때, 각 node의 memory도 고려해야 한다. 한 executor당 5 core를 잡았으므로 1 node당 8개의 executor가 띄워진다.(40/5 = 8..