我在window本地搭建spark环境,想请教下 如何提交到集群中呢 代码如下:
[mw_shl_code=scala,true]import org.apache.spark.{SparkConf, SparkContext}
/**
* Created by Jan on 2016/12/19.
*/
object Helloworld {
def main(args: Array[String]) {
val logFile= "D:\\Improve\\24.Scala\\file" // Should be some file on your server.
System.setProperty("hadoop.home.dir", "D:\\Improve\\24.Scala\\Hadooplib\\hadoop-2.7.0\\hadoop-2.7.0");
val conf = new SparkConf().setAppName("Simple Application").setMaster("spark://10.145.218.176")
val sc= new SparkContext(conf)
val logData= sc.textFile(logFile, 2).cache()
val numAs= logData.filter(line => line.contains("h")).count()
val numBs= logData.filter(line => line.contains("j")).count()
println("Lines with h: %s, Lines with j: %s".format(numAs, numBs))
}
}[/mw_shl_code]
谢谢啦
|
|