通过 Logstash 将日志存入 Mysql
1,CentOS7安装Mysql并建好表
2,安装logstash-output-jdbc
./logstash-plugin install logstash-output-jdbc
3,下载mysql-connector-java-8.0.21.jar,拷贝至/opt
https://mvnrepository.com/artifact/mysql/mysql-connector-java
4,编辑logstash配置文件
output{
elasticsearch{
***
}
jdbc {
driver_jar_path => "/opt/mysql-connector-java-8.0.21.jar"
driver_class => "com.mysql.jdbc.Driver"
connection_string => "jdbc:mysql://127.0.0.1:3306/库名?user=USERNAME&password=PASSWORD&useUnicode=true&characterEncoding=UTF8"
statement => ["INSERT INTO 表名(field1,field2,field3) VALUES(?,?,?)","[value1_label]",[value2_labe2]","[value2_labe2]"]
}