2015-11-03 116 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