Apache Spark 的安装

安装JAVA和Python

> sudo apt-get install openjdk-8-jdk
> vim /etc/environment 

# 添加export到全局env里面
> export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

# 如果不想重启,可以直接使用source
> source /etc/environment
> sudo apt-get install python python3

安装Hadoop

> wget http://apache.fayea.com/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz
> tar -zxf hadoop-2.7.3.tar.gz 
> sudo mkdir input
> sudo chmod -R 777 input
> cp etc/hadoop/*.xml input/
> sudo ./bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar grep input output 'dfs[a-z.]+'
> cat output/*

安装Apache Spark

> wget http://mirrors.tuna.tsinghua.edu.cn/apache/spark/spark-2.1.1/spark-2.1.1-bin-hadoop2.7.tgz
> tar -zxf spark-2.1.1-bin-hadoop2.7.tgz 
> cd spark-2.1.1-bin-hadoop2.7

关联hadoop与spark

> sudo vim /etc/environment
    export LD_LIBRARY_PATH=/vagrant/hadoop-2.7.3/lib/native/:$LD_LIBRARY_PATH

安装pyspark到pip

> cd /vagrant/spark-2.1.1-bin-hadoop2.7/python
> pip install -e .

运行测试

> ./bin/spark-shell --master local[2]

# Python Version Spark Api
> ./bin/pyspark --master local[2]

note:The –master option specifies the master URL for a distributed cluster, local[N] is run locally with N threads.

Spark Standalone Cluster Deploy

> sudo ./bin/spark-submit --master spark://192.168.33.67:7077  --executor-memory 4G  --deploy-mode client --packages org.apache.spark:spark-streaming-kafka-0-8_2.11:2.1.1 /vagrant/stream_kafka.py

Spark Standalone client deploy mode and cluster deploy mode:

  • Client:

    • Driver runs on a dedicated server (Master node) inside a dedicated process. This means it has all available resources at it’s disposal to execute work.
    • Driver opens up a dedicated Netty HTTP server and distributes the JAR files specified to all Worker nodes (big advantage).
    • Because the Master node has dedicated resources of it’s own, you don’t need to “spend” worker resources for the Driver program.
    • If the driver process dies, you need an external monitoring system to reset it’s execution.
  • Cluster:

    • Driver runs on one of the cluster’s Worker nodes. The worker is chosen by the Master leader
    • Driver runs as a dedicated, standalone process inside the Worker.
    • Driver programs takes up at least 1 core and a dedicated amount of memory from one of the workers (this can be configured).
    • Driver program can be monitored from the Master node using the –supervise flag and be reset in case it dies.
    • When working in Cluster mode, all JARs related to the execution of your application need to be publicly available to all the workers. This means you can either manually place them in a shared place or in a folder for each of the workers.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值