允许 Elasticsearch 分配索引
编辑允许 Elasticsearch 分配索引
编辑可以使用启用分配配置来控制数据的分配。在某些情况下,用户可能希望暂时禁用或限制数据的分配。
忘记重新允许所有数据分配会导致分片未分配。
为了(重新)允许分配所有数据,请按照以下步骤操作
为了分配分片,我们需要将限制分片分配的配置的值更改为all
。
使用 Kibana
- 登录到Elastic Cloud 控制台。
-
在Elasticsearch 服务面板上,单击您的部署名称。
如果您的部署名称被禁用,您的 Kibana 实例可能不健康,在这种情况下,请联系Elastic 支持。如果您的部署不包含 Kibana,您只需要先启用它。
-
打开您的部署的侧边导航菜单(位于左上角的 Elastic 徽标下方),然后转到开发工具 > 控制台。
-
检查具有未分配分片的索引的
index.routing.allocation.enable
索引设置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
响应将如下所示
-
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);
为了分配分片,我们需要将限制分片分配的配置的值更改为all
。
-
检查具有未分配分片的索引的
index.routing.allocation.enable
索引设置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
响应将如下所示
-
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);