2015-11-03 115 views
0

我需要問一些關於Azure的問題。我想知道如何將.jar文件傳入羣集,以便您可以從命令行羣集azure啓動。CountWord在集羣azure上使用火花

我也想知道我寫的代碼在scala中是否正確,特別是如果它是使用wasb://函數從blob獲取文件的正確方法。

import scala.io.Source 
import org.apache.spark.SparkContext 
import org.apache.spark.SparkContext._ 
import org.apache.spark.SparkConf 

object SimpleApp { 
    def main(args: Array[String]) { 
    val textFile = 
     spark.textFile("wasb://[email protected]/prova.txt") 
    val counts = textFile.flatMap(line => line.split(" ")) 
        .map(word => (word, 1)) 
        .reduceByKey(_ + _) 
    counts.saveAsTextFile("wasb://[email protected]/provaoutput.txt") 
    } 
} 

而最後一個問題了啓動程序,這是正確的代碼:

C:\apps\dist\spark-1.2.0\bin\spark-submit --class "SimpleApp" --master local target/scala-2.10/simpleapp_2.10-1.0.jar 

回答

0

對於你的問題,我想你想知道如何遠程訪問HDInsight星火集羣。

在HDInsight上創建Spark集羣時,需要啓用遠程桌面,請參閱下文。

enter image description here

那麼你可以參考https://azure.microsoft.com/en-us/documentation/articles/hdinsight-administer-use-management-portal/#rdp連接到使用RDP HDInsight集羣。

然後按照文檔https://azure.microsoft.com/en-us/documentation/articles/hdinsight-hadoop-use-mapreduce-remote-desktop/運行您的spark工作,如運行mapreduce。

enter image description here

然而,有一個簡單的方法用在Azure HDInsight一個飛艇notebool運行腳本階,請參閱https://azure.microsoft.com/en-us/documentation/articles/hdinsight-apache-spark-zeppelin-notebook-jupyter-spark-sql/#zeppelin看到更多的細節。請看下面的圖片。

enter image description here