计算圆周率
[[email protected] bin]# ./run-example SparkPi
[[email protected] bin]# ./run-example SparkPi 10
[[email protected] bin]# ./run-example SparkPi 1000
运行 spark-shell 的两种方式:
1 直接运行 spark-shell
单机通过多线程跑任务, 只运行一个进程叫 submit
2 运行 spark-shell --master spark://mini1:7077
将任务运行在集群中, 运行 submit 在 master 上, 运行 executor 在 worker 上
启动
[[email protected] bin]# ./spark-shell
- hdfs
- hadoop/sbin/start-dfs.sh
计算 wordcount
sc.textFile("/root/words.txt").flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).collect
升序, 降序排列
mapReduce 执行流程
来源: http://www.bubuko.com/infodetail-3088602.html