#/etc/logstash/conf.d/logstash.conf
jdbc {
jdbc_driver_library => "/home/xxx/mysql-connector-java-5.1.40-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/kuname?useSSL=false&zeroDateTimeBehavior=convertToNull&useUnicode=yes&characterEncoding=UTF-8"
jdbc_user => "xxxx"
jdbc_password => "xxxxx"
statement => "select * from tablename"
jdbc_paging_enabled => true
jdbc_page_size => 200000
type => "xxxx"
}
filter {
...
}
output {
stdout { codec => rubydebug }
elasticsearch {
hosts => ["localhost:9200"]
index => "xxxxx"
}
}
說明:
useSSL=false 關(guān)閉SSL
useUnicode=yes&characterEncoding=UTF-8 指定編碼
zeroDateTimeBehavior=convertToNull 如果有時間字段值為0000-00-00時會報錯,轉(zhuǎn)化為null
jdbc_paging_enabled => true 開啟分頁
如果遇到內(nèi)存不足錯誤
Error: Your application used more memory than the safety cap of 10240M.
Specify -J-Xmx####m to increase it (#### = cap size in MB).
Specify -w for full OutOfMemoryError stack trace
修改以下文件手動指定
#/etc/default/logstash
LS_HEAP_SIZE="xxxxm"