我在 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/