2016-12-19 47 views
0

請你幫忙寫一個腳本來ES另外,運行此腳本複製索引數據使用logstash

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" 
    } 
} 

,而X收到以下錯誤這是我logstash.conf文件當我運行這個m到處以下錯誤

未知設置「端口」的elasticsearch

{: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 }\ 
+0

如果您使用Logstash 2+,港口和INDEX_TYPE選項不再有效 – baudsp

+0

是我使用的日誌藏匿就是現在應該做的2.X版本。 –

+0

您能否讓我知道2.X版本的正確格式? –

回答

0

我已經修改了配置,隨着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" 
    } 
} 
+0

非常感謝baudsp,但很抱歉讓您再次讓我不知所措,像 –

+0

@PrasadKhandagale很高興我能幫上忙。從mysql到ES,你可以使用[jdbc輸入插件](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html)。你可以找到關於這個問題的幾個問題(如http://stackoverflow.com/questions/37650623/elasticsearch-logstash-duplicating-output-when-use-schedule,http://stackoverflow.com/questions/31611171/ logstash-jdbc-input-plugin-for-mysql,http://stackoverflow.com/questions/39073928/logstash-jdbc-mysql-config-error)。如果它不起作用,請提出一個新問題,我對此輸入插件沒有任何經驗。 – baudsp

+0

再次感謝bausap,它的工作BU的映射不是在 「屬性」 正確複製:{ 「text_field」:{ 「類型」: 「串」, 「index_analyzer」: 「edge_ngram_analyzer」, 「search_analyzer」:「標準「 } }這是原單映射但是複製的一個不包含該索引和搜索分析器est_ktype」:{ ‘屬性’:{ ‘text_field’:{ ‘類型’:‘串’ } } –