首页 > 解决方案 > Logstash 错误:拒绝对 [db] 的映射更新,因为最终映射将有超过 1 种类型:[meeting_invities, meetingroom"}}}}

问题描述

Rejecting mapping update to [db] as the final mapping would have more than 1 type: [meeting_invities, meetingroom
"}}}}

下面是我的 logstatsh-mysql.conf 我必须在 jdbc 输入中使用多个表。请指教

input {
    jdbc {
        jdbc_connection_string => "jdbc:mysql://localhost:3306/db"
        jdbc_user => "root"
        jdbc_password => "pwd"

        jdbc_driver_class => "com.mysql.jdbc.Driver"
        statement => "SELECT * FROM meeting"
        tags => "dat_meeting"
    }
    jdbc {
        jdbc_connection_string => "jdbc:mysql://localhost:3306/db"
        jdbc_user => "root"
        jdbc_password => "pwd"

        jdbc_driver_class => "com.mysql.jdbc.Driver"
        statement => "SELECT * FROM meeting_invities;"
        tags => "dat_meeting_invities"


    }
}
output {
    stdout { codec => json_lines }
    if "dat_meeting" in [tags]{elasticsearch {
        hosts => "localhost:9200"
        index => "meetingroomdb"

         document_type => "meeting"   
    }
    }

    if "dat_meeting_invities" in [tags]{elasticsearch {
        hosts => "localhost:9200"
        index => "meetingroomdb"

         document_type => "meeting_invities"   
    }
    }
}

标签: elasticsearchlogstash

解决方案


您的 elasticsearch 输出使用document_type具有两个不同值的选项,此选项设置_type索引的字段,从版本 6.X 开始,您的索引中只能有一种类型。

此选项在版本 7.X 中已弃用,并且将在未来版本中删除,因为 elasticsearch 正在变得无类型

由于elasticsearch不允许您索引多个索引类型,您需要查看您索引的第一个文档的类型,这是elasticsearch将用于任何未来文档的类型,在这两个document_type选项中都使用它。


推荐阅读