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

  • 相关阅读:
    【学习笔记】第二章 python安全编程基础---python爬虫基础(urllib)
    java Spring boot entity编写
    UI自动化基础
    初级:第五课 Tony and his family? 托尼和他的家人?
    初级:第四课 What do you do? 你是做什么的?
    初级:第三课 My Family 我的家人
    初级:第二课 Nice to Meet You 幸会
    初级:第一课 Self Introduction 自我介绍
    jmeter自定义函数
    Go笔记-结构、类型、常量
  • 原文地址:https://www.cnblogs.com/hxlasky/p/13448220.html
Copyright © 2011-2022 走看看