I'm trying to install the jdbc plugin for Logstash on a AWS EC2 server so I can query a MySQL database. Logstash is working but I can't get the JDBC plugin to work. When I run Logstash I get this error:
Error: com.mysql.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
I tried installing the JDBC plugin based on this:
https://discuss.elastic.co/t/getting-started-with-jdbc-input-plugin/77162
The install looked like it worked:
[ec2-user@ settings]$ sudo /usr/share/logstash/bin/logstash-plugin install logstash-input-jdbc
Validating logstash-input-jdbc
Installing logstash-input-jdbc
Installation successful
But when I try to find the .jar file for the mysql connector it does not seem to exist on the system:
[ec2-user@ logstash]$ sudo find / -name "*connector-java*"
This is what my Logstash config file looks like:
input {
jdbc {
jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://***:3306/website"
jdbc_user => "***"
jdbc_password => "***"
statement => "SELECT * from runtime_ProdFull WHERE `MfPN` LIKE 'KO8%'"
}
}
How do I identify the correct name for jdbc_driver_library and how do I find it's path so I can add it to my config?
Thanks, Phil
SOLUTION: I downloaded the latest platform independent version from https://dev.mysql.com/downloads/connector/j/ to my PC, unzipped the mysql-connector-java-8.0.15.jar file and uploaded to the EC2 server via WinSCP to /var/lib/logstash/. Then changed the jdbc driver to:
jdbc_driver_library => "/var/lib/logstash/mysql-connector-java-8.0.15.jar"
You have to download JDBC driver by yourself. Go to this website and download appropriate driver for your database and then put it somewhere in your EC2. Then you just have to specify path to the downloaded driver in this field jdbc_driver_library and you're good to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With