blueness_sunshine 2017-11-13 09:54 采纳率: 40%
浏览 2567
已结题

logstash同步数据mysql一对多数据结构的情况?

学生表student和课程表class一对多关系,
学生表student和兴趣interest表一对多关系,
想要将三个表同步到一个索引里面,通过ES一次性查询到学生信息、学生的课程数组、学生的兴趣数组;

[
{
"id": 1,
"name": "小王",
"class": [
{
"id": 1,
"name": "数学"
},
{
"id": 2,
"name": " 语文"
}
],
"interest": [
{
"id": 1,
"name": "学习"
},
{
"id": 1,
"name": "足球"
}
]
}]
我是想搜索出来这样的数据 同时包含学生的 课程和兴趣,而这条数据是真实同步到logstash中的 不是通过ES的联合查询出来的

  • 写回答

4条回答

  • 砍柴-少年 2017-11-13 10:06
    关注

    input {
    stdin {
    }
    jdbc {
    # mysql jdbc connection string to our backup databse
    jdbc_connection_string => "jdbc:mysql://192.168.42.147:3306/test"
    # the user we wish to excute our statement as
    jdbc_user => "root"
    jdbc_password => "root"
    # the path to our downloaded jdbc driver
    jdbc_driver_library => "/home/hadoop/opt/logstash-2.3.2/mysql-connector-java-5.1.29.jar"
    # the name of the driver class for mysql
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_paging_enabled => "true"
    jdbc_page_size => "50000"
    statement_filepath => "jdbc.sql"
    schedule => "* * * * "
    type => "gjhz"
    }
    jdbc {
    # mysql jdbc connection string to our backup databse
    jdbc_connection_string => "jdbc:mysql://192.168.42.147:3306/test"
    # the user we wish to excute our statement as
    jdbc_user => "root"
    jdbc_password => "root"
    # the path to our downloaded jdbc driver
    jdbc_driver_library => "/home/hadoop/opt/logstash-2.3.2/mysql-connector-java-5.1.29.jar"
    # the name of the driver class for mysql
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_paging_enabled => "true"
    jdbc_page_size => "50000"
    statement_filepath => "jdbc2.sql"
    schedule => "
    * * * *"
    type => "rjfw"
    }
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用