es命令删除索引数据_elasticsearch常用命令

#查看健康状态

curl -XGET 127.0.0.1:9200/_cluster/health?pretty

#查看所有shard

curl -XGET 'http://localhost:9200/_cat/shards'

#查看index

curl -XGET 127.0.0.1:9200/index_name/_settings?pretty

#删除index

curl -XDELETE localhost:9200/index_name

常见错误

1。max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

sudo vim /etc/security/limits.conf

username hard nofile 65536

2。memory locking requested for elasticsearch process but memory is not locked

sudo vim /etc/security/limits.conf

username soft memlock unlimited

username hard memlock unlimited

3。max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[root@centos7.4-64 ~]# vim /etc/sysctl.conf

添加配置:vm.max_map_count=262144,然后执行命令

[root@centos7.4-64 ~]# sysctl -p

性能优化

原则:

副本多:优点:查询速度快,容错性高

缺点:插入速度变慢

分片多:优点:插入速度快

缺点:查询速度慢

1.删除文档:在es中删除文档,数据不会马上在硬盘上除去,而是在es索引中产生一个.del的文件,而在检索过程中这部分数据也会参与检索,es在检索过程会判断是否删除了,如果删除了在过滤掉。这样也会降低检索效率。所以可以执行清除删除文档

curl -XPOST 'http://127.0.0.1:9200/index_name/_forcemerge?only_expunge_deletes=true'

2.索引量不是很大的话情况下可以将segment设置为1

curl -XPOST "http://localhost:9200/index_name/_forcemerge?max_num_segments=1"

3.设置副本为0

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

4.设置刷新时间为-1

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

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值