# How to change the default amount of shards and replicas of indices?

**URL:** https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989
**Category:** Elasticsearch
**Created:** [August 5, 2017, 6:31pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989 "2017-08-05T18:31:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)
#### Post date: [August 5, 2017, 6:31pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/1 "2017-08-05T18:31:04Z")

</div>

ELK version: 5.5.1

I referred to this page [https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-update-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-update-settings.html) and changed a index's number of replica, and it worked, but how to add it to the config file to make it valid for all new indices?

Referred to this page [https://www.elastic.co/guide/en/elasticsearch/reference/5.5/index-modules.html#dynamic-index-settings](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/index-modules.html#dynamic-index-settings) , I add

```auto
index.number_of_shards: 7
index.number_of_replicas: 2

```

to `elasticsearch.yml`, but it didn't work...ES can't startup...

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 5, 2017, 7:39pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/2 "2017-08-05T19:39:05Z")

</div>

Use index templates instead.

---

<div class="post-metadata">

### Author: ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)
#### Post date: [August 5, 2017, 7:58pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/3 "2017-08-05T19:58:53Z")

</div>

Hello, is there a guide about how to set this using template...?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 5, 2017, 8:27pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/4 "2017-08-05T20:27:43Z")

</div>

A simple search for "index templates" on [elastic.co](http://elastic.co) website:

 ![49](https://us1.discourse-cdn.com/elastic/original/3X/e/3/e3133937a9344aac61a3ab5effa186e02438b5af.png)

Will lead you to: [https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-templates.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-templates.html)

---

<div class="post-metadata">

### Author: ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)
#### Post date: [August 7, 2017, 8:54am UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/5 "2017-08-07T08:54:16Z")

</div>

Thanks, and how to use template to modify this value? 😳

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 7, 2017, 9:07am UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/6 "2017-08-07T09:07:06Z")

</div>

Should be something like:

```auto
PUT _template/all
{
  "template": "*",
  "settings": {
    "number_of_shards": 7,
    "number_of_replicas": 2
  }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 4, 2017, 9:07am UTC](https://discuss.elastic.co/t/how-to-change-the-default-amount-of-shards-and-replicas-of-indices/95989/7 "2017-09-04T09:07:08Z")

</div>

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