入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

Spark(python)

创建时间:2017-04-23 投稿人: 浏览次数:240

一、 安装

下载jdk、scala、spark并配置环境变量/etc/profile

Spark(python)

创建软链接

Spark(python)

打开python的spark连接窗口 or ./bin/spark-submit test.py

Spark(python)

简化连接窗口日志信息

在conf目录下:cp log4j.properties.template log4j.properties

vim log4j.properties

Spark(python)

cp spark-env.sh.template spark-env.sh(编译好的故scala不用配置)

Spark(python)

cp slaves.template slaves

Spark(python)

启动

Spark(python)

Linux or window下浏览器访问:

Spark(python)

Spark shell 求pi 或者(./bin/run-example SparkPi 10)

Spark(python)

Spark(python)

一、 Wordcount

启动sparkhdfs

Spark(python)

进入pyspark或者(bin/pyspark --master spark://spark01:7077 --executor-memory 1G --total-executor-cores 1)运行:

sc.textFile("hdfs://spark01:9000/wc/test01.log").flatMap(lambda line: line.split(" ")).map(lambda word: (word, 1)).reduceByKey(lambda a, b: a+b).saveAsTextFile("hdfs://spark01:9000/out")

Spark(python)

Spark(python)

Spark(python)

Spark(python)

或者新建文件test.py

Spark(python)

执行bin/spark-submit test.py

bin/spark-submit --master spark://spark01:7077 --executor-memory 1G --total-executor-cores 1 test.py

Spark(python)

一、 RDD

1.Pyspark命令行

Spark(python)

2.Python文件形式

Spark(python)

声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像