2017-07-06 76 views
0

我目前正在使用IntelliJ IDE在Scala中開發Spark。當我執行程序時,我可以訪問Web UI,但之後我無法訪問歷史記錄服務器。Spark歷史服務器

任何幫助將非常感激,我使用Windows的方式。 我也位於C創建日誌文件夾:/ tmp目錄/火花事件和編輯的火花defaults.conf這樣:

# Example: 
# spark.master      spark://master:7077 
# spark.eventLog.enabled   true 
# spark.eventLog.dir    hdfs://namenode:8021/directory 
# spark.serializer     org.apache.spark.serializer.KryoSerializer 
# spark.driver.memory    5g 
# spark.executor.extraJavaOptions -XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three" 
-Dspark.eventLog.enabled   true 
-Dspark.history.fs.logDirectory file:///C:/tmp/spark-events 
-Dspark.eventLog.dir    file:///C:/tmp/spark-events 

但我執行

更新後看不到任何日誌1:看到本教程https://medium.com/@eyaldahari/how-to-run-spark-history-server-on-windows-52cde350de07後,我現在可以訪問歷史記錄服務器。但它是空的,日誌不存在...

更新2:我現在非常接近,如果我在控制檯中啓動spark-shell,日誌和歷史記錄工作,但是當我在我的這個程序中使用它不寫任何日誌的IDE。

這裏是我的代碼

object SimpleScalaSpark { 
    def main(args: Array[String]) { 
    val logFile = "/Users/me/README.md" // Should be some file on your system 
    val conf = new SparkConf().setAppName("Simple Application").setMaster("local[*]") 
    val sc = new SparkContext(conf) 
    val logData = sc.textFile(logFile, 2).cache() 

     val numAs = logData.filter(line => line.contains("a")).count() 
     val numBs = logData.filter(line => line.contains("b")).count() 
     println("Lines with a: %s, Lines with b: %s".format(numAs, numBs)) 


    } 
} 
+0

什麼時候開始的歷史記錄服務器網頁前端(https://spark.apache.org/docs/latest/monitoring.html#viewing-after-the-fact)? –

+0

我建議你不要在tmp裏面創建spark-events目錄,系統每次重啓時都會刪除目錄。 –

+0

謝謝你的建議Shankar。 No Raphael,我在windows下,我無法運行.sh ... – Tiffany

回答

2

我終於通過在代碼中添加以下行來解決這個問題:

conf.set("spark.eventLog.enabled", "true") 
conf.set("spark.eventLog.dir", "file:///C:/Users/me/spark/logs") 

這一切都可以正常使用,現在

+0

這是否爲C:/ Users/me/spark/logs中的每個應用程序創建單獨的文件夾? – IceMan

+0

我認爲它會爲每個運行的應用程序創建一個單獨的日誌文件,但不是每次都運行一個文件夾 – Tiffany