apache-spark - Glue 上的 Spark 无法连接到 AWS/ElasticSearch

标签 apache-spark elasticsearch aws-glue

我在 Glue 中运行 Spark 以使用以下 Spark 配置写入 AWS/ElasticSearch:

  conf.set("es.nodes", s"$nodes/$indexName")
  conf.set("es.port", "443")
  conf.set("es.batch.write.retry.count", "200")
  conf.set("es.batch.size.bytes", "512kb")
  conf.set("es.batch.size.entries", "500")
  conf.set("es.index.auto.create", "false")
  conf.set("es.nodes.wan.only", "true")
  conf.set("es.net.ssl", "true")

但是我得到的是以下错误:
diagnostics: User class threw exception: org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot detect ES version - typically this happens if the network/Elasticsearch cluster is not accessible or when targeting a WAN/Cloud instance without the proper setting 'es.nodes.wan.only'
    at org.elasticsearch.hadoop.rest.InitializationUtils.discoverClusterInfo(InitializationUtils.java:340)
    at org.elasticsearch.spark.rdd.EsSpark$.doSaveToEs(EsSpark.scala:104)
    ....

我知道在哪个“VPC”中运行我的 ElasticSearch 实例,但我不确定如何为 Glue/Spark 设置它,或者它是否是一个不同的问题。任何的想法?

我还尝试添加一个“glue jdbc”连接,它应该使用正确的 VPC 连接,但我不确定如何正确设置它:
  import scala.reflect.runtime.universe._
  def saveToEs[T <: Product : TypeTag](index: String, data: RDD[T]) =
    SparkProvider.glueContext.getJDBCSink(
      catalogConnection = "my-elasticsearch-connection",
      options = JsonOptions(
        "WHAT HERE?"
      ),
      transformationContext = "SinkToElasticSearch"
    ).writeDynamicFrame(DynamicFrame(
      SparkProvider.sqlContext.createDataFrame[T](data),
      SparkProvider.glueContext))

最佳答案

尝试创建一个虚拟 JDBC 连接。虚拟连接将告诉 Glue ES - VPC、子网和安全组。测试连接可能不起作用,但是当您使用连接运行作业时,它将使用连接元数据在您的 VPC 中启动弹性网络接口(interface)以促进这种通信。更多关于连接的信息可以在这里找到:

[1] https://docs.aws.amazon.com/glue/latest/dg/start-connecting.html

关于apache-spark - Glue 上的 Spark 无法连接到 AWS/ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61453492/

相关文章:

java - Spark序列化和Java序列化有什么区别?

java - 使用 Java 的 Spark 作业服务器

database - 使用键值存储来保留rdbms的索引

Elasticsearch 分页最佳方法

python - SQL Server 与 AWS GLUE Python 3 作业的连接

snowflake-cloud-data-platform - 您可以使用 AWS Glue 获得永久 IP 地址,以便它可以在 Snowflake 中列入白名单吗?

apache-spark - Spark "Failed to construct kafka consumer"通过 SSL

scala - SPARK_EXECUTOR_INSTANCES 无法在 SPARK SHELL、YARN 客户端模式下工作

elasticsearch - elasticsearch中的mysql字段="value"

python - AWS Glue 与 SecretManager 用于数据库凭证