gpt4 book ai didi

jdbc - Logstash-JDBC-MYSQL配置错误

转载 作者:行者123 更新时间:2023-12-03 01:52:45 26 4
gpt4 key购买 nike

看完本教程之后;

https://www.youtube.com/watch?v=ZnI_rlrei1s

我正在尝试使用logstash和jdbc获取我的本地主机mysql(使用laravel valet mysql)以发送到elasticsearch服务器。

这是我的配置:

# file: db.conf
input {
jdbc {
# MySQL jdbc connection string to our database, mydb
jdb_connection_string => "jdbc:mysql://localhost:3306/dragon"
# The user we wish to execute our statement as
jdbc_user => "root"
# The user password
jdbc_password => ""
# The path to our downloaded jdbc driver
jdbc_driver_library => "/Users/muaz/downloads/logstash/mysql-connector-java-5.1.39-bin.jar"
# The name of the deliver clas for MySQL
jdbc_driver_class => "com.mysql.jdbc.Driver"
# Our query
statement = "SELECT * from Receipt"
}
}
output {
# stdout { codec => json_lines }
elasticsearch {
# protocol = https
index => "power_receipt"
document_type => "Receipt"
document_id => "%{id}"
host => "https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com"
}
}

我使用命令运行它(在logstash文件夹中):
./bin/logstash agent -f db.conf

它产生:
fetched an invalid config {:config=>"# file: db.conf\ninput {\n\tjdbc {\n\t\t# MySQL jdbc connection string to our database, mydb\n\t\tjdb_connection_string => \"jdbc:mysql://localhost:3306/dragon\"\n\t\t# The user we wish to execute our statement as \n\t\tjdbc_user => \"root\"\n\t\t# The user password\n\t\tjdbc_password => \"\"\n\t\t# The path to our downloaded jdbc driver\n\t\tjdbc_driver_library => \"/Users/muaz/downloads/logstash/mysql-connector-java-5.1.39-bin.jar\"\n\t\t# The name of the deliver clas for MySQL\n\t\tjdbc_driver_class => \"com.mysql.jdbc.Driver\"\n\t\t# Our query\n\t\tstatement = \"SELECT * from Receipt\"\n\t}\n}\noutput {\n\t# stdout { codec => json_lines }\n\telasticsearch {\n\t\t# protocol = https\n\t\tindex => \"slurp_receipt\"\n\t\tdocument_type => \"Receipt\"\n\t\tdocument_id => \"%{id}\"\n\t\thost => \"https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com\"\n\t}\n}\n\n\n", :reason=>"Expected one of #, => at line 15, column 13 (byte 521) after # file: db.conf\ninput {\n\tjdbc {\n\t\t# MySQL jdbc connection string to our database, mydb\n\t\tjdb_connection_string => \"jdbc:mysql://localhost:3306/dragon\"\n\t\t# The user we wish to execute our statement as \n\t\tjdbc_user => \"root\"\n\t\t# The user password\n\t\tjdbc_password => \"\"\n\t\t# The path to our downloaded jdbc driver\n\t\tjdbc_driver_library => \"/Users/muaz/downloads/logstash/mysql-connector-java-5.1.39-bin.jar\"\n\t\t# The name of the deliver clas for MySQL\n\t\tjdbc_driver_class => \"com.mysql.jdbc.Driver\"\n\t\t# Our query\n\t\tstatement ", :level=>:error}

怎么解决呢?

谢谢

最佳答案

您在jdbc输入的最后一行输入错字

statement = "SELECT * from Receipt"

应该读
statement => "SELECT * from Receipt"

同样在 elasticsearch输出中,您需要更改
host => "https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com"


hosts => ["https://search-power-yidhfhkidiiddcccyhyrijaagamu.ap-southeast-1.es.amazonaws.com"]

关于jdbc - Logstash-JDBC-MYSQL配置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39073928/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com