Eighth Elasticsearch link MySQL Automatic Update database

Source: Internet
Author: User
Tags logstash

Incremental update

Input {jdbc {jdbc_driver_library= "D:\tools\mysql\mysql-connector-java-5.1.45/mysql-connector-java-5.1.45-bin.jar"Jdbc_driver_class= "Com.mysql.jdbc.Driver"jdbc_connection_string= "Jdbc:mysql://localhost:3306/canyin?characterencoding=utf-8&usessl=false"Jdbc_user= "Root"Jdbc_password= "228151"Statement= = "SELECT * FROM Goods"jdbc_paging_enabled= "true"jdbc_page_size= "50000"Schedule= "* * * * * *"type= "Foods"Record_last_run=trueLast_run_metadata_path= ""Clean_run=false}}filter {json {source= "Message"Remove_field= = ["Message"]}}output {stdout {codec=Rubydebug} elasticsearch {hosts= "127.0.0.1:9200"Index= "Goods"Document_type= "Foods"document_id= "%{id}"    }        } 

The parameters of the incremental update are described:

input {stdin {} JDBC {# database address port database name Jdbc_connection_string= "Jdbc:mysql://localhost:3306/shen"# Database user name Jdbc_user= "Root"# Database Password Jdbc_password= "Rootroot"# mysql Java driver address jdbc_driver_library= "/usr/share/logstash/mysql-connector-java-5.1.43-bin.jar"# The name of the driver class Jdbc_driver_class= "Com.mysql.jdbc.Driver"jdbc_paging_enabled= "true"jdbc_page_size= "50000"#是否记录上次运行的结果 Record_last_run=true#记录上次运行结果的文件位置 Last_run_metadata_path= ""#是否使用数据库某一列的值, Use_column_value=trueTracking_column= "id"#numeric或者timestamp Tracking_column_type= "Numeric"#如果为true则会清除 Last_run_metadata_path Record, that is, to restart synchronizing the data clean_run=false#sql_last_value根据tracking类型, default is 0 or 1970-1-1Statement= = "SELECT * from TABLE WHERE ID >: Last_sql_value"# SQL statement file, for complex queries, can be placed in a file. # Statement_filepath= "Filename.sql"# Set the listening interval, syntax is the same as Linux system cron schedule= "* * * * * *"}}output {stdout {codec=Json_lines} elasticsearch {hosts= "localhost:9200"Index= "Contacts"Document_type= "Contact"document_id= "%{id}"    }}

Chedule is now set to execute once every minute to facilitate observing behavior. Statefile This sentence must be added. $metrics. Lastexecutionstart is the key to this script, which refers to the last time the script was executed, and can be used to compare the time and the fields in the database to determine whether to update.
Reference: http://www.cnblogs.com/cocowool/p/mysql_data_to_elasticsearch_via_logstash.html
Http://www.cnblogs.com/zhongshengzhen/p/elasticsearch_logstash.html
Configuring Logstash https://www.elastic.co/guide/en/logstash/current/configuration.html#

Eighth Elasticsearch link MySQL Automatic Update database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.