【问题标题】:How to connect to ElasticSearch from Apache Spark Service on Bluemix如何从 Bluemix 上的 Apache Spark 服务连接到 ElasticSearch
【发布时间】:2015-11-18 21:03:59
【问题描述】:

我在 Bluemix 上使用 Apache Spark 服务来创建演示(收集/解析 twitter 数据)。我想传输 Elastic Search。

我根据以下 URL [1] 创建了我的 scala 应用程序:

[1]https://www.elastic.co/guide/en/elasticsearch/hadoop/current/spark.html

但是,在 Bluemix 上使用 Jupyter notebook 时,我无法正常运行我的应用程序。一个特殊的解释器感知 SparkContext“sc”已经在运行,但我没有向“sc”添加属性,例如“es.nodes”、“es.port”等来连接 Elastic Search。

第一季度。 有谁知道如何向 Bluemix 上的特殊解释器感知 SparkContext 添加额外的属性?在我本地的 spark 环境中,很容易添加。

第二季度。 我尝试如下创建另一个 SparkContext 并用于流式传输,但它在 Jupyter 笔记本上无法控制..

var conf = sc.getConf
conf.set("es.index.auto.create", "true")
conf.set("es.nodes", "XXXXXXXX")
conf.set("es.port", "9020")
conf.set("spark.driver.allowMultipleContexts", "true")
val sc1 = new SparkContext(conf)

我认为,我创建额外 SparkContext 的过程可能不正确。 有谁知道如何在 Bluemix 上正确创建第二个 SparkContext?

【问题讨论】:

    标签: scala apache-spark ibm-cloud


    【解决方案1】:

    如果我没记错的话,您已经在现有 SparkContext 中的配置对象上设置了属性。

    这些行(纠正我认为是错字)应该在现有 SparkContext 的配置上设置选项:

    val conf = sc.getConf
    conf.set("es.index.auto.create", "true")
    conf.set("es.nodes", "XXXXXXXX")
    conf.set("es.port", "9020")
    conf.set("spark.driver.allowMultipleContexts", "true")
    

    您提到您无法添加这些属性——您能否详细说明这样做导致的问题?

    【讨论】:

    • 谢谢你,克里斯。我弄错了我的代码。我修改了它,它起作用了。
    猜你喜欢
    • 2016-04-26
    • 2016-09-07
    • 2016-12-29
    • 1970-01-01
    • 2016-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多