我在群集模式的Docker容器中遇到了ES 5.6.5的奇怪问题。这是相关代码:
from elasticsearch import Elasticsearch
from settings import ES_HOSTS
db = Elasticsearch(hosts=ES_HOSTS)
db.indices.exists(index=product_id)
它在后台执行HTTP HEAD请求,并且该请求超时,从未得到响应。我通过使用curl(curl -X HEAD http://elasticsearch:9200/85a9b708-e89d-11e7-887a-02420aff0008
)执行相同的HEAD请求来确认它确实超时了。其他请求工作得很好。例如,如果我对上述URL执行GET请求,则会收到预期错误,指出索引不存在。
当我在我的计算机上的独立docker容器上运行相同的ES映像时,配置完全相同的方式并使用相同的代码进行调用,它可以正常运行。
以下是相关的群组配置部分:
elasticsearch:
image: "docker.elastic.co/elasticsearch/elasticsearch:5.6.5"
environment:
- cluster.name=raul_elasticsearch
- xpack.security.enabled=false
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- esdata:/usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
deploy:
resources:
limits:
memory: 6G
reservations:
memory: 6G
这是我为拥有一个独立的ES docker容器而运行的命令:
docker run --rm -p 9200:9200 -p 9300:9300 -e "bootstrap.memory_lock=true" -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "xpack.security.enabled=false" -d --name raul_elasticsearch docker.elastic.co/elasticsearch/elasticsearch:5.6.5
有关可能导致此问题的任何想法?
UPDATE1:查看来自docker swarm中运行的ES的调试日志,我收到以下消息:
Dec 24 17:10:33: [2017-12-24T17:10:33,839][DEBUG][r.suppressed ] path: /85a9b708-e89d-11e7-887a-02420aff0008, params: {index=85a9b708-e89d-11e7-887a-02420aff0008}
Dec 24 17:10:33: org.elasticsearch.index.IndexNotFoundException: no such index
Dec 24 17:10:33: at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.infe(IndexNameExpressionResolver.java:676) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.innerResolve(IndexNameExpressionResolver.java:630) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.resolve(IndexNameExpressionResolver.java:578) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndices(IndexNameExpressionResolver.java:168) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndexNames(IndexNameExpressionResolver.java:144) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndexNames(IndexNameExpressionResolver.java:77) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.admin.indices.get.TransportGetIndexAction.checkBlock(TransportGetIndexAction.java:63) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.admin.indices.get.TransportGetIndexAction.checkBlock(TransportGetIndexAction.java:47) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.doStart(TransportMasterNodeAction.java:134) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.start(TransportMasterNodeAction.java:126) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:104) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:54) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:170) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:142) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:84) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.client.node.NodeClient.executeLocally(NodeClient.java:83) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:72) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1256) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.getIndex(AbstractClient.java:1357) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.rest.action.admin.indices.RestGetIndicesAction.lambda$prepareRequest$0(RestGetIndicesAction.java:97) ~[elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:80) [elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:262) [elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:200) [elasticsearch-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.http.netty4.Netty4HttpServerTransport.dispatchRequest(Netty4HttpServerTransport.java:505) [transport-netty4-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.channelRead0(Netty4HttpRequestHandler.java:80) [transport-netty4-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at org.elasticsearch.http.netty4.pipelining.HttpPipeliningHandler.channelRead(HttpPipeliningHandler.java:68) [transport-netty4-5.6.5.jar:5.6.5]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [netty-codec-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) [netty-codec-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284) [netty-codec-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:544) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-common-4.1.13.Final.jar:4.1.13.Final]
Dec 24 17:10:33: at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
此外,我也收到这些消息,其中大部分消息似乎与周期性任务有关,但有一个消息引起了我的注意:Can not start an object, expecting field name (context: Object)
Dec 24 17:10:36: [2017-12-24T17:10:36,919][DEBUG][o.e.x.m.a.GetDatafeedsStatsAction$TransportAction] [hPjV7-n] Get stats for datafeed '_all'
Dec 24 17:10:36: [2017-12-24T17:10:36,923][DEBUG][o.e.x.m.e.l.LocalExporter] monitoring index templates and pipelines are installed on master node, service can start
Dec 24 17:10:46: [2017-12-24T17:10:46,932][DEBUG][o.e.x.m.a.GetDatafeedsStatsAction$TransportAction] [hPjV7-n] Get stats for datafeed '_all'
Dec 24 17:10:46: [2017-12-24T17:10:46,935][DEBUG][o.e.x.m.e.l.LocalExporter] monitoring index templates and pipelines are installed on master node, service can start
Dec 24 17:10:56: [2017-12-24T17:10:56,920][DEBUG][o.e.x.m.a.GetDatafeedsStatsAction$TransportAction] [hPjV7-n] Get stats for datafeed '_all'
Dec 24 17:10:56: [2017-12-24T17:10:56,927][DEBUG][o.e.x.m.e.l.LocalExporter] monitoring index templates and pipelines are installed on master node, service can start
Dec 24 17:10:58: [2017-12-24T17:10:58,707][DEBUG][o.e.x.w.e.ExecutionService] [hPjV7-n] saving watch records [4]
Dec 24 17:10:58: [2017-12-24T17:10:58,711][DEBUG][o.e.x.w.e.ExecutionService] [hPjV7-n] executing watch [fxCyOMU8STOiNqoLUtOQhQ_kibana_version_mismatch]
Dec 24 17:10:58: [2017-12-24T17:10:58,711][DEBUG][o.e.x.w.e.ExecutionService] [hPjV7-n] executing watch [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_cluster_status]
Dec 24 17:10:58: [2017-12-24T17:10:58,711][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_kibana_version_mismatch_4e9bb936-dc65-4795-8be3-b2b2c1660460-2017-12-24T17:10:58.707Z] found [0] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,711][DEBUG][o.e.x.w.e.ExecutionService] [hPjV7-n] executing watch [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_version_mismatch]
Dec 24 17:10:58: [2017-12-24T17:10:58,712][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_kibana_version_mismatch_4e9bb936-dc65-4795-8be3-b2b2c1660460-2017-12-24T17:10:58.707Z] found [0] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,713][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_version_mismatch_0a13442f-96dc-4732-b0de-1e87a9dc05ab-2017-12-24T17:10:58.707Z] found [0] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,714][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_version_mismatch_0a13442f-96dc-4732-b0de-1e87a9dc05ab-2017-12-24T17:10:58.707Z] found [0] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,714][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_cluster_status_b35f5be6-4d4b-4fa2-a50c-6f18d4b6d949-2017-12-24T17:10:58.707Z] found [15178] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,715][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_cluster_status_b35f5be6-4d4b-4fa2-a50c-6f18d4b6d949-2017-12-24T17:10:58.707Z] hit [{
Dec 24 17:10:58: "error" : "Can not start an object, expecting field name (context: Object)"
Dec 24 17:10:58: }]
Dec 24 17:10:58: [2017-12-24T17:10:58,716][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_cluster_status_b35f5be6-4d4b-4fa2-a50c-6f18d4b6d949-2017-12-24T17:10:58.707Z] found [1] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,716][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_elasticsearch_cluster_status_b35f5be6-4d4b-4fa2-a50c-6f18d4b6d949-2017-12-24T17:10:58.707Z] hit [{
Dec 24 17:10:58: "error" : "Can not start an object, expecting field name (context: Object)"
Dec 24 17:10:58: }]
Dec 24 17:10:58: [2017-12-24T17:10:58,718][DEBUG][o.e.x.w.e.ExecutionService] [hPjV7-n] executing watch [fxCyOMU8STOiNqoLUtOQhQ_logstash_version_mismatch]
Dec 24 17:10:58: [2017-12-24T17:10:58,718][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_logstash_version_mismatch_c88db510-0a7e-4520-a085-8381f4278288-2017-12-24T17:10:58.707Z] found [0] hits
Dec 24 17:10:58: [2017-12-24T17:10:58,719][DEBUG][o.e.x.w.i.s.ExecutableSimpleInput] [hPjV7-n] [fxCyOMU8STOiNqoLUtOQhQ_logstash_version_mismatch_c88db510-0a7e-4520-a085-8381f4278288-2017-12-24T17:10:58.707Z] found [0] hits
(我不知道它为什么抱怨Kibana和Logstash,我没有安装它们)
更新2:使用curl的--head
参数代替-X HEAD
使其有效。不知道为什么。要求详细输出产生这个:
$ curl -v --head http://localhost:9200/85a9b708-e89d-11e7-887a-02420aff0008
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
> HEAD /85a9b708-e89d-11e7-887a-02420aff0008 HTTP/1.1
> Host: localhost:9200
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< content-type: application/json; charset=UTF-8
content-type: application/json; charset=UTF-8
< content-length: 467
content-length: 467
这是预期的响应,命令正常退出。
然而,这永远不会退出:
$ curl -v -X HEAD http://localhost:9200/85a9b708-e89d-11e7-887a-02420aff0008
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
> HEAD /85a9b708-e89d-11e7-887a-02420aff0008 HTTP/1.1
> Host: localhost:9200
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< content-type: application/json; charset=UTF-8
< content-length: 467
<
第二个命令的警告是什么?
答案 0 :(得分:0)
看起来这是我正在使用的elasticsearch == 5.4.0库中的一个错误。将其更新到更新的版本(5.5.1)解决了这个问题。