Spark程式設計及作業提交易犯錯誤

2021-08-20 22:43:34 字數 1156 閱讀 5975

本地輸入的資料檔案,需要和jar包放在linux作業系統中,不能放在hdfs檔案系統中。以下是乙個示例

pathin="../sparkjar/distinct_infected_ua "

# 本地要傳入給spark作業的資料位置

for i in

doif [ $i

-lt10 ] ; then

i=0$i

fipathin="$pathin/user/guixiaolin/iphone_userurl/201509$i "

# hdfs檔案系統中資料位置

done

pathin=$-1}

pathout=""

for i in

doif [ $i

-lt10 ] ; then

i=0$i

fipathout="$pathout/user/guixiaolin/distinct_infected_user/201509$i "

# 資料輸出路徑

done

pathout=$-1}

export yarn_conf_dir=/opt/cloudera/parcels/cdh/lib/spark

spark-submit \

--master yarn-client \

--class cmc.distinctinfecteduser \

--num-executors 30 \

--driver-memory 14g \

--executor-memory 14g \

--executor-cores 16 \

../sparkjar/distinctinfecteduser.jar \

$pathin \ #總的輸入資料路徑

$pathout

譬如:

sc.textfile(file1).map(line=>line.split(「\)」)).map(x=>x(0).split(「\(「)).map(x=>x(1).split(「,」)).map(x=>(x(0),x(1)))

實現將檔案中的一行(a,b)轉變成k,v對。

spark提交作業時args引數是以空格隔開,若要輸入多條路徑,使用逗號隔開。

spark作業提交失敗分析

提交乙個spark作業,報錯 error spark.sparkcontext error inilializing sparkcontext.再提交乙個yarn作業,hadoop jar opt cloudera parcels cdh 6.1 jars hadoop examples.jar p...

Spark的作業提交流程簡介

這是自己讀取原始碼並結合他人的總結,寫的大概的流程,僅供參考 處理使用者的 jar 或者資源檔案,和日誌處理相關 iseventlogenabled eventlogdir eventlogcodec的初始化 初始化非同步監聽 bus livelistenerbus,監聽 spark 事件,用於 s...

Spark 三種作業提交方式

本地方式是在本地 jvm 中啟動乙個程序來模擬執行環境,多個執行緒進行作業執行,主要用於開發測試。standalone,yarn,兩種方式的區別在於 clustermanager 的不同,clustermanager 的作用在於進行各個程序的啟動管理,資源的排程。standalone的 cluste...