Allen
Allen

Reputation: 354

How to delete unassigned shards in elasticsearch?

I have only one node on one computer and the index have 5 shards without replicas. Here are some parameters describe my elasticsearch node(healthy indexes are ignored in the following list):

GET /_cat/indices?v
health status index   pri rep docs.count docs.deleted store.size pri.store.size 
red    open   datas     5   0  344999414            0     43.9gb         43.9gb 

GET _cat/shards                                    
datas   4 p STARTED    114991132 14.6gb 127.0.0.1 Eric the Red 
datas   3 p STARTED    114995287 14.6gb 127.0.0.1 Eric the Red 
datas   2 p STARTED    115012995 14.6gb 127.0.0.1 Eric the Red 
datas   1 p UNASSIGNED                                         
datas   0 p UNASSIGNED                  

shards disk.indices disk.used disk.avail disk.total disk.percent host      ip        node         
14       65.9gb     710gb    202.8gb    912.8gb           77 127.0.0.1 127.0.0.1 Eric the Red 
 3                                                                               UNASSIGNED   

Upvotes: 8

Views: 28487

Answers (2)

Zedzdead
Zedzdead

Reputation: 354

Although deleting created shards doesn't seem to be supported, as mentioned on the comments above, reducing the number of replicas to zero for the indexes with UNASSIGNED shards might do the job, at least for single node clusters.

PUT /{my_index}/_settings
{
   "index" : {
       "number_of_replicas" : 0
   }
}

reference

Upvotes: 9

Tanu
Tanu

Reputation: 1563

You can try deleting unassigned shard following way (Not sure though if it works for data index, works for marvel indices)

1) Install elasticsearch plugin - head. Refer Elastic Search Head Plugin Installation

2) Open your elasticsearch plugin - head URL in brwoser. From here you can easily check out which are unassigned shards and other related info. This will display infor regarding that shard.

{
"state": "UNASSIGNED",
 "primary": true,
 "node": null,
 "relocating_node": null,
 "shard": 0,
"index": ".marvel-es-2016.05.18",
 "version": 0,
"unassigned_info": {
"reason": "DANGLING_INDEX_IMPORTED",
"at": "2016-05-25T05:59:50.678Z"
  }
 }

from here you can copy index name i.e. .marvel-es-2016.05.18.

3) Now you can run this query in sense

 DELETE .marvel-es-2016.05.18

Hope this helps !

Upvotes: 0

Related Questions