Allow Elasticsearch to allocate the index
Allow Elasticsearch to allocate the index
The allocation of data can be controlled using the enable allocation configuration. In certain circumstances users might want to temporarily disable or restrict the allocation of data.
Forgetting to re-allow all data allocation can lead to unassigned shards.
In order to (re)allow all data to be allocated follow these steps:
Elasticsearch Service Self-managed
In order to get the shards assigned we’ll need to change the value of the configuration that restricts the assignemnt of the shards to all
.
Use Kibana
- Log in to the Elastic Cloud console.
On the Elasticsearch Service panel, click the name of your deployment.
If the name of your deployment is disabled your Kibana instances might be unhealthy, in which case please contact Elastic Support. If your deployment doesn’t include Kibana, all you need to do is enable it first.
Open your deployment’s side navigation menu (placed under the Elastic logo in the upper left corner) and go to Dev Tools > Console.
Inspect the
index.routing.allocation.enable
index setting for the index with unassigned shards:resp = client.indices.get_settings(
index="my-index-000001",
name="index.routing.allocation.enable",
flat_settings=True,
)
print(resp)
response = client.indices.get_settings(
index: 'my-index-000001',
name: 'index.routing.allocation.enable',
flat_settings: true
)
puts response
const response = await client.indices.getSettings({
index: "my-index-000001",
name: "index.routing.allocation.enable",
flat_settings: "true",
});
console.log(response);
GET /my-index-000001/_settings/index.routing.allocation.enable?flat_settings
The response will look like this:
{
"my-index-000001": {
"settings": {
"index.routing.allocation.enable": "none"
}
}
}
Represents the current configured value that controls if the index is allowed to be partially or totally allocated.
Change the configuration value to allow the index to be fully allocated:
resp = client.indices.put_settings(
index="my-index-000001",
settings={
"index": {
"routing.allocation.enable": "all"
}
},
)
print(resp)
response = client.indices.put_settings(
index: 'my-index-000001',
body: {
index: {
'routing.allocation.enable' => 'all'
}
}
)
puts response
const response = await client.indices.putSettings({
index: "my-index-000001",
settings: {
index: {
"routing.allocation.enable": "all",
},
},
});
console.log(response);
PUT /my-index-000001/_settings
{
"index" : {
"routing.allocation.enable" : "all"
}
}
The new value for the
allocation.enable
configuration for themy-index-000001
index is changed to allow all the shards to be allocated.
In order to get the shards assigned we’ll need to change the value of the configuration that restricts the assignemnt of the shards to all
.
Inspect the
index.routing.allocation.enable
index setting for the index with unassigned shards:resp = client.indices.get_settings(
index="my-index-000001",
name="index.routing.allocation.enable",
flat_settings=True,
)
print(resp)
response = client.indices.get_settings(
index: 'my-index-000001',
name: 'index.routing.allocation.enable',
flat_settings: true
)
puts response
const response = await client.indices.getSettings({
index: "my-index-000001",
name: "index.routing.allocation.enable",
flat_settings: "true",
});
console.log(response);
GET /my-index-000001/_settings/index.routing.allocation.enable?flat_settings
The response will look like this:
{
"my-index-000001": {
"settings": {
"index.routing.allocation.enable": "none"
}
}
}
Represents the current configured value that controls if the index is allowed to be partially or totally allocated.
Change the configuration value to allow the index to be fully allocated:
resp = client.indices.put_settings(
index="my-index-000001",
settings={
"index": {
"routing.allocation.enable": "all"
}
},
)
print(resp)
response = client.indices.put_settings(
index: 'my-index-000001',
body: {
index: {
'routing.allocation.enable' => 'all'
}
}
)
puts response
const response = await client.indices.putSettings({
index: "my-index-000001",
settings: {
index: {
"routing.allocation.enable": "all",
},
},
});
console.log(response);
PUT /my-index-000001/_settings
{
"index" : {
"routing.allocation.enable" : "all"
}
}
The new value for the
allocation.enable
configuration for themy-index-000001
index is changed to allow all the shards to be allocated.