報錯現(xiàn)象
在 Python 中調(diào)用 client.indices.create
來創(chuàng)建 ElasticSearch 索引時,報如下錯誤:
elastic_transport.transport - INFO - PUT http://127.0.0.1:9200/document_page?timeout=60s [status:N/A duration:10.011s]
elastic_transport.node_pool - WARNING - Node <Urllib3HttpNode(http://127.0.0.1:9200)> has failed for 1 times in a row, putting on 1 second timeout
elastic_transport.transport - WARNING - Retrying request after failure (attempt 0 of 3)
Traceback (most recent call last):
File "C:\Users\15797\.conda\envs\ppkg\lib\site-packages\elastic_transport\_transport.py", line 329, in perform_request
meta, raw_data = node.perform_request(
File "C:\Users\15797\.conda\envs\ppkg\lib\site-packages\elastic_transport\_node\_http_urllib3.py", line 199, in perform_request
raise err from None
elastic_transport.ConnectionTimeout: Connection timeout caused by: ReadTimeoutError(HTTPConnectionPool(host='127.0.0.1', port=9200): Read timed out. (read timeout=10.0))
問題分析
在查閱網(wǎng)絡(luò)資料時,一開始以為是字面意思上的連接超時問題,但調(diào)大 timeout 參數(shù)也一樣報錯,而且之前用相同方法創(chuàng)建類似索引時并未出現(xiàn)該問題。
最后,受博文(https://blog.csdn.net/ckq707718837/article/details/136215814)的啟發(fā),查看 ElasticSearch 的日志(如下所示),才發(fā)現(xiàn)問題所在:電腦磁盤快滿了,ES 自動把索引的狀態(tài)由黃轉(zhuǎn)紅,變成只讀狀態(tài),無法寫入。文章來源:http://www.zghlxwxcb.cn/news/detail-855388.html
elasticsearch.log(節(jié)選內(nèi)容)文章來源地址http://www.zghlxwxcb.cn/news/detail-855388.html
current.health="RED" message="Cluster health status changed from [YELLOW] to [RED] (reason: [reconcile-desired-balance])." previous.health="YELLOW" reason="reconcile-desired-balance"
flood stage disk watermark [95%] exceeded on [D:\Softwares\elasticsearch-8.6.0\data] free: 5.8gb[2.1%], all indices on this node will be marked read-only
問題解決(兩種方法)
- (推薦)清理磁盤,釋放更多空余空間,再重啟 ElasticSearch;
- 調(diào)整 ElasticSearch 配置,可參考博文(https://blog.csdn.net/liaomingwu/article/details/115425880)
到了這里,關(guān)于ElasticSearch 創(chuàng)建索引超時(ReadTimeoutError)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!