gpt4 book ai didi

elasticsearch - 编辑 ElasticSearch 7.3 的状态文件

转载 作者:行者123 更新时间:2023-12-02 23:13:16 25 4
gpt4 key购买 nike

我的集群中有一个 ElasticNode 7.3.2 已崩溃,此后无法重新启动,但仍包含重要数据(最后一个副本在此节点上)。

Caused by: java.io.IOException: failed to find metadata for existing index indexname-2019.06.23 [location: ORVU14kLSf6kIv8ULliijA, generation: 178]



我不关心这个特殊索引,我可以从状态文件中删除这个吗?我已经尝试通过 HexEditor 将其删除,但随后他提示不是有效的哈希校验和;)

我已经尝试通过 SMILE 对其进行解码,但似乎 *.st 文件仅部分不遵循确切的规范。

有人有想法吗?还是编辑它的好工具?

谢谢

最佳答案

我有一个类似的案例,我用无效的相似性设置破坏了我的索引设置。不幸的是,设置被 ES 写入文件而没有进行有效性检查,之后我无法再次打开索引。所以我从 data/nodes/0/indices/<index UID>/_state/state-xx.st 得到了索引元数据并弄清楚如何加载、更改并重新存储它。我使用的是 ES 5.4,所以我在这里给出的代码在 ES 7.x 中会略有不同。它是这样的:

import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Paths;

public class RepairIndexSettings {
public static void main(String args[]) throws IOException {

// Load the existing, possibly corrupt index file
IndexMetaData d = IndexMetaData.FORMAT.read(NamedXContentRegistry.EMPTY, Paths.get( "indexstaterepair","_state", "state-11.st"));

// Create new IndexMetaData by copying all the valid meta data from the original and removing or fixing
// the corrupt settings.
Settings.Builder sb = Settings.builder();
for (String key : d.getSettings().keySet()) {
if (!key.contains("similarity"))
sb.put(key, d.getSettings().get(key));
}
IndexMetaData newd = IndexMetaData.builder(d).settings(sb).build();

// Write the new index state to file
IndexMetaData.FORMAT.write(newd, Paths.get("indexstaterepair"));
}
}

我用新的替换了原始状态文件,之后可以正常打开和使用索引。

您将不得不使用另一个 MetaData子类,但我认为它应该非常相似。

关于elasticsearch - 编辑 ElasticSearch 7.3 的状态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58121186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com