请按照链接http://h2o-release.s3.amazonaws.com/sparkling-water/rel-2.2/0/index.html中的Sparkling Water步骤操作。
在终端中运行:
~/InstallFile/SparklingWater/sparkling-water-2.2.0$ bin/sparkling-shell --conf "spark.executor.memory=1g"
请将SPARK_HOME变量设置为您的Spark安装路径。
请按照链接http://h2o-release.s3.amazonaws.com/sparkling-water/rel-2.2/0/index.html中的Sparkling Water步骤操作。
在终端中运行:
~/InstallFile/SparklingWater/sparkling-water-2.2.0$ bin/sparkling-shell --conf "spark.executor.memory=1g"
请将SPARK_HOME变量设置为您的Spark安装路径。
您需要安装并设置SPARK_HOME变量,在unix终端上运行以下代码以设置该变量:
export SPARK_HOME="/path/to/spark"
为了维护这个配置,您需要将以下内容追加到您的 .bashrc 文件的末尾。
有关安装信息,请参见 https://www.tutorialspoint.com/apache_spark/apache_spark_installation.htm
在使用安装了Anaconda的Jupyter Notebook时,调用名为findspark.py的函数会执行以下操作:
def find():
spark_home = os.environ.get('SPARK_HOME', None)
if not spark_home:
for path in [
'/usr/local/opt/apache-spark/libexec', # OS X Homebrew
'/usr/lib/spark/' # AWS Amazon EMR
# Any other common places to look?
]:
if os.path.exists(path):
spark_home = path
break
if not spark_home:
raise ValueError("Couldn't find Spark, make sure SPARK_HOME env is set"
" or Spark is in an expected location (e.g. from homebrew installation).")
return spark_home
接下来我们将按照以下步骤操作。
正如我们在上面的函数中看到的那样,对于 Windows 我们需要指定位置。下一个函数是从这些答案稍微修改过的版本。它被修改了,因为还需要指定 JAVA_HOME,这是你安装 Java 的目录。另外,我创建了一个 spark 目录,把我下载的 Spark 版本放进去了,你可以查看这些链接来进行这个操作。
import os
import sys
def configure_spark(spark_home=None, pyspark_python=None):
spark_home = spark_home or "/path/to/default/spark/home"
os.environ['SPARK_HOME'] = spark_home
os.environ['JAVA_HOME'] = 'C:\Program Files\Java\jre1.8.0_231'
# Add the PySpark directories to the Python path:
sys.path.insert(1, os.path.join(spark_home, 'python'))
sys.path.insert(1, os.path.join(spark_home, 'python', 'pyspark'))
sys.path.insert(1, os.path.join(spark_home, 'python', 'build'))
# If PySpark isn't specified, use currently running Python binary:
pyspark_python = pyspark_python or sys.executable
os.environ['PYSPARK_PYTHON'] = pyspark_python
configure_spark('C:\spark\spark-2.4.4-bin-hadoop2.6')
在本地工作时,您应该按照以下方式配置SparkContext:(这些链接很有用)
import findspark
from pyspark.conf import SparkConf
from pyspark.context import SparkContext
# Find Spark Locally
location = findspark.find()
findspark.init(location, edit_rc=True)
# Start a SparkContext
configure = SparkConf().set('spark.driver.host','127.0.0.1')
sc = pyspark.SparkContext(master = 'local', appName='desiredName', conf=configure)
这个流程对我来说很顺利,谢谢!
当您想要使用Sparkling Water时,您需要在计算机上下载spark运行时。它可以是本地下载或集群化的spark即基于Hadoop。
SPARK_HOME变量是Sparkling Water用来寻找spark运行时的目录/文件夹。
在以下设置SPARK_HOME中,我已经在本地机器上下载了Spark 2.1,并将路径设置为未解压缩的spark 2.1,如下所示:
SPARK_HOME=/Users/avkashchauhan/tools/spark-2.1.0-bin-hadoop2.6
$ pwd
/Users/avkashchauhan/tools/sw2/sparkling-water-2.1.14
现在,当我像下面这样启动sparkling-shell时,它运行得很好:
~/tools/sw2/sparkling-water-2.1.14 $ bin/sparkling-shell
-----
Spark master (MASTER) : local[*]
Spark home (SPARK_HOME) : /Users/avkashchauhan/tools/spark-2.1.0-bin-hadoop2.6
H2O build version : 3.14.0.2 (weierstrass)
Spark build version : 2.1.1
Scala version : 2.11
----