其他分享
首页 > 其他分享> > es常用命令

es常用命令

作者:互联网

1.查看es错误信息

curl GET 'http://192.168.10.1:9202/_cluster/allocation/explain?pretty'

2.磁盘只读问题处理

1.根据报错内容找到对应node_id
curl GET 'http://192.168.10.1:9202/_cluster/allocation/explain?pretty' |grep "node_id"
2.找到对应ip及磁盘位置 echo "a" > 只读路径
进入/opt/elasticsearch-a/config/elasticsearch.yml //注释相关磁盘
3.过滤es服务
ps -ef |grep elasticsearch-a //有三个,每次kill一个服务,起一个服务,然后再kill下一个服务
kill -9 xxxxx //kill es服务
4.启动es服务
./bin/elasticsearch-a -d
curl -s "http://192.168.10.1:9202/_cluster/health?pretty" //查看服务状态,增加后kill下一个服务
过滤相关为分片
curl -s "http://192.168.10.1:9200/_cat/shards" | grep UNASSIGNED 

3.处理相关分片

总共分四步
1.  curl -X PUT "http://192.168.10.1:9200/_cluster/settings" -H 'Content-Type: application/json' -d '{"persistent":{"cluster.routing.allocation.enable":"none"}}'
2.  curl -X  POST "http://192.168.10.1:9200//_cluster/reroute?retry_failed=true"
3.  curl -X PUT "http://192.168.10.1:9200/_cluster/settings" -H 'Content-Type: application/json' -d '{"persistent":{"cluster.routing.allocation.enable":"all"}}'
4.//手动处理为分片
 curl -X POST "http://192.168.10.1:9200/_cluster/reroute" -H 'Content-Type: application/json' -d '{"commands":[{"allocate_replica":{"index":"bus_adver","shard":0,"node":"fLa2s_1WTUizV6UAPTuW1w"}}]}'
curl -X POST "http://192.168.10.1:9200/_cluster/reroute" -H 'Content-Type: application/json' -d '{"commands":[{"allocate_replica":{"index":"bus_adver","shard":0,"node":"0JX8yOLZTzqGVccsh1UEcQ"}}]}'
如手动处理失败,过滤为分片信息
curl -s "http://192.168.10.1:9200/_cat/shards" | grep UNASSIGNED
删除该未分片信息
curl -X DELETE "http://ip:port/xxxxxxx"
查看服务状态
curl -s "http://192.168.10.1:9202/_cluster/health?pretty"
//状态green结束

标签:10.1,http,9200,192.168,cluster,常用命令,curl,es
来源: https://www.cnblogs.com/whiteY/p/16671726.html