版本: 6.8-8.9
简而言之,当尝试在一个仍然被视为主分片的副本分片上执行操作时,会出现此错误。这可能是由于网络分区或节点故障导致的。要解决此问题,您可以尝试以下方法:1) 重启 Elasticsearch 节点,这有助于重置分片状态。2) 使用 reroute API 手动更改分片的分配。3) 检查集群健康状况,确保所有节点正确连接。4) 如果问题持续存在,考虑重新索引数据。
日志上下文
日志"Not primary; can’t move to replica"的类名是 ShardRouting.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的人参考:
* @throws IllegalShardRoutingStateException if shard is already a replica
*/
public ShardRouting moveUnassignedFromPrimary() {
assert state == ShardRoutingState.UNASSIGNED : "expected an unassigned shard " + this;
if (primary == false) {
throw new IllegalShardRoutingStateException(this, "Not primary; can't move to replica");
}
return new ShardRouting(
shardId,
currentNodeId,
relocatingNodeId,





