本地jar包提交集群
--master 集群主节点
--name app名字
--class 主类,com.wyb为package名
本地jar包路径
./spark-submit --master spark://hadoop1:7077 --name wybPi --class com.wyb.SparkPi ~/Desktop/spark_scala.jar
在intellij中运行程序,得到结果
先将工程打包,runconfig设置好
val conf = new SparkConf().setAppName("WordCount1").setMaster("spark://hadoop1:7077")//添加appname和master
val sc = new SparkContext(conf)
sc.addJar("/home/hadoop/workspace/IdeaProjects/spark_scala/out/artifacts/spark_scala_jar/spark_scala.jar")//jar包
val line = sc.textFile("hdfs://hadoop1:9000/input/*.txt")
line.flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).sortByKey(false).sortByKey().collect().foreach(println)
--master 集群主节点
--name app名字
--class 主类,com.wyb为package名
本地jar包路径
./spark-submit --master spark://hadoop1:7077 --name wybPi --class com.wyb.SparkPi ~/Desktop/spark_scala.jar
在intellij中运行程序,得到结果
先将工程打包,runconfig设置好
val conf = new SparkConf().setAppName("WordCount1").setMaster("spark://hadoop1:7077")//添加appname和master
val sc = new SparkContext(conf)
sc.addJar("/home/hadoop/workspace/IdeaProjects/spark_scala/out/artifacts/spark_scala_jar/spark_scala.jar")//jar包
val line = sc.textFile("hdfs://hadoop1:9000/input/*.txt")
line.flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).sortByKey(false).sortByKey().collect().foreach(println)