์ด ํฌ์คํ ์ ์ด์ ํฌ์คํ ๊ณผ ์ด์ด์ง๋๋ค. ๐
Hadoop HDFS(3.3)+Spark(3.1.1)! ๋ฌด์์ ๋ฐ๋ผํ๊ธฐ #2
Hadoop HDFS(3.3)+Spark(3.1.1)! ๋ฌด์์ ๋ฐ๋ผํ๊ธฐ #2
์ด ํฌ์คํ ์ ์ด์ ํฌ์คํ ๊ณผ ์ด์ด์ง๋๋ค. ์ด์ ํฌ์คํ ์์ EC2 ํ๋๋ฅผ ์์ฑํ์ฌ ๊ทธ ์ธ์คํด์ค์ ํ์ํ ์ํํธ์จ์ด๋ฅผ ๋ชจ๋ ์ค์นํ๊ณ , ํ๊ฒฝ๋ณ์์ ์ค์ ํ์ผ์ ์์ ํ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๊ทธ ์ธ์คํด์ค๋ฅผ
1mini2.tistory.com
์ด์ ํฌ์คํ
#1 ~ #2์์ ๋ชจ๋ ์ธํ๋ผ ๊ตฌ์ถ์ด ์๋ฃ ๋์์ต๋๋ค.
์ด์ 4๋์ ์ธ์คํด์ค์ HDFS, YARN, Spark ํด๋ฌ์คํฐ๊ฐ ์ด์์ค์
๋๋ค. ๐๐๐๐
์ด๋ฒ ๋จ๊ณ์JupyterNotebook์ ์ค์นํ๊ณ ์คํํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.๐
ํ์ง๋ง ๊ทธ ์ ์! ๋ชจ๋ ์๋น์ค๊ฐ ์ ์์ธ์ง ํ์ธํด๋ด
์๋ค!!
์ธํ๋ผ ๊ตฌ์ฑ์ด ์๋ฃ๋ ์์ ์ธ ์ง๊ธ!!
์ง๊ธ๋ถํฐ๋ ๋ชจ๋ ๋ช
๋ น์ด์ํ์ Master๋
ธ๋์์๋ง ์งํํฉ๋๋ค.
1. HDFS ์๋น์ค ํ์ธํ๊ธฐ
HDFS ์๋น์ค๋ CLI ํน์ ์น์ฝ์์ ํตํด ์ํ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
[ HDFS CLI ]
[root@master ~]# /usr/local/hadoop-3.3.0/bin/hdfs dfsadmin -report

[ HDFS WEB UI ]
- http://<master node IP>:9870


2. Yarn ์๋น์ค ํ์ธํ๊ธฐ
YARN ์๋น์ค๋ CLI ํน์ ์น์ฝ์์ ํตํด ์ํ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
[ YARN CLI ]
[root@master ~]# /usr/local/hadoop-3.3.0/bin/yarn node -list

[ YARN WEB UI ]
- http://<master node IP>:8088


3. Spark ์๋น์ค ํ์ธํ๊ธฐ
Spark์ ์๋น์ค๋ WEB UI์์ ํ์ธํฉ๋๋ค!!
[ Spark WEB UI ]
- http://<master node IP>:8080

4. Python 3 & Conda (jupyterNotebook) & findspark ์ค์นํ๊ธฐ
1) Python 3 ์ค์น
์ ๋ Amazon Linux2 OS๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ฌ๊ธฐ์๋ ์ด๋ฏธ Python 3 ์ต์ ๋ฒ์ ์ด ์ค์น๋์ด ์์ต๋๋ค.
๋ง์ฝ, ์ค์น๋์ด์์ง ์๋ค๋ฉด, "yum install python3 -y" ๋ช
๋ น์ด๋ก python 3๋ฅผ ์ค์นํด์ฃผ์ธ์.
python3 ์ค์น ๋ฒ์ ์ ํ์ธํด๋ด ๋๋ค.
[root@master ~]# python3 --version

2) JupyterNotebook ์ค์น
miniconda(์ค์น ๋งํฌ)๋ก๋ ์ค์น๊ฐ ๊ฐ๋ฅํ์ง๋ง, ์ ๋ ๊ฐ์ฅ ๊ฐํธํ ๋ฐฉ๋ฒ์ธ pip์ ํตํด jupyter๋ฅผ ์ค์นํ๊ฒ ์ต๋๋ค.
[root@master ~]# pip3 install jupyter
๋ฒ์จ ์ค์น๊ฐ ์๋ฃ ๋์์ต๋๋ค.
์๋ ๋ช
๋ น์ด๋ฅผ ์คํํ์ฌ ํ๋ก์ธ์ค๊ฐ ์คํ๋๋ค๋ฉด ๋ค์์ผ๋ก ๋์ด๊ฐ๋๋ค!!!
[root@master ~]# jupyter notebook --allow-root

3) findSpark ์ค์น
findspark๋? SparkContext (Spark Cluster endpoint) ๋ฅผ findSpark ํจํค์ง๋ก ์ฝ๊ฒ ์ฐพ์ ์ ์์ต๋๋ค. ๋ง์ฝ ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค๋ฉด Jypyter์์ Spark์ฉ๋์ ํ๋กํ์ ๋ณ๋๋ก ์ฌ์ฉํด์ ์ฌ์ฉํฉ๋๋ค.
[root@master ec2-user]# pip3 install findspark

5. Jupyter Notebook ์คํํ๊ธฐ
Jupyter Notebook ์คํ ์ ์ค์ ํ์ผ์ ์์ ํด์ค๋๋ค!
๋จผ์ , ์ค์ ํ์ผ์ ์์ฑํฉ๋๋ค.
[root@master ~]# jupyter notebook --generate-config
๊ทธ๋ฆฌ๊ณ Password๋ฅผ ์์ฑํฉ๋๋ค.
[root@master ~]# ipython
Python 3.7.9 (default, Feb 18 2021, 03:10:35)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: // ์ฌ์ฉํ ๋น๋ฏผ๋ฒํธ ์
๋ ฅ
Verify password:
Out[2]: 'argon2:$argon2id$v=19$m=10240,t=1 ... ' //๋ณต์ฌํด๋๊ธฐ!
In [3]: exit()
๊ทธ๋ฆฌ๊ณ Jupyter Notebook์ ํ๋๋ ํฐ๋ฆฌ๋ฅผ ๋ง๋ค์ด์ค๋๋ค.
[root@master ~]# mkdir /root/jupyter_dir
์ด์ ์ค์ ํ์ผ์ ์์ ํฉ๋๋ค.
[root@master ~]# vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.password ='argon2:$argon2id$v=19$m=10240,t=10,p=8$t+Ki3Y…’
c.NotebookApp.notebook_dir = '/root/jupyter_dir/
์~! ์ด์ ์คํํด๋ด ์๋ค!!!!
[root@master ~]# jupyter notebook --allow-root

์น๋ธ๋ผ์ฐ์ ์์ ์คํํ๋ฉด ์ด๋ ๊ฒ ๋ณด์
๋๋ค.!!
๋น๋ฐ๋ฒํธ๋ฅผ ์น๊ณ ๋ก๊ทธ์ธํด๋ด
๋๋ค.

์๋ฌด๊ฒ๋ ์์ฃ !!!
ํ๋ฒ findspark ์จ๋ด
์๋ค!!

๊ทธ๋ฅ ์ดํ๋ฆฌ์ผ์ด์ ์ ์์ฑํ๋๊ฒ ๊น์ง ์ ๋๋ค!!

import findspark
findspark.init('/usr/local/spark-3.1.1-bin-hadoop3.2/')
import pyspark
sc = pyspark.SparkContext(master='spark://master:7077', appName='myFirstApp')
sc
์ด ์ฝ๋๋ฅผ ์คํํ๋ฉด, Spark Application์ด ์คํ๋ฉ๋๋ค.
์น UI์์๋ ์ดํ๋ฆฌ์ผ์ด์
์ด ์คํ๋๋๊ฒ์ ํ์ธํ ์ ์์ต๋๋ค.

๐๐๐์ฌ๊ธฐ์ ์ ๊น!๐๐๐
์ ๊ฐ ์์ฑํ ์ด ํฌ์คํ
์์, spark๋ฅผ ๋ฐ๋ก ๋์ฐ๋๋ฐ, ์ด๋ ๊ฒ ๋๋ฉด standalone mode ๋ผ๊ณ ํฉ๋๋ค ๐ฅฒ
ํฌ์คํ
ํ์ง 1๋
์ด ์ง๋ฌ์ง๋ง, ์ด์ ์ผ ์ด ์ฌ์ค์ ์์๋ค์...
์ ํฌ์คํ
์ ๋ณด๊ณ ๋ฐ๋ผํ์
จ๋ ๋ถ๋ค ์ด ๋ถ๋ถ์ ์ฐธ๊ณ ํด์ฃผ์ธ์ ๐ฅฒ
๋ค์์ ๋ ๊ณต๋ถํด์ ์ข์ ๋ด์ฉ์ผ๋ก ํฌ์คํ
ํ๋๋ก ํ๊ฒ ์ต๋๋ค.
cattt๋ ์ ๋ง ๊ฐ์ฌํฉ๋๋ค.๐
์ถ์ฒ: spark.apache.org/docs/latest/running-on-yarn.html