Spark
Standalone 실행하기
master 실행
$ ./spark3/bin/start-master.sh
$ jps
5940 Master
5998 JPS
$ cat $HOME/spark3/logs/spark-spark-org.apache.spark.deploy.master.Master-1-spark-master-01.out
Shell
복사
master 정보 변경
$ cp ./spark3/conf/spark-env.sh.template ./spark3/conf/spark-env.sh
$ vim ./spark3/conf/spark-env.sh
...
$ ./spark3/sbin/stop-master.sh
$ ./spark3/sbin/start-master.sh
Shell
복사
•
spark-env.sh
# added by claude
SPARK_MASTER_PORT=7177
SPARK_MASTER_WEBUI_PORT=8180
SPARK_PUBLIC_DNS=${HOSTNAME}
Shell
복사
◦
SPARK_MASTER_PORT: 7077 (default)
◦
SPARK_MASTER_WEBUI_PORT: 8080 (default)
worker 실행
$ ./spark3/sbin/start-worker.sh spark://master-01:7177
Shell
복사
worker 정보 수정
$ cp ./spark3/conf/spark-env.sh.template ./spark3/conf/spark-env.sh
$ vim ./spark3/conf/spark-env.sh
...
$ ./spark3/sbin/stop-worker.sh
$ ./spark3/sbin/start-worker.sh spark://master-01:7177
Shell
복사
•
spark-env.sh
# added by clud
SPARK_WORKER_PORT=40001
SPARK_WORKER_WEBUI_PORT=8181
SPARK_PUBLIC_DNS=${HOSTNAME}
Shell
복사
◦
SPARK_WORKER_WEBUI_PORTL: 8081 (default)
Pyspark 실행
•
기본 실행
$ ./spakr3/bin/pyspark --master spark://master-01:7177
Shell
복사
•
리소스 할당
$ ./spark3/bin/pyspark --master spark://master-01:7177 \
--executor-memory 2G \
--executor-cores 2 \
--total-executor-cores 4 \
--name claude
Shell
복사
내용
•
Yarn, Kubernetes 등 별도의 리소스 매니저가 없는 경우 Spark 에서 Bundle 로 제공하는 Spark Standalone 을 사용한다
•
Standalone 은 기본적으로 CPU 를 할당 가능한만큼 다 할당해주고, Memory 는 Executor 당 1G 씩 할당한다
◦
Resource Manager 마다 Resource 할당 기준이 다르다
•
Standalone 을 사용할 때는 CPU, Memory 를 반드시 지정하는걸 습관화해야한다
•
Yarn 은 오버헤드로 인해 메모리가 약 1G 정도 할당되지만, Standalone 은 정해진 메모리만큼만 할당한다
•
단점
◦
Spark 외 다른 애플리케이션은 사용할 수 없다
◦
Standalone 은 버전 호환성이 떨어지기 때문에 Spark2 버전과 Spark3 버전에서 돌릴 수 없다
•
Yarn 은 Spark 버전과 관계 없이 모두 실행이 가능하기 때문에 현업에서는 주로 Yarn 을 많이 쓴다