elasticsearch “curl:(52)来自服务器的空回复”/查询ElastiscSearch时超时

2ledvvac  于 2022-12-03  发布在  ElasticSearch
关注(0)|答案(6)|浏览(241)

我遇到了一个恼人的问题与我的ElasticSearch(版本1.5.2):查询立即返回超时(当我使用python的Requests时)或
curl:(52)来自服务器的空回复
当我使用curl时
这只发生在预期输出很大的时候。当我发送一个类似的(但更小的)查询时,它回来得很好。
这是怎么回事?我该怎么克服?

vcirk6k6

vcirk6k61#

刚打开

sudo nano  /etc/elasticsearch/elasticsearch.yml

and replace this setting with false
# Enable security features
xpack.security.enabled: false
qnyhuwrf

qnyhuwrf2#

另一种解释是在群集上激活ssl/security时发出http请求。
在这种情况下,请使用

curl -X GET "https://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s&pretty" --key certificates/elasticsearch-ca.pem  -k -u elasticuser
7hiiyaii

7hiiyaii3#

我在最新版本的Elasticsearh 8.1.3上遇到了同样的问题。我通过将/config/elasticsearch.yml文件中的以下设置从true更改为false来修复此问题:

# Enable security features
xpack.security.enabled: false

我通过下载tar文件安装了elastic,并解压缩它,然后转到elasticsearch的文件夹,并运行以下命令:

./bin/elasticsearch

第一次运行此命令时,它将使用以下内容更改elasticsearch.yml文件,这意味着它是自动生成的默认安全设置:

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 01-05-2022 06:59:12
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: true

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["DaMings-MacBook-Pro.local"]

# Allow HTTP API connections from localhost and local networks
# Connections are encrypted and require user authentication
http.host: [_local_, _site_]

# Allow other nodes to join the cluster from localhost and local networks
# Connections are encrypted and mutually authenticated
#transport.host: [_local_, _site_]

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
2q5ifsrm

2q5ifsrm4#

此问题是由Elastic内存不足引起的:它无法在内存中保存所有文档。不幸的是,对于这种情况没有显式的错误代码。
除了增加更多内存之外,还有很多方法可以解决这个问题:
1.您可以通过指定“_source:false”。结果将只列出相关文档(您需要检索它们)。
1.如果您不需要整个文档,可以使用“source filtering“只返回文档的一部分-这对我很有效。
1.你也可以把你的查询拆分成一堆子查询。不漂亮,但它会起作用。

6ljaweal

6ljaweal5#

在6.2版本中,有更严格的检查。
例如:

curl -XPUT -H'Content-Type: application/json' 'http://localhost:9200/us/user/2?pretty=1' -d '{"email" : "mary@jones.com", "name" : "Mary Jones","username" : "@mary"}'
curl: (52) Empty reply from server

如果删除=1:

curl -XPUT -H'Content-Type: application/json' 'http://localhost:9200/us/user/2?pretty' -d '{"email" : "mary@jones.com", "name" : "Mary Jones","username" : "@mary"}'
{
  "_index" : "us",
  "_type" : "user",
  "_id" : "2",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

它起作用了!

1cosmwyk

1cosmwyk6#

在我的例子中,这是因为端点url中缺少url方案https://

相关问题