ElasticSearch 创建索引超时(ReadTimeoutError)

报错现象

在 Python 中调用 client.indices.create 来创建 ElasticSearch 索引时,报如下错误:

python 复制代码
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))

问题分析

在查阅网络资料时,一开始以为是字面意思上的连接超时问题,但调大 timeout 参数也一样报错,而且之前用相同方法创建类似索引时并未出现该问题。

最后,受博文(https://blog.csdn.net/ckq707718837/article/details/136215814)的启发,查看 ElasticSearch 的日志(如下所示),才发现问题所在:电脑磁盘快满了,ES 自动把索引的状态由黄转红,变成只读状态,无法写入

elasticsearch.log(节选内容)

python 复制代码
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

问题解决(两种方法)

相关推荐
莓有烦恼吖2 分钟前
Vibe Coding 的一些思考
python
切糕师学AI3 分钟前
如何查看已合并到 master 分支的所有分支?Git 分支清理指南
大数据·git·elasticsearch
小白学大数据4 分钟前
超简单:用 Python 让 Excel 飞起来:用 openpyxl 把重复报表整理交给脚本
开发语言·数据库·python·excel
爱丶不疚20 分钟前
写给前端工程师的现代 Python 工程化最佳实践:从 pnpm 到 uv,从 CommonJS 到 src-layout
javascript·python·typescript
suaizai_20 分钟前
从1210条报错到全自动修复:AI闭环运维实战
大数据·elasticsearch·搜索引擎
2601_9622972538 分钟前
C# vs Java vs Python:YOLO工业部署性能对比实战
java·python·c·工业视觉·性能对比
CTA终结者1 小时前
示例、拆解和练习,要连成一条量化补课线
人工智能·python
lolijiaqi151 小时前
一线观察:长期体验后发现的医疗器械 CDMO 底层现象
大数据·python
spencer_tseng2 小时前
[j2cache ehcache.xml]/tmp/.ehcache-diskstore.lock (Permission denied)
xml·linux·python·ehcache·[j2cache
梦想不只是梦与想2 小时前
Python Web 框架:FastAPI
python·fastapi·web框架