本篇文章為大家展示了如何實(shí)現(xiàn)Spark on Yarn配置日志W(wǎng)eb UI,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
成都創(chuàng)新互聯(lián)公司是一家專業(yè)從事成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站的網(wǎng)絡(luò)公司。作為專業(yè)的建站公司,成都創(chuàng)新互聯(lián)公司依托的技術(shù)實(shí)力、以及多年的網(wǎng)站運(yùn)營經(jīng)驗(yàn),為您提供專業(yè)的成都網(wǎng)站建設(shè)、全網(wǎng)整合營銷推廣及網(wǎng)站設(shè)計(jì)開發(fā)服務(wù)!1.進(jìn)入spark目錄和配置文件
[root@sht-sgmhadoopnn-01 ~]# cd /root/learnproject/app/spark/conf
[root@sht-sgmhadoopnn-01 conf]# cp spark-defaults.conf.template spark-defaults.conf
2.創(chuàng)建spark-history的存儲(chǔ)日志路徑為hdfs上(當(dāng)然也可以在linux文件系統(tǒng)上)
[root@sht-sgmhadoopnn-01 conf]# hdfs dfs -ls /
Found 3 items
drwxr-xr-x - root root 0 2017-02-14 12:43 /spark
drwxrwx--- - root root 0 2017-02-14 12:58 /tmp
drwxr-xr-x - root root 0 2017-02-14 12:58 /user
You have new mail in /var/spool/mail/root
[root@sht-sgmhadoopnn-01 conf]# hdfs dfs -ls /spark
Found 1 items
drwxrwxrwx - root root 0 2017-02-15 21:44 /spark/checkpointdata
[root@sht-sgmhadoopnn-01 conf]# hdfs dfs -mkdir /spark/historylog
#在HDFS中創(chuàng)建一個(gè)目錄,用于保存Spark運(yùn)行日志信息。Spark History Server從此目錄中讀取日志信息
3.配置
[root@sht-sgmhadoopnn-01 conf]# vi spark-defaults.conf
spark.eventLog.enabled true
spark.eventLog.compress true
spark.eventLog.dir hdfs://nameservice1/spark/historylog
spark.yarn.historyServer.address 172.16.101.55:18080
#spark.eventLog.dir保存日志相關(guān)信息的路徑,可以是hdfs://開頭的HDFS路徑,也可以是file://開頭的本地路徑,都需要提前創(chuàng)建
#spark.yarn.historyServer.address : Spark history server的地址(不加http://).
這個(gè)地址會(huì)在Spark應(yīng)用程序完成后提交給YARN RM,然后可以在RM UI上點(diǎn)擊鏈接跳轉(zhuǎn)到history server UI上.
4.添加SPARK_HISTORY_OPTS參數(shù)
[root@sht-sgmhadoopnn-01 conf]# vi spark-env.sh
#!/usr/bin/env bash
export SCALA_HOME=/root/learnproject/app/scala
export JAVA_HOME=/usr/java/jdk1.8.0_111
export SPARK_MASTER_IP=172.16.101.55
export SPARK_WORKER_MEMORY=1g
export SPARK_PID_DIR=/root/learnproject/app/pid
export HADOOP_CONF_DIR=/root/learnproject/app/hadoop/etc/hadoop
export SPARK_HISTORY_OPTS="-Dspark.history.fs.logDirectory=hdfs://mycluster/spark/historylog \
-Dspark.history.ui.port=18080 \
-Dspark.history.retainedApplications=20"
5.啟動(dòng)服務(wù)和查看
[root@sht-sgmhadoopnn-01 spark]# ./sbin/start-history-server.sh
starting org.apache.spark.deploy.history.HistoryServer, logging to /root/learnproject/app/spark/logs/spark-root-org.apache.spark.deploy.history.HistoryServer-1-sht-sgmhadoopnn-01.out
[root@sht-sgmhadoopnn-01 ~]# jps
28905 HistoryServer
30407 ProdServerStart
30373 ResourceManager
30957 NameNode
16949 Jps
30280 DFSZKFailoverController
31445 JobHistoryServer
[root@sht-sgmhadoopnn-01 ~]# ps -ef|grep spark
root 17283 16928 0 21:42 pts/2 00:00:00 grep spark
root 28905 1 0 Feb16 ? 00:09:11 /usr/java/jdk1.8.0_111/bin/java -cp /root/learnproject/app/spark/conf/:/root/learnproject/app/spark/jars/*:/root/learnproject/app/hadoop/etc/hadoop/ -Dspark.history.fs.logDirectory=hdfs://mycluster/spark/historylog -Dspark.history.ui.port=18080 -Dspark.history.retainedApplications=20 -Xmx1g org.apache.spark.deploy.history.HistoryServer
You have new mail in /var/spool/mail/root
[root@sht-sgmhadoopnn-01 ~]# netstat -nlp|grep 28905
tcp 0 0 0.0.0.0:18080 0.0.0.0:* LISTEN 28905/java
[root@sht-sgmhadoopnn-01 ~]#
上述內(nèi)容就是如何實(shí)現(xiàn)Spark on Yarn配置日志W(wǎng)eb UI,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道。