Using org.elasticsearch.hadoop with searchguard

80 views
Skip to first unread message

Steven Suting

unread,
Sep 27, 2018, 1:56:30 AM9/27/18
to Search Guard Community Forum
When asking questions, please provide the following information:

* Search Guard and Elasticsearch version
* Installed and used enterprise modules, if any
* JVM version and operating system version
* Search Guard configuration files
* Elasticsearch log messages on debug level
* Other installed Elasticsearch or Kibana plugins, if any

Version Details:
Search Guard: 6.4.1-23.1
Elasticsearch version: 6.4.1
operating system version: Centos 7

I am trying to connect to ES from spark. It worked fine until Searchguard was installed. As per the documentation https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html#_basic_authentication the user and pass parameters needed to be passed.

    es_write_conf = {
       
"es.nodes" : "192.168.22.22",
       
"es.port" : "9200",
       
"es.input.json": "true",
       
"es.nodes.ingest.only": "true",
       
"es.net.http.auth.user": "user",
       
"es.net.http.auth.pass": "pass"
   
}


Function being used:

    saveAsNewAPIHadoopFile(
    path
='-',
    outputFormatClass
="org.elasticsearch.hadoop.mr.EsOutputFormat",
    keyClass
="org.apache.hadoop.io.NullWritable",
    valueClass
="org.elasticsearch.hadoop.mr.LinkedMapWritable",
    conf
=es_write_conf)



However, even after doing so it does not connect and throws the following error:

18/09/27 10:59:28 INFO HttpMethodDirector: I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 192.168.22.22 failed to respond
 
18/09/27 10:59:29 ERROR NetworkClient: Node [192.168.22.22:9200] failed (The server 192.168.2.59 failed to respond); no other nodes left - aborting...
   
Caused by: org.elasticsearch.hadoop.rest.EsHadoopNoNodesLeftException: Connection error (check network and/or proxy settings)- all nodes failed; tried [[192.168.22.22:9200]]

SG

unread,
Sep 27, 2018, 2:11:55 AM9/27/18
to search...@googlegroups.com
Something interesting in the ES logs? Maybe you enabled https and so some ssl config is missing on client side?
Please post your elasticsearch.yml file.
> --
> You received this message because you are subscribed to the Google Groups "Search Guard Community Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to search-guard...@googlegroups.com.
> To post to this group, send email to search...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/search-guard/dc0d908f-973c-4dac-bdd4-91fcf6ab12d7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Steven Suting

unread,
Sep 27, 2018, 2:41:13 AM9/27/18
to search...@googlegroups.com
Attached is the elasticsearch.yml file.

This is the ES Log. I am using PEM for certification.
[2018-09-27T12:36:42,187][ERROR][c.f.s.h.SearchGuardHttpServerTransport] [esm1] SSL Problem Received fatal alert: certificate_unknown
javax
.net.ssl.SSLException: Received fatal alert: certificate_unknown
    at sun
.security.ssl.Alerts.getSSLException(Alerts.java:208) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781) ~[?:?]
    at javax
.net.ssl.SSLEngine.unwrap(SSLEngine.java:624) ~[?:1.8.0_181]
    at io
.netty.handler.ssl.SslHandler$SslEngineType$3.unwrap(SslHandler.java:281) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1215) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1127) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.ssl.SslHandler.decode(SslHandler.java:1162) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) ~[netty-codec-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) ~[netty-codec-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-codec-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:545) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.16.Final.jar:4.1.16.Final]
    at java
.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
[2018-09-27T12:36:42,656][ERROR][c.f.s.h.SearchGuardHttpServerTransport] [esm1] SSL Problem Received fatal alert: certificate_unknown
javax
.net.ssl.SSLException: Received fatal alert: certificate_unknown
    at sun
.security.ssl.Alerts.getSSLException(Alerts.java:208) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907) ~[?:?]
    at sun
.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781) ~[?:?]
    at javax
.net.ssl.SSLEngine.unwrap(SSLEngine.java:624) ~[?:1.8.0_181]
    at io
.netty.handler.ssl.SslHandler$SslEngineType$3.unwrap(SslHandler.java:281) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1215) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1127) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.ssl.SslHandler.decode(SslHandler.java:1162) ~[netty-handler-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) ~[netty-codec-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) ~[netty-codec-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-codec-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:545) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [netty-transport-4.1.16.Final.jar:4.1.16.Final]
    at io
.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.16.Final.jar:4.1.16.Final]
    at java
.lang.Thread.run(Thread.java:748) [?:1.8.0_181]


elasticsearch.yml

SG

unread,
Sep 27, 2018, 4:13:35 AM9/27/18
to search...@googlegroups.com
You have enabled https so your hadoop config should look like:

es_write_conf = {
"es.nodes" : "192.168.22.22",
"es.port" : "9200",
"es.input.json": "true",
"es.nodes.ingest.only": "true",
"es.net.http.auth.user": "user",
"es.net.http.auth.pass": "pass",
"es.net.ssl": "true",
"es.net.ssl.truststore.location": "...",
"es.net.ssl.truststore.pass": "xxx",
"es.net.ssl.cert.allow.self.signed": "????"
}

See https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html#_secure_settings


> Am 27.09.2018 um 08:41 schrieb Steven Suting <steven...@everlytics.io>:
>
> Attached is the elasticsearch.yml file.
>
> --
> You received this message because you are subscribed to the Google Groups "Search Guard Community Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to search-guard...@googlegroups.com.
> To post to this group, send email to search...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/search-guard/906cf3ce-b5bc-477c-a523-2c67f726796d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <elasticsearch.yml>

Steven Suting

unread,
Sep 27, 2018, 7:47:18 AM9/27/18
to search...@googlegroups.com
Used this commands to generate a keystore file.
$> java -classpath path/to/eshadoop.jar org.elasticsearch.hadoop.cli.Keytool create


Used the keystore on the conf.

    es_write_conf = {
       
"es.nodes" : "esm1,esm2,esm3",

       
"es.port" : "9200",
       
"es.input.json": "true",
       
"es.nodes.ingest.only": "true",

       
"es.net.http.auth.user": "admin",
       
"es.net.http.auth.pass": "admin",
       
"es.net.ssl":"true",
       
"es.net.ssl.cert.allow.self.signed":"true",
       
"es.net.ssl.keystore.location":"file:///home/hdfs/test/esh.keystore",
   
}



Error received :

Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.saveAsNewAPIHadoopFile.
: 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.discoverEsVersion(InitializationUtils.java:327)
 at org
.elasticsearch.hadoop.mr.EsOutputFormat.init(EsOutputFormat.java:260)
 at org
.elasticsearch.hadoop.mr.EsOutputFormat.checkOutputSpecs(EsOutputFormat.java:233)
 at org
.apache.spark.internal.io.HadoopMapReduceWriteConfigUtil.assertConf(SparkHadoopWriter.scala:387)
 at org
.apache.spark.internal.io.SparkHadoopWriter$.write(SparkHadoopWriter.scala:71)
 at org
.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsNewAPIHadoopDataset$1.apply$mcV$sp(PairRDDFunctions.scala:1083)
 at org
.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsNewAPIHadoopDataset$1.apply(PairRDDFunctions.scala:1081)
 at org
.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsNewAPIHadoopDataset$1.apply(PairRDDFunctions.scala:1081)
 at org
.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
 at org
.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
 at org
.apache.spark.rdd.RDD.withScope(RDD.scala:363)
 at org
.apache.spark.rdd.PairRDDFunctions.saveAsNewAPIHadoopDataset(PairRDDFunctions.scala:1081)
 at org
.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsNewAPIHadoopFile$2.apply$mcV$sp(PairRDDFunctions.scala:1000)
 at org
.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsNewAPIHadoopFile$2.apply(PairRDDFunctions.scala:991)
 at org
.apache.spark.rdd.PairRDDFunctions$$anonfun$saveAsNewAPIHadoopFile$2.apply(PairRDDFunctions.scala:991)
 at org
.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
 at org
.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
 at org
.apache.spark.rdd.RDD.withScope(RDD.scala:363)
 at org
.apache.spark.rdd.PairRDDFunctions.saveAsNewAPIHadoopFile(PairRDDFunctions.scala:991)
 at org
.apache.spark.api.python.PythonRDD$.saveAsNewAPIHadoopFile(PythonRDD.scala:534)
 at org
.apache.spark.api.python.PythonRDD.saveAsNewAPIHadoopFile(PythonRDD.scala)
 at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java
.lang.reflect.Method.invoke(Method.java:498)
 at py4j
.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
 at py4j
.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
 at py4j
.Gateway.invoke(Gateway.java:282)
 at py4j
.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
 at py4j
.commands.CallCommand.execute(CallCommand.java:79)
 at py4j
.GatewayConnection.run(GatewayConnection.java:214)
 at java
.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.hadoop.rest.EsHadoopTransportException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
 at org
.elasticsearch.hadoop.rest.NetworkClient.execute(NetworkClient.java:124)
 at org
.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:380)
 at org
.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:344)
 at org
.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:348)
 at org
.elasticsearch.hadoop.rest.RestClient.get(RestClient.java:158)
 at org
.elasticsearch.hadoop.rest.RestClient.remoteEsVersion(RestClient.java:574)
 at org
.elasticsearch.hadoop.rest.InitializationUtils.discoverEsVersion(InitializationUtils.java:320)
 
... 31 more


Tried adding the keystore to cacerts but it could not be added. :
keytool -importcert -alias local-CA -keystore /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/lib/security/cacerts -file esh.keystore

Enter keystore password:  
keytool error: java.lang.Exception: Input not an X.509 certificate

SG

unread,
Sep 27, 2018, 8:40:32 AM9/27/18
to search...@googlegroups.com
The keystore must match the issued certificate of course (either directly or via an intermediate/root certificate)

Try

keytool -importcert -alias local-CA -keystore "chain-ca.pem" -file esh.keystore or
keytool -importcert -alias local-CA -keystore "CN=esm1.crtfull.pem" -file esh.keystore

Pls see
https://search-guard.com/elasticsearch-searchguard-tls-introduction/
https://www.elastic.co/guide/en/elasticsearch/hadoop/current/security.html
https://docs.search-guard.com/latest/online-tls-generator
https://docs.search-guard.com/latest/offline-tls-tool
> --
> You received this message because you are subscribed to the Google Groups "Search Guard Community Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to search-guard...@googlegroups.com.
> To post to this group, send email to search...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/search-guard/26c9aebf-f62c-41c0-944c-f7b4aa95260f%40googlegroups.com.

Steven Suting

unread,
Oct 3, 2018, 6:41:59 AM10/3/18
to Search Guard Community Forum
That fixed it, thank you.
Reply all
Reply to author
Forward
0 new messages