绊脚石乃是进身之阶。

请问下各位大神logstash同步mysql时,sql_last_value的时间不对为什么啊?

Logstash | 作者 tofu | 发布于2018年05月08日 | 阅读数:10054

The stdin plugin is now waiting for input:
[2018-05-08T11:01:02,589][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2018-05-08T11:02:04,834][INFO ][logstash.inputs.jdbc     ] (0.257000s) SELECT version() AS `v` LIMIT 1
[2018-05-08T11:02:04,948][INFO ][logstash.inputs.jdbc     ] (0.024000s) select * from std where creattime > '1970-01-01 00:00:00'
2018-05-08T03:02:05.079Z %{host} %{message}
2018-05-08T03:02:05.080Z %{host} %{message}
2018-05-08T03:02:05.088Z %{host} %{message}
2018-05-08T03:02:05.091Z %{host} %{message}
2018-05-08T03:02:05.093Z %{host} %{message}
2018-05-08T03:02:05.021Z %{host} %{message}
2018-05-08T03:02:05.049Z %{host} %{message}
2018-05-08T03:02:05.052Z %{host} %{message}
2018-05-08T03:02:05.055Z %{host} %{message}
2018-05-08T03:02:05.058Z %{host} %{message}
2018-05-08T03:02:05.060Z %{host} %{message}
2018-05-08T03:02:05.062Z %{host} %{message}
2018-05-08T03:02:05.064Z %{host} %{message}
2018-05-08T03:02:05.066Z %{host} %{message}
2018-05-08T03:02:05.069Z %{host} %{message}
[2018-05-08T11:03:00,274][INFO ][logstash.inputs.jdbc     ] (0.005000s) select * from std where creattime > '2018-05-08 03:02:04'
[2018-05-08T11:04:00,211][INFO ][logstash.inputs.jdbc     ] (0.009000s) select * from std where creattime > '2018-05-08 03:03:00'
 
'2018-05-08 03:03:00'这个时间不对,请问下这个时间怎么来的啊?select * from std where creattime >:sql_last_value  这是sql语句
已邀请:

tofu - 90IT小白

赞同来自: s60514

加了一句配置就好了:  jdbc_default_timezone =>"Asia/Shanghai"  input {
stdin {
  }
  jdbc {
    jdbc_driver_library => "mysql-connector-java-5.1.22-bin.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/dbzw"
    jdbc_user => "root"
    jdbc_password => "1234"
    schedule => "* * * * *"
    statement => "select * from std where creattime > :sql_last_value"
    type => "std"
    clean_run => "false"  
    jdbc_default_timezone =>"Asia/Shanghai"  
  }
 
}
output {
    elasticsearch {
        index => "stddb"
        document_type => "std"   
        hosts => "localhost:9200"
    }
     stdout {
   
  }
}
 
 
 

tofu - 90IT小白

赞同来自:

logstash.conf文件如下input {
stdin {
  }
  jdbc {
    jdbc_driver_library => "mysql-connector-java-5.1.22-bin.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/dbzw"
    jdbc_user => "root"
    jdbc_password => "1234"
    schedule => "* * * * *"
    statement => "select * from std where creattime > :sql_last_value"
    type => "std"
    clean_run => "false"  
  }
 
}
output {
    elasticsearch {
        index => "stddb"
        document_type => "std"   
        hosts => "localhost:9200"
    }
     stdout {
   
  }
}

要回复问题请先登录注册