es数据量过大,内存撑不住,关闭部分历史数据索引,以及备份删除索引

关闭索引命令

curl -XPOST http://ip:9200/索引名称/_close

恢复索引命令

curl -XPOST http://ip:9200/*202205*/_open

遇到问题索引权限问题关闭失败

{"type":"cluster_block_exception","reason":"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}

修改权限

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

备份数据

备份索引数据

注:以下索引名可用*模糊匹配如:*index*

1. 备份索引映射(Mapping)

./elasticdump \

--input=http://127.0.0.1:9200/索引名 \

--output=索引名-mapping.json \

--type=mapping

2. 备份索引数据

./elasticdump \

--input=http://127.0.0.1:9200/索引名 \

--output=索引名-data.json \

--type=data \

--limit=1000

以上两步执行完成后会在当前目录生成"索引名-mapping.json"和"索引名-data.json"两个文件,里面包含指定索引的映射信息和数据

(三)还原索引数据

数据还原时只需要将第二节数据备份中的命令的input和output对调即可

1. 还原索引映射(Mapping)

./elasticdump \

--input=索引名-mapping.json \

--output=http://127.0.0.1:9200/索引名 \

--type=mapping

2. 还原索引数据

./elasticdump \

--input=索引名-data.json \

--output=http://127.0.0.1:9200/索引名\

--type=data \

--limit=1000

删除索引

curl -XDELETE  http://{IP}:9200/索引名

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值