es:curl訪問es時返回為空(elasticsearch 8.14.2)

刘宏缔的架构森林發表於2024-07-08

一,返回為空:

[lhdop@blog ~]$ curl localhost:9200/_cluster/health?pretty
curl: (52) Empty reply from server
[lhdop@blog ~]$ curl localhost:9200
curl: (52) Empty reply from server
[lhdop@blog ~]$ curl http://localhost:9200
curl: (52) Empty reply from server

檢視日誌:

[2024-07-08T13:14:29,123][WARN ][o.e.c.r.a.DiskThresholdMonitor] [blog] flood stage disk watermark [95%] 
exceeded on [xcmI6v6SSFKqLp5qXM-sOw][blog][/usr/local/soft/elasticsearch/data] free: 1.7gb[1.7%],
all indices on this node will be marked read-only

得知磁碟使用率超出閾值,es索引模式變為只讀,無法寫入資料,從而返回資料失敗

解決:

  • 清理磁碟空間

因為Elasticsearch 會對磁碟空間進行監控,當磁碟剩餘空間達到了 floodstage 閾值,會將所有相關索引強制置為只讀。

需要清理磁碟空間後,才能寫入資料。

二,返回為空,日誌中報錯:

[2024-07-08T13:29:32,165][WARN ][o.e.h.n.Netty4HttpServerTransport] 
[blog] received plaintext http traffic on an https channel, 
closing connection Netty4HttpChannel{localAddress=/127.0.0.1:9200, remoteAddress=/127.0.0.1:60490}

錯誤原因:ES8預設開啟了 ssl 認證。
解決方案:elasticsearch.yml配置檔案
xpack.security.enabled設定為false

修改配置檔案:

[lhdop@blog logs]$ cd /usr/local/soft/elasticsearch/config/
[lhdop@blog config]$ vi elasticsearch.yml 

修改內容:

# xpack.security.enabled: true
xpack.security.enabled: false

修改完成重啟服務,
可以正常返回資料了:

[lhdop@blog config]$ curl localhost:9200
{
  "name" : "blog",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "aAr5708zRyS0wQZ9FcNdkA",
  "version" : {
    "number" : "8.14.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "2afe7caceec8a26ff53817e5ed88235e90592a1b",
    "build_date" : "2024-07-01T22:06:58.515911606Z",
    "build_snapshot" : false,
    "lucene_version" : "9.10.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

三,檢視es的版本:

[lhdop@blog config]$ /usr/local/soft/elasticsearch/bin/elasticsearch --version
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-15; using bundled JDK
Version: 8.14.2, Build: tar/2afe7caceec8a26ff53817e5ed88235e90592a1b/2024-07-01T22:06:58.515911606Z, JVM: 22.0.1

相關文章