【问题标题】:Copy index data from one ES index to ES another using logstash使用 logstash 将索引数据从一个 ES 索引复制到另一个 ES
【发布时间】:2016-12-19 20:38:51
【问题描述】:

你能帮忙写一个脚本吗,我在运行这个脚本时遇到以下错误

input {
  # We read from the "old" cluster
  elasticsearch {
    hosts => [ "localhost" ]
    port => "9200"
    index => "products"
    size => 500
    scroll => "5m"
    docinfo => true
  }
}

output {
  # We write to the "new" cluster
  elasticsearch {
    host => "localhost"
    port => "9200"
    protocol => "http"
    index => "%{[@metadata][_index1]}"
    index_type => "%{[@metadata][_type1]}"
    document_id => "%{[@metadata][_id]}"
  }
  # We print dots to see it in action
  stdout {
    codec => "dots"
  }
}

这是我的 logstash.conf 文件,当我运行这个 m 时出现以下错误

弹性搜索的未知设置“端口”

{:level=>:error}
fetched an invalid config {:config=>"input {\n  # We read from the \"old\" cluster\n  elasticsearch {\n    hosts => [ \"localhost\" ]\n    port => \"9200\"\n    index => \"products\"\n    size => 500\n    scroll => \"5m\"\n    docinfo => true\n  }\n}\n\noutput {\n  # We write to the \"new\" cluster\n  elasticsearch {\n    host => \"localhost\"\n    port => \"9200\"\n    protocol => \"http\"\n    index => \"%{[@metadata][_index1]}\"\n    index_type => \"%{[@metadata][_type1]}\"\n    document_id => \"%{[@metadata][_id]}\"\n  }\n  # We print dots to see it in action\n  stdout {\n    codec => \"dots\"\n  }\

【问题讨论】:

  • 如果你使用 Logstash 2+,port 和 index_type 选项不再有效
  • 是的,我正在使用 2.X 版本的日志存储,现在应该做什么。
  • 能否告诉我 2.X 版本的正确格式?

标签: elasticsearch logstash


【解决方案1】:

我已经修改了配置,带有2+版本的选项。

input {
  # We read from the "old" cluster
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "products"
    size => 500
    scroll => "5m"
    docinfo => true
  }
}

output {
  # We write to the "new" cluster
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "%{[@metadata][_index1]}"
    document_type => "%{[@metadata][_type1]}"
    document_id => "%{[@metadata][_id]}"
  }
  # We print dots to see it in action
  stdout {
    codec => "dots"
  }
}

【讨论】:

  • 非常感谢 baudsp,但很抱歉再次打扰您,因为我收到了不需要的字段,例如
  • @PrasadKhandagale 很高兴我能帮上忙。要从 mysql 转到 ES,可以使用 jdbc input plugin。您可以在 SO 上找到一些关于此的问题(例如 stackoverflow.com/questions/37650623/…stackoverflow.com/questions/31611171/…stackoverflow.com/questions/39073928/…)。如果它不起作用,请提出一个新问题,我对这个输入插件没有任何经验。
  • 再次感谢 bausap,它起作用了,但映射未在“属性”中正确复制:{“text_field”:{“type”:“string”,“index_analyzer”:“edge_ngram_analyzer”,“search_analyzer ": "standard" } } 这是原始映射,但复制的不包含此索引和搜索分析器 est_ktype": { "properties": { "text_field": { "type": "string" } }
  • 您必须删除索引,使用映射创建索引并重新索引。映射不是数据的一部分,因此它们不会转移到新索引中
猜你喜欢
  • 1970-01-01
  • 2016-03-13
  • 2017-09-30
  • 2015-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多