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常用操作命令
    golang的goroutine调度机制,GC机制
    数据库原理
    linux各文件夹的作用
    c++面试题
    EF 新增数据时提示it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element
    EF 批量插入,sqlhelper 批量插入
    C# 自己用到的几个参数转换方法
    asp.net MVC EF Where 过滤条件怎么写
    EF Code First 数据迁移命令
  • 原文地址:https://www.cnblogs.com/hxlasky/p/13448220.html
Copyright © 2011-2022 走看看