【发布时间】:2017-06-22 20:59:10
【问题描述】:
(首先,我知道Can not connect to elasticsearch container in docker。我的问题仍然存在。)
我正在 ElasticSearch 上踢轮胎。
我有run the official Docker image from the command line as described in the official documentation,将cluster.name 指定为elasticsearch(文档声称这是默认设置,但检查显示它实际上默认为docker-cluster):
$ docker run -p 9200:9200 -p 9300:9300 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -e "xpack.security.enabled=false" -e "cluster.name=elasticsearch" docker.elastic.co/elasticsearch/elasticsearch:5.4.2
你会注意到我有disabled the X-Pack security, following official documentation。
你会注意到我已经暴露了端口 9200 和端口 9300。
浏览器指向http://localhost:9200/_cat/health的结果是:
1498166019 21:13:39 docker-cluster yellow 1 1 3 3 0 0 3 0 - 50.0%
...这并没有让我充满信心,但我猜,当您按照 official documentation 运行操作时,这就是您所得到的。
无论如何,接下来,我使用 Java 构建了 Client,如下所示:
this.client = new PreBuiltTransportClient(Settings.builder()
.put("cluster.name", "elasticsearch")
.put("client.transport.sniff", true)
.build())
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300));
您会注意到我已将127.0.0.1 指定为主机名(与transport.host 属性匹配),将9300 指定为端口(与公开的端口匹配)。
然后我运行:this.client.prepareGet("argle", "bargle", "1").get();。我期待看到某种“嘿,笨蛋,argle 不存在”错误。
相反,这会导致可怕的:
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{q00tH2RKTlCkXut03lYHOg}{127.0.0.1}{127.0.0.1:9300}]]
我做错了什么?官方文档哪部分不正确?
【问题讨论】:
标签: java elasticsearch