elastic常用高频命令

本文提供了Elasticsearch的常用操作教程,包括查看节点信息、集群信息、索引状态及健康检查等,还介绍了如何批量创建索引及调整索引设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.查看单个节点信息

curl http://127.0.0.1:9200

2.查看集群信息

curl http://127.0.0.1:9200/_cat/nodes?v

3.查看单节点索引信息

 curl -X GET '127.0.0.1:9200/_cat/indices?v'

4.查看集群健康检查

curl -XGET 'http://127.0.0.1:9200/_cluster/health?pretty=true'

5.处理index read-only/ allow delete 

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

6.kibana 自动创建索引配置

curl -f -XPOST -H 'Content-Type: application/json' -H 'kbn-xsrf: anything' \
    "http://127.0.0.1:5601/api/saved_objects/index-pattern/logname-{$date}" -d"{\"attributes\":{\"title\":\"logname*\",\"timeFieldName\":\"@timestamp\"}}"

7.批量调整索引yellow,设置副本集为0

curl -XPUT "http://localhost:9200/_settings" -H 'Content-Type: application/json' -d'
{
    "index" : {
        "number_of_replicas" : 0
     }
}'

8.恢复副本集为1

curl -XPUT "http://localhost:9200/_settings" -H 'Content-Type: application/json' -d'
{
    "index" : {
        "number_of_replicas" : 1
     }
}'

9.kibana 创建索引,$index 为需要创建的索引

curl -f -XPOST -H 'Content-Type: application/json' -H 'kbn-xsrf: anything'     "http://127.0.0.1:5601/api/saved_objects/index-pattern/$index-{$date}" -d"{\"attributes\":{\"title\":\"$index*\",\"timeFieldName\":\"@timestamp\"}}"

10. kibana 批量创建索引

file=demo.txt
#获取索引文件行数
num=`wc -l ${file} | awk '{print $1}'`
echo  $num
#开始循环创建索引
for((i=1;i<=${num};i++));
do

   echo "for循环--$i"
   index=`sed -n "${i}p" $file | awk '{print $1}'`
   echo "索引名称: "$index
curl -f -XPOST -H 'Content-Type: application/json' -H 'kbn-xsrf: anything' \
    "http://127.0.0.1:5601/api/saved_objects/index-pattern/${index}-{$date}" -d"{\"attributes\":{\"title\":\"${index}*\",\"timeFieldName\":\"@timestamp\"}}"
done

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值