• 使用logstash迁移elasticsearch


    环境:

    原elasticsearch版本:6.5.0

    目的elasticsearch 版本:7.4.0

    1.下载logstash

    我这里下载的是6.8.5版本

    https://artifacts.elastic.co/downloads/logstash/logstash-6.8.5.tar.gz

    2.上次服务器进行解压

    在root账号下处理

    tar -xvf logstash-6.8.5.tar.gz

    3.迁移单个index

    添加配置文件,文件内容如下:

    [root@localhost config]# more sync_single_index.conf
    input {
        elasticsearch {
            hosts => ["http://192.168.1.136:19200"]
            index => "index_test"
            size => 1000
            scroll => "1m"
            docinfo => true
        }
    }
    # 该部分被注释,表示filter是可选的
    filter {
      mutate {
        remove_field => ["@timestamp", "@version"]  #过滤掉logstash 自己加上的字段
      }
    }

    output {
        elasticsearch {
            hosts => ["http://192.168.1.118:9200"]
            user => "elastic"
            password => "elastic"
            index => "index_test"
        }
    }

    执行如下脚本进行迁移

    /opt/logstash-6.8.5/bin/logstash -f /opt/logstash-6.8.5/config/sync_single_index.conf

    4.迁移所有的index

    配置文件内容如下:

    [root@localhost config]# more sync_all_index.conf
    input {
        elasticsearch {
            hosts => ["http://192.168.1.136:19200"]
            index => "*"
            size => 1000
            scroll => "1m"
            codec => "json"
            docinfo => true
        }
    }
    # 该部分被注释,表示filter是可选的
    filter {
      mutate {
        remove_field => ["@timestamp", "@version"]  #过滤掉logstash 自己加上的字段
      }
    }

    output {
        elasticsearch {
            hosts => ["http://192.168.1.118:9200"]
            user => "elastic"
            password => "elastic"
            index => "%{[@metadata][_index]}"
        }
    }

    执行如下脚本迁移

    /opt/logstash-6.8.5/bin/logstash -f /opt/logstash-6.8.5/config/sync_all_index.conf

  • 相关阅读:
    ecos 编译时无法找到 tclConfig.sh 和 tkConfig.sh
    gcc 的宏替换 __stringify
    CentOS 静态IP配置
    光照
    CUnit 安装
    git push not configured with USE_CURL_MULTI
    在VC中用FreeImage显示图片的简单方法
    vanilla kernel
    Eclipse CDT 对 Doxygen 型注释的支持
    己所不欲,人欲取之
  • 原文地址:https://www.cnblogs.com/hxlasky/p/13448220.html
Copyright © 2020-2023  润新知