工作纪实36-ES跨集群迁移

1.es数据备份、恢复

https://blog.csdn.net/andy_only/article/details/111319175

2.reindex命令

https://codeleading.com/article/40964498185/

添加配置、重启ES

cd bin
sh elasticsearch -d

3.开源工具

https://github.com/elasticsearch-dump/elasticsearch-dump

4.logstash

[work()@tjtxvm176-239-170 config]$ cd ..
[work()@tjtxvm176-239-170 logstash-5.6.16]$ sh ^C
[work()@tjtxvm176-239-170 logstash-5.6.16]$ ./bin/logstash -f config/logstash-es-migrate.conf 

注意logstash 跟ES的匹配版本

logstash-5.6.16 376,800,历时 3分20秒,1884每秒,3个小时能迁完

bin/logstash -f config/logstash-sample.conf

input{
    elasticsearch{
        # 源端地址
        hosts =>  ["http://source:9200"]
        # 安全集群配置登录用户名密码
        # user => "xxxx"
        # password => "xxxx"
        # 需要迁移的索引列表,以逗号分隔
        index => "omd_v6"
        # 以下三项保持默认即可,包含线程数和迁移数据大小和logstash jvm配置相关
        docinfo=>true
        # slices => 10
        # size => 200
    }
}

filter {
  # 去掉一些logstash自己加的字段
  mutate {
    remove_field => ["@timestamp", "@version"]
  }
}

output{
    elasticsearch{
        # 目的端es地址
        hosts => ["http://target:9200"]
        # 目的端索引名称,以下配置为和源端保持一致
        # index => "%{[@metadata][_index]}"
        index => "omd_v4"
        # 目的端索引type,以下配置为和源端保持一致
        document_type => "%{[@metadata][_type]}"
        # 目标端数据的_id,如果不需要保留原_id,可以删除以下这行,删除后性能会更好
        document_id => "%{[@metadata][_id]}"
        # ilm_enabled => false
        # manage_template => false
    }
    
    # 调试信息,正式迁移去掉
    # stdout { codec => rubydebug { metadata => true }}
}

https://www.elastic.co/guide/en/logstash/6.7/plugins-inputs-elasticsearch.html?spm=a2c4e.10696291.0.0.34dd19a4GGsCSh
https://bbs.huaweicloud.com/blogs/265963
https://www.51cto.com/article/704537.html

5.写程序

自由发挥

logstash效率最高,elastcidump受限于node环境

你可能感兴趣的:(elasticsearch,jenkins,大数据)