Spark _14_SparkShell的使用
生活随笔
收集整理的這篇文章主要介紹了
Spark _14_SparkShell的使用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
SparkShell的使用
概念:
SparkShell是Spark自帶的一個(gè)快速原型開(kāi)發(fā)工具,也可以說(shuō)是Spark的scala REPL(Read-Eval-Print-Loop),即交互式shell。支持使用scala語(yǔ)言來(lái)進(jìn)行Spark的交互式編程。
使用:
啟動(dòng)Standalone集群,./start-all.sh
在客戶端上啟動(dòng)spark-shell:
[root@henu4 ~]# ./spark-shell --master spark://henu1:7077正常啟動(dòng):【像springboot一樣,有這高逼格的圖標(biāo)】
?
啟動(dòng)hdfs,創(chuàng)建目錄spark/test,上傳文件words.txt
strat-all.sh??創(chuàng)建目錄:
[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提交任務(wù):
scala> sc.textFile("hdfs://mycluster/spark/test/words.txt").flatMap(_.split(" ")).map( (_,1)).reduceByKey(_+_).foreach(println)運(yùn)行結(jié)果:
http://henu1:8080/?
總結(jié)
以上是生活随笔為你收集整理的Spark _14_SparkShell的使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: no.4_药丸称重
- 下一篇: SparkShell中提交任务java.