Spark _14_SparkShell的使用
生活随笔
收集整理的這篇文章主要介紹了
Spark _14_SparkShell的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
SparkShell的使用
概念:
SparkShell是Spark自帶的一個快速原型開發工具,也可以說是Spark的scala REPL(Read-Eval-Print-Loop),即交互式shell。支持使用scala語言來進行Spark的交互式編程。
使用:
啟動Standalone集群,./start-all.sh
在客戶端上啟動spark-shell:
[root@henu4 ~]# ./spark-shell --master spark://henu1:7077正常啟動:【像springboot一樣,有這高逼格的圖標】
?
啟動hdfs,創建目錄spark/test,上傳文件words.txt
strat-all.sh??創建目錄:
[root@henu2 ~]# hdfs dfs -mkdir -p /spark/test上傳wc.txt
[root@henu2 ~]# hdfs dfs -put /root/words.txt /spark/test/文件信息words.txt:
hello world george george hello george hello honey a li提交任務:
scala> sc.textFile("hdfs://mycluster/spark/test/words.txt").flatMap(_.split(" ")).map( (_,1)).reduceByKey(_+_).foreach(println)運行結果:
http://henu1:8080/?
總結
以上是生活随笔為你收集整理的Spark _14_SparkShell的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: no.4_药丸称重
- 下一篇: SparkShell中提交任务java.