Spark学习之Spark调优与调试(7)
生活随笔
收集整理的這篇文章主要介紹了
Spark学习之Spark调优与调试(7)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Spark學習之Spark調優與調試(7)
1. 對Spark進行調優與調試通常需要修改Spark應用運行時配置的選項。
當創建一個SparkContext時就會創建一個SparkConf實例。2. Spark特定的優先級順序來選擇實際配置:
優先級最高的是在用戶代碼中顯示調用set()方法設置選項; 其次是通過spark-submit傳遞的參數; 再次是寫在配置文件里的值; 最后是系統的默認值。3.查看應用進度信息和性能指標有兩種方式:網頁用戶界面、驅動器和執行器進程生成的日志文件。
4.Spark執行的組成部分:作業、任務和步驟
需求:使用Spark shell完成簡單的日志分析應用。 scala> val input =sc.textFile("/home/spark01/Documents/input.text") input: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[3] at textFile at <console>:27scala> val tokenized = input.map(line=>line.split(" ")).filter(words=>words.size>0) tokenized: org.apache.spark.rdd.RDD[Array[String]] = MapPartitionsRDD[5] at filter at <console>:29scala> val counts = tokenized.map(words=>(words(0),1)).reduceByKey{(a,b)=>a+b} counts: org.apache.spark.rdd.RDD[(String, Int)] = ShuffledRDD[7] at reduceByKey at <console>:31scala> // see RDDscala> input.toDebugString res0: String = (1) MapPartitionsRDD[3] at textFile at <console>:27 []| /home/spark01/Documents/input.text HadoopRDD[2] at textFile at <console>:27 []scala> counts.toDebugString res1: String = (1) ShuffledRDD[7] at reduceByKey at <console>:31 []+-(1) MapPartitionsRDD[6] at map at <console>:31 []| MapPartitionsRDD[5] at filter at <console>:29 []| MapPartitionsRDD[4] at map at <console>:29 []| MapPartitionsRDD[3] at textFile at <console>:27 []| /home/spark01/Documents/input.text HadoopRDD[2] at textFile at <console>:27 []scala> counts.collect() res2: Array[(String, Int)] = Array((ERROR,1), (##input.text##,1), (INFO,4), ("",2), (WARN,2))scala> counts.cache() res3: counts.type = ShuffledRDD[7] at reduceByKey at <console>:31scala> counts.collect() res5: Array[(String, Int)] = Array((ERROR,1), (##input.text##,1), (INFO,4), ("",2), (WARN,2))scala>5. Spark網頁用戶界面
默認情況地址是http://localhost:4040 通過瀏覽器可以查看已經運行過的作業(job)的詳細情況 如圖下圖:
圖1所有任務用戶界面
圖二作業2詳細信息用戶界面
6. 關鍵性能考量:
代碼層面:并行度、序列化格式、內存管理 運行環境:硬件供給。總結
以上是生活随笔為你收集整理的Spark学习之Spark调优与调试(7)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux驱动中获取系统时间
- 下一篇: Open*** 安装脚本