elasticsearch - elasticsearch拆分索引错误,路由分片必须是目标分片的倍数?
问题描述
我想将索引nozomi-trace-log
(5 个分片,number_of_routing_shards
未设置)拆分nozomi-log-thomas
为 10 个分片的目标。
据此,首先我发布了一条命令,number_of_routing_shards
将源索引设置为 20:
PUT /nozomi-trace-log/_settings
{
"settings": {
"index.number_of_routing_shards" : 20
}
}
检查结果:
{
"nozomi-trace-log": {
"settings": {
"index": {
"number_of_shards": "5",
"provided_name": "nozomi-trace-log",
"creation_date": "1594180347628",
"unassigned": {
"node_left": {
"delayed_timeout": "5m"
}
},
"number_of_routing_shards": "20",
"number_of_replicas": "1",
"uuid": "Yal04AcQRUyZQIjrUGwTGw",
"version": {
"created": "6020499"
}
}
}
}
}
然后我发出_split
命令,但它给出了一个错误:
POST nozomi-trace-log/_split/nozomi-log-thomas
{
"settings": {
"index.number_of_shards": 10
}
}
错误:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[***][**.**.**.**:9300][indices:admin/resize]"
}
],
"type": "illegal_state_exception",
"reason": "the number of routing shards [5] must be a multiple of the target shards [10]"
},
"status": 500
}
错误似乎表明number_of_routing_shards
源索引是5,但是第一个命令已经设置number_of_routing_shards
为20。那么哪里出错了?
解决方案
在您链接的文档中,索引是使用特定数量的路由分片创建的,而在您的示例中,您正在修改现有索引的设置。
在链接文档的开头清楚地说明了您正在使用的版本(6.2):
_split API 要求使用特定 number_of_routing_shards 创建源索引,以便将来进行拆分。此要求已在 Elasticsearch 7.0 中删除。
这意味着在 Elasticsearch 6.x 版本中,您必须在创建索引之前创建具有“正确”数量的路由分片的索引。在这种情况下,请考虑使用具有所需设置的索引模板。
(此外:在问题中,您忘记了将源索引设为只读的步骤)
可能的解决方案(REINDEX)
因此,话虽如此,您可以尝试重新索引 API 。
您可以选择将源索引设为只读以避免冲突:
PUT /nozomi-trace-log/_settings
{
"settings": {
"index.blocks.write": true
}
}
首先使用正确的设置创建目标索引:
PUT nozomi-log-thomas
{
"settings": {
"index.number_of_shards": 10
}
}
然后将源索引重新索引到目标索引中
POST _reindex
{
"source": {
"index": "nozomi-trace-log"
},
"dest": {
"index": "nozomi-log-thomas"
}
}
推荐阅读
- fusionauth - 这种 SSO 场景是否可以使用 FusionAuth?
- php - SELECT all tables from DB and query same column name in each one of them
- python - 如何跟踪各种类型的条纹
- javascript - 将用户输入与登录按钮链接
- hyperledger-fabric - IBM Blockchain Platform VS Code GOPATH 错误
- python - 如何从父类调用属性?
- android-studio - 如何将现有的android项目转换为gradle依赖
- sql - 其他列相等的 SQL 组列
- ios - 使用swift杀死应用程序时如何存储ios推送通知
- xamarin.forms - 将焦点设置在 Xamarin.Forms MVVM (Prism) 中的 Entry 字段上