在 elasticsearch 中将索引从一台机器复制到另一台机器

To copy an index from one machine to another in elasticsearch

我的一台机器上有一些索引。我需要将它们复制到另一台机器,我该如何在 elasticsearch 中做到这一点。 我确实得到了一些很好的文档 here,但由于我是 elasticsearch 生态系统的新手,而且我使用的数据索引较少,所以我想我会使用一些插件或方法,这样会更省时。

我会使用 Logstash with an elasticsearch input plugin and an elasticsearch output 插件。

installing Logstash 之后,您可以创建一个如下所示的配置文件 copy.conf

input {
  elasticsearch {
   hosts => "localhost:9200"                     <--- source ES host
   index => "source_index"
  }
}
filter {
 mutate {
  remove_field => [ "@version", "@timestamp" ]   <--- remove added junk
 }
}
output {
 elasticsearch {
   host => "localhost"                           <--- target ES host
   port => 9200
   protocol => "http"
   manage_template => false
   index => "target_index"
   document_id => "%{id}"                        <--- name of your ID field
   workers => 1
 }
}

然后在设置正确的值后(source/target 主机 + source/target 索引),你可以 运行 这个 bin/logstash -f copy.conf

您也可以使用快照和恢复功能,您可以在其中拍摄一个索引的快照(备份),然后可以恢复到其他地方。

随便看看 https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

我可以在这里看到 3 个选项

  1. Snapshot/Restore - 您可以跨地理位置移动数据。
  2. Logstash reindex - 正如 Val
  3. 所指出的
  4. Stream2ES - 这是一个更简单的解决方案