#查看健康状态
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/
username hard nofile 65536
2。memory locking requested for elasticsearch process but memory is not locked
sudo vim /etc/security/
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/
添加配置: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" }}'