简体   繁体   English

如何有效地将数据从Elasticsearch索引(具有一个分片)移动到另一索引(具有5个分片)?

[英]How to efficiently move data from elasticsearch index (with one shard) to another index (with 5 shards)?

I have an elasticsearch index which contains around 5 GB of data on a single node in a single shard. 我有一个Elasticsearch索引,它在单个分片的单个节点上包含大约5 GB的数据。 Now I have created another index with same settings as older one, but with number_of_shards as 5 instead of 1. 现在,我创建了另一个索引,该索引的设置与旧索引相同,但是number_of_shards为5而不是1。

I am looking for the most efficient approach to copy the data from older index to newer index without any downtime. 我正在寻找最有效的方法来将数据从旧索引复制到新索引,而不会造成任何停机。

I would suggest using Logstash for this. 我建议为此使用Logstash You could use the following configuration. 您可以使用以下配置。 Make sure to replace the source and target hosts, as well as the index and type names to match your local environment. 确保替换源主机和目标主机,以及索引和类型名称以匹配您的本地环境。

File: reindex.conf 文件:reindex.conf

input {
  elasticsearch {
   hosts => "localhost:9200"       <---- your source host
   index => "my_source_index"
  }
}
filter {
 mutate {
  remove_field => [ "@version", "@timestamp" ]
 }
}
output {
 elasticsearch {
   host => "localhost"       <--- your target host
   port => 9200
   protocol => "http"
   manage_template => false
   index => "my_target_index"
   document_type => "my_type"
   workers => 5
 }
}

And then you can simply launch it with 然后您可以使用

bin/logstash -f reindex.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM