winutils spark windows安装env_variable

时间:2016-05-18 16:14:29

标签: windows git scala apache-spark apache-spark-standalone

我正在尝试在Windows 10上安装Spark 1.6.1,到目前为止我已经完成了以下操作......

  1. 下载spark 1.6.1,解压缩到某个目录,然后设置SPARK_HOME
  2. 下载scala 2.11.8,解压缩到某个目录,然后设置SCALA_HOME
  3. 设置_JAVA_OPTION env变量
  4. 只需下载zip目录,然后设置HADOOP_HOME env变量,即可从https://github.com/steveloughran/winutils.git下载winutils。 (不确定这是不正确的,由于权限被拒绝,我无法克隆目录。)
  5. 当我去火花回家并运行bin \ spark-shell时,我得到了

    'C:\Program' is not recognized as an internal or external command, operable program or batch file.
    

    我必须遗漏一些东西,我不知道如何从windows环境中运行bash脚本。但希望我不需要理解只是为了让这个工作。我一直在关注这个人的教程 - https://hernandezpaul.wordpress.com/2016/01/24/apache-spark-installation-on-windows-10/。任何帮助,将不胜感激。

2 个答案:

答案 0 :(得分:4)

您需要下载winutils可执行文件,而不是源代码。

您可以下载here,或者如果您真的想要整个Hadoop发行版,可以找到2.6.0二进制文件here。然后,您需要将HADOOP_HOME设置为包含winutils.exe的目录。

此外,确保您放置Spark的目录是一个不包含空格的目录,这非常重要,否则它将无效。

设置完成后,您无法启动spark-shell.sh,启动spark-shell.cmd

C:\Spark\bin>spark-shell
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Using Spark's repl log4j profile: org/apache/spark/log4j-defaults-repl.properties
To adjust logging level use sc.setLogLevel("INFO")
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 1.6.1
      /_/

Using Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_91)
Type in expressions to have them evaluated.
Type :help for more information.
Spark context available as sc.
16/05/18 19:31:56 WARN General: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Spark/lib/datanucleus-core-3.2.10.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Spark/bin/../lib/datanucleus-core-3.2.10.jar."
16/05/18 19:31:56 WARN General: Plugin (Bundle) "org.datanucleus.api.jdo" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Spark/lib/datanucleus-api-jdo-3.2.6.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Spark/bin/../lib/datanucleus-api-jdo-3.2.6.jar."
16/05/18 19:31:56 WARN General: Plugin (Bundle) "org.datanucleus.store.rdbms" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Spark/lib/datanucleus-rdbms-3.2.9.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Spark/bin/../lib/datanucleus-rdbms-3.2.9.jar."
16/05/18 19:31:56 WARN Connection: BoneCP specified but not present in CLASSPATH (or one of dependencies)
16/05/18 19:31:56 WARN Connection: BoneCP specified but not present in CLASSPATH (or one of dependencies)
16/05/18 19:32:01 WARN ObjectStore: Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 1.2.0
16/05/18 19:32:01 WARN ObjectStore: Failed to get database default, returning NoSuchObjectException
16/05/18 19:32:07 WARN General: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Spark/lib/datanucleus-core-3.2.10.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Spark/bin/../lib/datanucleus-core-3.2.10.jar."
16/05/18 19:32:07 WARN General: Plugin (Bundle) "org.datanucleus.api.jdo" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Spark/lib/datanucleus-api-jdo-3.2.6.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Spark/bin/../lib/datanucleus-api-jdo-3.2.6.jar."
16/05/18 19:32:07 WARN General: Plugin (Bundle) "org.datanucleus.store.rdbms" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/C:/Spark/lib/datanucleus-rdbms-3.2.9.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Spark/bin/../lib/datanucleus-rdbms-3.2.9.jar."
16/05/18 19:32:07 WARN Connection: BoneCP specified but not present in CLASSPATH (or one of dependencies)
16/05/18 19:32:08 WARN Connection: BoneCP specified but not present in CLASSPATH (or one of dependencies)
16/05/18 19:32:12 WARN ObjectStore: Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 1.2.0
16/05/18 19:32:12 WARN ObjectStore: Failed to get database default, returning NoSuchObjectException
SQL context available as sqlContext.

scala>

答案 1 :(得分:0)

在Windows上,您需要明确指定放置hadoop二进制文件的位置。

以下是设置spark-scala独立应用程序的步骤。

  1. 下载winutil.exe并将其放置在bin文件夹下的某个文件夹/目录中,例如c:\ hadoop \ bin

完整路径类似于c:\ hadoop \ bin \ winutil.exe

  1. 现在在创建sparkSession时,我们需要指定此路径。请参考下面的代码段:

    包com.test.config

     import org.apache.spark.sql.SparkSession
    
     object Spark2Config extends Serializable{
                System.setProperty("hadoop.home.dir", "C:\\hadoop")
                val spark = SparkSession.builder().appName("app_name").master("local").getOrCreate()       
     }