将以下内容保存为 spark-env.cmd 放到 spark-2.1.1-bin-without-hadoop\bin 目录。
前提(安装好hadoop[比如 hadoop-2.6.3 ] 并配置环境好变量)
@echo off
rem ################### SET ENV ##################
rem set SPARK_MASTER_IP=localhost
rem set SPARK_WORKER_CORES=1
set SPARK_WORKER_MEMORY=1gecho HADOOP_HOME: %HADOOP_HOME%
set HADOOP_CONF_DIR=”%HADOOP_HOME%\hadoop\etc\hadoop”
echo HADOOP_CONF_DIR: %HADOOP_CONF_DIR%for /f %%i in (‘hadoop classpath’) do set SPARK_DIST_CLASSPATH=%%i
echo SPARK_DIST_CLASSPATH: %SPARK_DIST_CLASSPATH%
mkdir -p %SPARK_HOME%\temp
SET temp=%SPARK_HOME%\tempecho %temp%
然后先执行 spark-env
在执行 spark-shell 即可成功。
国内镜像下载地址:
http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz
http://mirror.bit.edu.cn/apache/spark/spark-2.1.1/spark-2.1.1-bin-without-hadoop.tgz