Logstash mysql using jdbc on windows: library error


(Krushnat Khawale) #1

I want to insert data from mysql to elasticsearch using logstash.

when I am running command, logstash -f myconf.conf
I am getting following error:

D:\Users\admin\setups\logstash-2.1.1\bin>logstash -f myconf.conf

io/console not supported; tty will not be manipulated
Settings: Default filter workers: 2
Error: com.jdbc.mysql.Driver not loaded. Are you sure you've included the correc
t jdbc driver in :jdbc_driver_library?
You may be interested in the '--configtest' flag which you can
use to validate logstash's configuration before you choose
to restart a running system.

I am using following conf settings...

 input {
jdbc {
jdbc_driver_library => "D:/mysql-connector-java-5.1.37-bin.jar"
jdbc_driver_class => "com.jdbc.mysql.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/testdatabase"
jdbc_user => "root"
jdbc_password => "root"
schedule => "5"
statement => "SELECT * from testtable"
}
}

output {
elasticsearch {
hosts => "localhost"
action => "index"
index => "testindex"
}
stdout { codec => rubydebug }
}

My java version is

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

I am using MySQL Server version: 5.7.9

And I've placed my jar in d: [ d-drive ]

I've spent enough time on this, and referred google for this, but didn't get solution.
Is there any PATH setting is required for loading library?
Suggest necessary solution.


(Magnus B├Ąck) #2

What's in myconf.conf?


(Krushnat Khawale) #3

Hi magnusbaeck,
Please see the post again, I've edited for myconf.conf


(Krushnat Khawale) #4

Error message I am receiving here is,

Error: com.jdbc.mysql.Driver not loaded. Are you sure you've included the correc
t jdbc driver in :jdbc_driver_library?


(Krushnat Khawale) #5

FYI, I am using Logstash 2.1.1


(Krushnat Khawale) #6

myconf.conf contains

input {
jdbc {
jdbc_driver_library => "D:/mysql-connector-java-5.1.37-bin.jar"
jdbc_driver_class => "com.jdbc.mysql.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/testdatabase"
jdbc_user => "root"
jdbc_password => "root"
schedule => "5"
statement => "SELECT * from testtable"
}
}

output {
elasticsearch {
hosts => "localhost"
action => "index"
index => "testindex"
}
stdout { codec => rubydebug }
}

(razafinr) #7

For your jdbc_driver_class try Java::com.jdbc.mysql.Driver


(Krushnat Khawale) #8

Thanks @razafinr

But did not work.


(Craig Foote) #9

The driver class should be com.mysql.jdbc.Driver.


(Krushnat Khawale) #10

What a silly mistake. I need to be more careful about spellings.

THANKS @CraigFoote :christmas_tree:


(system) #11