1、下载安装spark
解压安装spark
tar xzvf spark-2.2.3-bin-hadoop2.7.tgz -C /home/hadoop/apps
spark集群规划
主机名 | 地址 | 角色 | 硬件配置 |
shixi01(master) | 192.168.150.159 | namenode | 2g 4核 |
shixi02(slaver1) | 192.168.150.158 | datanode | 2g 4核 |
shixi03(slaver2) | 192.168.150.157 | datanode | 2g 4核 |
2、配置文件修改
(1)复制模板文件
[hadoop@shixi01 conf]$ mv spark-env.sh.template spark-env.sh
[hadoop@shixi01 conf]$ mv slaves.template slaves
(2)配置spark-env.sh(增加环境变量)
vi spark-env.sh
export JAVA_HOME=/export/servers/jdk1.8.0_131
export SPARK_shixi01_HOST=192.168.150.159
export SPARK_shixi01_PORT=7077
(3)配置slaves
vi slaves
shixi02
shixi03
(4)将shixi01配置好的spark 拷贝到shixi02,shixi03
scp -r spark/ shixi02:/export/servers/spark
(注意命令语句中是否是中文的冒号,这里我把冒号输错了好几次)
scp -r spark/ shixi03:/export/servers/spark
(5)配置环境变量
export SPARK_HOME=/export/servers/spark
export PATH=$PATH:$SPARK_HOME/bin:$SPARK_HOME/sbin
//更新
source /etc/profile
//将其拷贝到其他机子上
scp /etc/profile shixi02:/etc/profile
scp /etc/profile shixi03:/etc/profile
- 启动与验证
start-shixi01.sh //启动主节点
start-slaves.sh //启动从节点
(从机)jps
打开浏览器,输入192.168.150.159:8080
2.提交jar 包并观察验证
spark-submit \
--master spark://192.168.150.159:7077 \
--class org.apache.spark.examples.SparkPi \
--executor-memory 512M \
--total-executor-cores 2 \
/export/servers/spark/examples/jars/spark-examples_2.11-2.4.1.jar 1000
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)