📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 6.8-8.9

简而言之,当尝试在Elasticsearch中的非主分片上执行快照时,会出现此错误。快照是集群索引的备份,只应在主分片上执行以确保数据一致性。要解决此问题,请确保快照操作在主分片上执行。如果错误仍然存在,请检查集群健康状况并确保所有主分片已正确分配。如有必要,您可能需要手动重新分配主分片或执行集群重新路由操作。

日志上下文 #

日志"snapshot should be performed only on primary"的类名是 SnapshotShardsService.java。 我们从Elasticsearch源代码中提取了以下内容,供寻求深入了解的人士参考:

) {
 ActionListener.run(resultListener; listener -> {
 snapshotStatus.ensureNotAborted();
 final IndexShard indexShard = indicesService.indexServiceSafe(shardId.getIndex()).getShard(shardId.id());
 if (indexShard.routingEntry().primary() == false) {
 throw new IndexShardSnapshotFailedException(shardId; "snapshot should be performed only on primary");
 }
 if (indexShard.routingEntry().relocating()) {
 // do not snapshot when in the process of relocation of primaries so we won't get conflicts
 throw new IndexShardSnapshotFailedException(shardId; "cannot snapshot while relocating");
 }