zoukankan      html  css  js  c++  java
  • 使用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

  • 相关阅读:
    linux 开机启动设置
    Ubuntu安装Oracle时出现乱码,及其他安装错误
    ubuntu 设置DNS
    opencv cuda TK1 TX1 兼容设置
    int to string
    post文件的html
    vc 获得调用者的模块名称
    dlib landmark+人面识别
    android破解
    jquery $(document).ready() 与window.onload的区别
  • 原文地址:https://www.cnblogs.com/hxlasky/p/13448220.html
Copyright © 2011-2022 走看看