spark 安装与python pycharm搭建
来源:互联网 发布:kafka数据写入 hdfs 编辑:程序博客网 时间:2024/05/21 19:35
Spark介绍与安装教程(Linux系统)
Spark的安装教程
安装JDK与Scala
- 下载JDK:sudo apt-get install openjdk-7-jre-headless。
- 下载Scala: http://www.scala-lang.org/。
- 解压缩:tar –zxvf scala-2.10.6.tgz。
- 进入sudo vim /etc/profile在下面添加路径:
- 1
- 1
- 使修改生效source /etc/profile。
- 在命令行输入scala测试。
安装Spark
- 下载Spark: http://spark.apache.org/downloads.html
- 解压缩: tar –zxvf spark-1.5.1-bin-hadoop2.6.tgz
- 进入sudo vim /etc/profile在下面添加路径:
- 1
- 2
- 1
- 2
测试
- 在命令行输入:spark-shell(可在安装目录中bin里面找到)
python环境的安装
执行pyspark命令,你会看到以下结果:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
~$ pyspark
Python 2.7.8 (default, Dec 2 2014, 12:45:58)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Spark assembly has been built with Hive, including Datanucleus jars on classpath
Using Sparks default log4j profile: org/apache/spark/log4j-defaults.properties
[… snip …]
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ `_/
/__ / .__/\_,_/_/ /_/\_\ version 1.2.0
/_/
Using Python version 2.7.8 (default, Dec 2 2014 12:45:58)
SparkContext available as sc.
>>>
简略Spark输出
Spark(和PySpark)的执行可以特别详细,很多INFO日志消息都会打印到屏幕。开发过程中,这些非常恼人,因为可能丢失Python栈跟踪或者print的输出。为了减少Spark输出 – 你可以设置$SPARK_HOME/conf下的log4j。首先,拷贝一份$SPARK_HOME/conf/log4j.properties.template文件,去掉“.template”扩展名。
1
~$cp$SPARK_HOME/conf/log4j.properties.template$SPARK_HOME/conf/log4j.properties
编辑新文件,用WARN替换代码中出现的INFO。你的log4j.properties文件类似:
1
2
3
4
5
6
7
8
9
10
11
# Set everything to be logged to the console
log4j.rootCategory=WARN,console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/ddHH:mm:ss}%p%c{1}:%m%n
# Settings to quiet third party logs that are too verbose
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=WARN
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=WARN
使用PyCharm配置Spark的Python开发环境
1.配置Pycharm
打开PyCharm,创建一个Project。 然后选择“Run” ->“Edit Configurations” ->“Environment variables” 增加SPARK_HOME目录与PYTHONPATH目录。 - SPARK_HOME:Spark安装目录 - PYTHONPATH:Spark安装目录下的Python目录
2.测试Pycharm
运行一个小的Spark程序看看:
"""SimpleApp"""from pyspark import SparkContextlogFile = "/home/tom/spark-1.6.0/README.md"sc = SparkContext("local","Simple App")logData = sc.textFile(logFile).cache()numAs = logData.filter(lambda s: 'a' in s).count()numBs = logData.filter(lambda s: 'b' in s).count()print("Lines with a: %i, lines with b: %i"%(numAs, numBs))
运行结果:
Lines with a: 58, lines with b: 26
阅读全文
1 0
- spark 安装与python pycharm搭建
- Python安装环境搭建(python+pycharm+pid)
- linux pycharm安装(Python环境搭建)
- Python学习一 Windows10下Python安装与pycharm集成环境搭建
- Python之道1-环境搭建与pycharm的配置django安装及MySQL数据库配置
- Python之道1-环境搭建与pycharm的配置django安装及MySQL数据库配置
- spark在pycharm的搭建
- Spark安装搭建与使用
- 【PYTHON IDE】pycharm安装与使用
- python环境搭建(pycharm)
- Pycharm安装搭建
- Windows下Python开发环境搭建及Pycharm安装
- Python-Python及PyCharm的下载与安装
- win10 64位系统下,搭建spark环境,并配置python+pycharm开发环境
- Python&Pycharm&Django安装
- PyCharm安装Python插件
- pycharm 安装 python 包
- Python+PyCharm安装教程
- 5分钟通俗易懂了解什么是云存储
- APP优雅退出的几种方式
- 令人惊艳的废弃集装箱改造设计
- iOS
- centos升级内核
- spark 安装与python pycharm搭建
- 如何在官网下载JDK(版本、系统类型、字节位等)
- java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
- 框架,系统架构以及架构师的区别
- Table '.\xxxxx\xxxx' is marked as crashed and should be repaired 解决办法
- RTSP协议
- HTML知识点
- List的toArray方法的使用方法以及强制转换时的报错问题
- mysql全量和增量备份脚本