2016-05-13 59 views
0

我有一张20GB数据表,其中有5000万行。需要使用logstash jdbc输入插件迁移到ElasticSearch。我已经尝试了所有基本的实现,但需要帮助才能批量迁移数据,即一次只能处理10,000行。我不知道如何以及在何处指定此计数以及下次运行logstash时如何更新它。请帮我解决这个问题Logstash JDBC输入插件:以批量计数从mysql迁移数据

这是我有:

input { 
    jdbc { 
     jdbc_driver_library => "mysql-connector-java-5.1.12-bin.jar" 
     jdbc_driver_class => "com.mysql.jdbc.Driver" 
     jdbc_connection_string => "jdbc:mysql://localhost/db" 
     jdbc_validate_connection => true 
     jdbc_user => "root" 
     jdbc_password => "root" 
     clean_run => true 
     record_last_run => true 
     use_column_value => true 
     jdbc_paging_enabled => true 
     jdbc_page_size => 5 
     tracking_column => id 
     statement => "select * from employee" 
    } 
} 

在此先感谢。

+1

这有帮助吗? https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_dealing_with_large_result_sets – Val

+0

谢谢瓦尔,请给我举一些例子,说明如何实现它。 – Chitra

+0

有一篇优秀的博客文章,提供了从A到Z的示例:https://www.elastic.co/blog/logstash-jdbc-input-plugin – Val

回答

1

您需要将jdbc_paging_enabled设置为true,以使pagniation正常工作。

但是,您还需要确保clean_run设置为false,否则分页将不起作用。

+0

非常感谢你的指导,我可以实现我想要的。 – Chitra

+0

太棒了,很高兴帮助! – Val

+1

你应该考虑接受这个答案,如果它帮助你。 – Val