Use logstash to synchronize one database to another
Use cmd to execute logstash synchronization processing data under windows successfully but publish to linux and execute java.lang.IllegalAccessError: tried to access class com.mysql.jdbc.EscapeProcessor from class com.mysql.jdbc.ConnectionImpl
I read many articles and found that there is no such kind of solution
input { jdbc { # Database drive path jdbc_driver_library => " D:\logstash-7.14.0-windows-x86_64\logstash-7.14.0\vendor\jar\jdbc\mysql-connector-java-5.1.46-bin.jar " # Drive name jdbc_driver_class => " com.mysql.jdbc.Driver " # Database connection string jdbc_connection_string => " jdbc:mysql://****?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true " # database username jdbc_user => "" # Database password jdbc_password => "" # The time interval for repeating the import task: minute -hour-day-month- week schedule => " */1 * * * * * " # Imported table (query SQL, can filter data) statement => " SELECT * from hot_data limit 1000 " # Default time zone jdbc_default_timezone => " Asia/Shanghai " } } filter{ json{ source => " message " } } output { stdout{ codec => rubydebug{} } jdbc { driver_jar_path => " D:\logstash-7.14.0-windows-x86_64\logstash-7.14.0\vendor\jar\jdbc\mysql-connector-java-5.1.46-bin.jar " driver_class => " com.mysql .jdbc.Driver " connection_string => " jdbc:mysql://***?user=&password= " statement => [ " INSERT INTO hot_data (title, url, content, cnt, site_name, hot_tag) VALUES(?,? , ?, ?, ?, ?) " , " title " , " url " , " content " ," cnt ", " site_name " , " hot_tag " ] } }
There is no problem with the execution of the above in windows cmd, and the data will be written, but there will be problems under linux. Many methods have been tried and finally solved.
input { jdbc { # Database drive path jdbc_driver_library => " /home/fanxu/logstash/logstash-7.0.0/vendor/jar/jdbc/mysql-connector-java-8.0.26.jar " # Drive name jdbc_driver_class => " com.mysql.jdbc.Driver " # Database connection string jdbc_connection_string => " jdbc:mysql://****?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true " # database username jdbc_user => " " # Database password jdbc_password => " " # The time interval for repeating the import task: minute -hour-day-month- week schedule => " */1 * * * * * " # Imported table (query SQL, can filter data) statement => " SELECT * from hot_data limit 1000 " # Default time zone jdbc_default_timezone => " Asia/Shanghai " } } filter{ json{ source => " message " } } output { stdout{ codec => rubydebug{} } jdbc { driver_jar_path => " /home/fanxu/logstash/logstash-7.0.0/vendor/jar/jdbc/mysql-connector-java-5.1.46-bin.jar " driver_class => " com.mysql.jdbc.Driver " connection_string => " jdbc:mysql://****?user=&password= " statement => [ " INSERT INTO hot_data (title, url, content, cnt, site_name, hot_tag) VALUES(?, ?, ?, ?, ?, ?) " , " title " , " url " , " content " , "cnt " ," site_name " , " hot_tag " ] } }
Add two jars under the /vendor/jar/jdbc/ path, and use them separately to write data normally
Similar Posts:
- [Solved] Logstash Error: com.mysql.jdbc.Driver not loaded. Are you sure you’ve included the correct jdbc driver in :jdbc_driver_library
- Error occurred when Android connected to cloud MySQL: java.lang.NoClassDefFoundError : Failed resolution of: Ljava/sql/SQLType
- SSM Project Error: java.sql.SQLException: Access denied for user ‘????…§’@’localhost’ (…
- java.sql.SQLException: Unable to load authentication plugin ‘caching_sha2_password‘
- The jdbc driver imported from idea into MySQL appears “Java. Lang. classnotfoundexception: com. Mysql. CJ. JDBC. Driver”
- MySQL database insert into statement with parameters Error
- Java.lang.classnotfoundexception: com.mysql.cj.jdbc.driver can’t find jar package, path problem
- [Solved] Mybatis-config Error: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: failed to parse the connection string near ‘;useUnicode=true&
- [Solved] MySQL Error: com.mysql.cj.jdbc.util.TimeUtil.loadTimeZoneMappings(TimeUtil.java:163)
- [Solved] Python import module error: importerror: no module named mysql.connector