当前位置: 首页 > news >正文

Elasticsearch常用命令

以下是 Elasticsearch 查看集群状态配置和索引完整操作流程的详细命令:

一、查看集群状态与配置

1. 集群健康状态
curl -X GET "localhost:9200/_cluster/health?pretty"
关键参数:
level=indices:显示每个索引的健康状态
level=shards:显示每个分片的详细状态健康状态说明:
- `green`:所有主分片和副本分片都正常。
- `yellow`:主分片正常,但至少有一个副本分片缺失。
- `red`:至少有一个主分片不可用。

输出示例:

{"cluster_name": "my_cluster","status": "green",                 # 集群状态:green/yellow/red"number_of_nodes": 3,"number_of_data_nodes": 2,"active_primary_shards": 15,"active_shards": 30,...
}
2. 集群节点信息
curl -X GET "localhost:9200/_nodes?pretty"
_nodes/stats:查看节点统计信息(CPU、内存、JVM 等)
_nodes/process:查看进程信息
3. 集群状态详细信息
curl -X GET "localhost:9200/_cluster/state?pretty"
包含分片分配、元数据、路由表等信息
4. 集群设置(动态配置)
#获取当前动态设置
curl -X GET "localhost:9200/_cluster/settings?include_defaults=true&pretty"#临时修改集群块级别(禁止写操作)
curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"transient": {"cluster.blocks.read_only_allow_delete": true}
}
'

二、索引操作完整流程

1. 创建索引(带映射)
curl -X PUT "localhost:9200/my_index?pretty" -H 'Content-Type: application/json' -d'
{"settings": {"number_of_shards": 3,          # 主分片数量"number_of_replicas": 1         # 每个主分片的副本数},"mappings": {"properties": {"title": { "type": "text" },"user": {"type": "nested",           # 嵌套对象"properties": {"id": { "type": "keyword" },"name": { "type": "text" }}},"timestamp": { "type": "date" }}}
}
'

创建索引别名

POST /_aliases
{
"actions":[{"add": {"index": "my_index","alias": "my_alias"}   ]
}#删除别名
POST /_aliases
{
"actions":[{"remove": {"index": "my_index","alias": "my_alias"}   ]
}#更新别名POST /_aliases
{
http://www.xdnf.cn/news/571159.html

相关文章:

  • 宁夏建设工程专业技术职称评审条件
  • 嵌入式Linux:移植使用scp指令
  • Java多线程深度解析:从核心机制到高阶实战
  • upload-labs通关笔记-第16关 文件上传之exif_imagetype绕过(图片马)
  • springcloud集成seata报错Error creating bean with name ‘globalTransactionScanner‘
  • 解决RedisTemplate的json反序列泛型丢失问题
  • SpringAI开发SSE传输协议的MCP Server
  • 安卓开发用到的设计模式(1)创建型模式
  • OpenCv高阶(十四)——LBPH人脸识别
  • 如何用 Qwen1.5-7B-Chat 模型打造高效轻量的 Python 智能助手(详细实操指南)
  • Windows在PowerShell或CMD运行 curl 命令报错 解决办法 (zx)
  • 如何支持Enhanced RTMP H.265(HEVC)
  • 蓝耘Ubantu服务器测试最新 PP-StructureV3 教程
  • linux 查看java的安装路径
  • Java面试问题基础篇
  • Wireshark 抓包工具使用
  • Visual Studio Code插件离线安装指南:从市场获取并手动部署
  • Android Framework学习八:SystemServer及startService原理
  • 鸿蒙开发——9.wrapBuilder与@BuilderParam对比解析
  • Oracle 11g post PSU Oct18 设置ssl连接(使用jks)
  • 拉普拉斯高斯(LoG)滤波器掩模的注意事项
  • 计及可再生能源不确定性的经济优化调度方法
  • AI与IT从业者的关系更似“进化催化剂“而非“职业终结者“
  • 太阳能电池IV测试设备AAA型AMG1.5太阳光模拟器
  • 道可云人工智能每日资讯|浙江省人民政府印发《关于支持人工智能创新发展的若干措施》
  • [特殊字符] 遇见Flask
  • 【HTML-4】HTML段落标签:构建内容结构的基础
  • 递归+反射+注解(动态拼接建表语句)
  • 机动车授权签字人有哪些权利和义务?
  • 【Element UI排序】JavaScript 的表格排序sortable=“custom“和 @sort-change