使用Spring Data ES搜索Guard

时间:2017-06-14 01:36:01

标签: elasticsearch spring-data-elasticsearch

我按照here提到的步骤使用SearchGuard保护我的本地ES安装(SO上没有标记)。现在,只有通过基本身份验证才能通过Postman访问它,并使用用户名密码作为默认admin/admin

现在,我需要允许我的Spring Data ES项目能够访问此ES安装。

我试过了:

Settings esSettings = Settings.settingsBuilder()
            .put("path.home", ".")
            .put("cluster.name", clusterName)
            .put("searchguard.ssl.transport.enabled", true)
            .put("searchguard.ssl.transport.keystore_filepath", "kirk-keystore.jks")
            .put("searchguard.ssl.transport.truststore_filepath", "truststore.jks")
            .put("searchguard.ssl.transport.enforce_hostname_verification", false)
            .put("request.headers.sg.impersonate.as", "admin")
            .build();

TransportClient client = TransportClient.builder().settings(esSettings)
            .build().addTransportAddress(
            new InetSocketTransportAddress(InetAddress.getByName(elasticsearchHost), elasticsearchPort));

client.prepareGet().putHeader("Authorization", "Basic " + Base64.encodeBase64("admin:admin".getBytes())).get();

return client;

按照建议here添加了标题。

但我得到的只是:

[elasticsearch[Meteorite][generic][T#3]] INFO  org.elasticsearch.client.transport - 
[Meteorite] failed to get node info for {#transport#-1}{127.0.0.1}{127.0.0.1:9300}, disconnecting...
org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected

我需要在ES(2.4.4)中获取和发布新数据。

0 个答案:

没有答案