5

sparklyrR 包是否能够连接到 YARN 管理的 hadoop 集群?这似乎没有记录在集群部署文档中。使用SparkRSpark 附带的软件包可以通过以下方式进行:

# set R environment variables
Sys.setenv(YARN_CONF_DIR=...)
Sys.setenv(SPARK_CONF_DIR=...)
Sys.setenv(LD_LIBRARY_PATH=...)
Sys.setenv(SPARKR_SUBMIT_ARGS=...)

spark_lib_dir <- ... # install specific
library(SparkR, lib.loc = c(sparkr_lib_dir, .libPaths()))
sc <- sparkR.init(master = "yarn-client")

但是,当我将上面的最后几行替换为

library(sparklyr)
sc <- spark_connect(master = "yarn-client")

我收到错误:

Error in start_shell(scon, list(), jars, packages) : 
  Failed to launch Spark shell. Ports file does not exist.
    Path: /usr/hdp/2.4.2.0-258/spark/bin/spark-submit
    Parameters: '--packages' 'com.databricks:spark-csv_2.11:1.3.0,com.amazonaws:aws-java-sdk-pom:1.10.34' '--jars' '<path to R lib>/3.2/sparklyr/java/rspark_utils.jar'  sparkr-shell /tmp/RtmpT31OQT/filecfb07d7f8bfd.out

Ivy Default Cache set to: /home/mpollock/.ivy2/cache
The jars for the packages stored in: /home/mpollock/.ivy2/jars
:: loading settings :: url = jar:file:<path to spark install>/lib/spark-assembly-1.6.1.2.4.2.0-258-hadoop2.7.1.2.4.2.0-258.jar!/org/apache/ivy/core/settings/ivysettings.xml
com.databricks#spark-csv_2.11 added as a dependency
com.amazonaws#aws-java-sdk-pom added as a dependency
:: resolving dependencies :: org.apache.spark#spark-submit-parent;1.0
    confs: [default]
:: resolution report :: resolve 480ms :: artifacts dl 0ms
    :: modules in use:
    -----------------------------------------

sparklyr替代方案SparkR还是建立在SparkR包装之上?

4

4 回答 4

5

是的,sparklyr 可以用于纱线管理的集群。为了连接到纱线管理的集群,需要:

  1. 将 SPARK_HOME 环境变量设置为指向正确的 spark 主目录。
  2. 使用适当的主位置连接到 spark 集群,例如:sc <- spark_connect(master = "yarn-client")

另见:http ://spark.rstudio.com/deployment.html

于 2016-06-29T18:41:00.320 回答
2

是的,它可以,但所有其他内容都有一个问题,这在博客文献中非常难以捉摸,并且以配置资源为中心。

关键是:当你让它在本地模式下执行时,你不必以声明方式配置资源,但是当你在 YARN 集群中执行时,你绝对必须声明这些资源。我花了很长时间才找到阐明这个问题的文章,但一旦我尝试过,它就奏效了。

这是一个带有关键参考的(任意)示例:

config <- spark_config()
config$spark.driver.cores <- 32
config$spark.executor.cores <- 32
config$spark.executor.memory <- "40g"

library(sparklyr)

Sys.setenv(SPARK_HOME = "/usr/local/spark")
Sys.setenv(HADOOP_CONF_DIR = '/usr/local/hadoop/etc/hadoop/conf')
Sys.setenv(YARN_CONF_DIR = '/usr/local/hadoop/etc/hadoop/conf')

config <- spark_config()
config$spark.executor.instances <- 4
config$spark.executor.cores <- 4
config$spark.executor.memory <- "4G"

sc <- spark_connect(master="yarn-client", config=config, version = '2.1.0')

R Bloggers 文章链接

于 2017-03-17T22:48:21.427 回答
0

您是否可能使用 Cloudera Hadoop (CDH)?

我在问,因为我在使用 CDH 提供的 Spark 发行版时遇到了同样的问题:

Sys.getenv('SPARK_HOME')
[1] "/usr/lib/spark"  # CDH-provided Spark
library(sparklyr)
sc <- spark_connect(master = "yarn-client")
Error in sparkapi::start_shell(master = master, spark_home = spark_home,  : 
      Failed to launch Spark shell. Ports file does not exist.
        Path: /usr/lib/spark/bin/spark-submit
        Parameters: --jars, '/u01/app/oracle/product/12.1.0.2/dbhome_1/R/library/sparklyr/java/sparklyr.jar', --packages, 'com.databricks:spark-csv_2.11:1.3.0','com.amazonaws:aws-java-sdk-pom:1.10.34', sparkr-shell, /tmp/Rtmp6RwEnV/file307975dc1ea0.out

Ivy Default Cache set to: /home/oracle/.ivy2/cache
The jars for the packages stored in: /home/oracle/.ivy2/jars
:: loading settings :: url = jar:file:/usr/lib/spark/lib/spark-assembly-1.6.0-cdh5.7.0-hadoop2.6.0-cdh5.7.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
com.databricks#spark-csv_2.11 added as a dependency
com.amazonaws#aws-java-sdk-pom added as a dependency
:: resolving dependencies :: org.apache.spark#spark-submit-parent;1.0
    confs: [default]
    found com.databricks#spark-csv_2.11;1.3.0 in central
    found org.apache.commons#commons-csv;1.1 in central
    found com.univocity#univocity-parsers;1.5.1 in central
    found com.

但是,在我从 Databricks(Spark 1.6.1、Hadoop 2.6)下载预构建版本并指向SPARK_HOME那里后,我能够成功连接:

Sys.setenv(SPARK_HOME = '/home/oracle/spark-1.6.1-bin-hadoop2.6') 
sc <- spark_connect(master = "yarn-client") # OK
library(dplyr)
iris_tbl <- copy_to(sc, iris)
src_tbls(sc)
[1] "iris"

Cloudera 尚未包含SparkR在其发行版中,我怀疑sparklyr可能仍然对SparkR. 以下是尝试使用 CDH 提供的 Spark,但使用config=list()参数时的结果,正如Github 上的问题在此线程中所建议的那样:sparklyr

sc <- spark_connect(master='yarn-client', config=list()) # with CDH-provided Spark
Error in sparkapi::start_shell(master = master, spark_home = spark_home,  : 
  Failed to launch Spark shell. Ports file does not exist.
    Path: /usr/lib/spark/bin/spark-submit
    Parameters: --jars, '/u01/app/oracle/product/12.1.0.2/dbhome_1/R/library/sparklyr/java/sparklyr.jar', sparkr-shell, /tmp/Rtmpi9KWFt/file22276cf51d90.out

Error: sparkr.zip does not exist for R application in YARN mode.

此外,如果您检查错误部分的最右边部分Parameters(您的和我的),您将看到对sparkr-shell...的引用

(使用来自 RStudio Server、Oracle Linux 的 0.2.28、0.3.15、R 会话进行sparklyr 测试sparkapi

于 2016-07-20T16:20:29.613 回答
0

建议针对此问题升级到sparklyr版本或更新版本。0.2.30升级 usingdevtools::install_github("rstudio/sparklyr")然后重新启动 r 会话。

于 2016-07-26T07:18:07.867 回答