Shrink API and Relocation of Shards

Dear Community,

I am in the process of performing a shrink on indices in order to reduce the number of shards from 5 to 1 , i choose to test on my cluster on 1 index named "logstash-ssh-*'

So i followed the documentation form elasticsearch : https://www.elastic.co/guide/en/elasticsearch/reference/6.2/indices-shrink-index.html

By putting index in read-only and relocating the shards to one node in order to have the primary and replica on the same elasticsearch node.

PUT /logstash-ssh-*/_settings
{
  "settings": {
    "index.routing.allocation.require._host": "elastic-01",
    "index.blocks.write": true 
  }
}

If I check if the operation has been taken by elasticsearch it seems yes :

"logstash-ssh-2018.05.15": {
    "settings": {
        "index": {
            "blocks": {
                "write": "true"
            },
            "creation_date": "1526342499442",
            "number_of_replicas": "1",
            "number_of_shards": "5",
            "provided_name": "logstash-ssh-2018.05.15",
            "refresh_interval": "5s",
            "routing": {
                "allocation": {
                    "require": {
                        "_host": "",
                        "_ip": "",
                        "_name": "elastic-01"
                    }
                }
            },
            "uuid": "Lq38GrBySk6qO2RNRa8Clw",
            "version": {
                "created": "6020399"
            }
        }
    }
},
.....

But when I check if somes shards are relocating , it seems not

 curl -s 'http://elastic-01.domain.local:9200/_cat/shards?v' | fgrep RELO
<Empty output>

And if i check the shards by filtering from the index pattern logstash-ssh-*, it seems that nothing happen , the shards are still shared with my both elasticsearch nodes.

Did i miss something , is there are some parameter that stuck relocating of shards at the cluster level ?

I'm running the 6.2.3 Elasticsearch version on my cluster.

Thanks in advance for your help.

Best Regards, Edouard Fazenda.

Hello :slight_smile:

Is up this topic in case someone can help me.

Thanks :slight_smile:

Elasticsearch will never put a primary and replica of a shard on the same node. If you have 2 nodes and number_of_replicas set to 1 each node has the full set of shards available. Nothing will ever be relocated in this scenario.

Did you run the _shrink command? Any error is generally pretty descriptive of what goes wrong.

If that doesn't work, try setting the number of replicas to 0 before running _shrink.

1 Like

Thanks for the help , yes I run the _shrink command via curator and i made a bash script to add an alias with the old index name.

It's working well.

Have a nice day.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.