I found that logstash won't shutdown when jdbc or es connection failed。 It troubles me because I'll never find this mistake unless I take the initiative to see it。
And i tried configue the jdbc plugin setting 'connection_retry_attempts' , still dosen't work。
I want to know how to make logstash stop where connection failed ? Please help me .
my config file:
input {
jdbc {
jdbc_driver_library => "/home/appadmin/tools/hive_extract/work_part/hive-jdbc-1.1.0-cdh5.13.0-standalone.jar"
jdbc_driver_class => "org.apache.hive.jdbc.HiveDriver"
jdbc_connection_string => "jdbc:hive2://xx.xx.xx.xx:10001"
jdbc_user => "appadmin"
jdbc_password => "appadmin"
connection_retry_attempts => 3
connection_retry_attempts_wait_time => 5
# parameters => { "favorite_artist" => "Beethoven" }
# schedule => "* * * * *"
statement => "select 2 as id, 4 as col4, 9 as col9 "
# statement_filepath => "/home/appadmin/tools/hive_extract/work_part/123.sql"
}
}
filter {
mutate{
remove_field => ["@version"]
remove_field => ["@timestamp"]
}
}
output {
elasticsearch {
hosts => ["http://xx.xx.xx.xx:9200"]
index => "zyk_test"
action => "update"
document_id => "%{id}"
doc_as_upsert => true
#user => "%es_user%"
#password => "%es_password%"
}
}
the jdbc error like this:
[2020-11-23T17:27:51,486][ERROR][logstash.inputs.jdbc ][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Unable to connect to database. Trying again {:error_message=>"Java::JavaSql::SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://10.87.134.52:10001: java.net.ConnectException: Connection refused (Connection refused)"}
[2020-11-23T17:27:52,892][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://xx.xx.xx.xx:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://xx.xx.xx.xx:9200/][Manticore::SocketException] Connection refused (Connection refused)"}
[2020-11-23T17:27:56,527][INFO ][org.apache.hive.jdbc.Utils][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Supplied authorities: 10.87.134.52:10001
[2020-11-23T17:27:56,530][INFO ][org.apache.hive.jdbc.Utils][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Resolved authority: 10.87.134.52:10001
[2020-11-23T17:27:56,534][ERROR][logstash.inputs.jdbc ][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Unable to connect to database. Trying again {:error_message=>"Java::JavaSql::SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://10.87.134.52:10001: java.net.ConnectException: Connection refused (Connection refused)"}
[2020-11-23T17:27:57,906][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://xx.xx.xx.xx:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://xx.xx.xx.xx:9200/][Manticore::SocketException] Connection refused (Connection refused)"}
[2020-11-23T17:28:01,577][INFO ][org.apache.hive.jdbc.Utils][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Supplied authorities: 10.87.134.52:10001
[2020-11-23T17:28:01,583][INFO ][org.apache.hive.jdbc.Utils][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Resolved authority: 10.87.134.52:10001
[2020-11-23T17:28:01,590][ERROR][logstash.inputs.jdbc ][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] Unable to connect to database. Tried 3 times {:error_message=>"Java::JavaSql::SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://10.87.134.52:10001: java.net.ConnectException: Connection refused (Connection refused)"}
[2020-11-23T17:28:01,596][ERROR][logstash.javapipeline ][main][27143fd552adc14fc6dd9893f77b8cea6995c7a8d1aedffa6fcdbb8252081084] A plugin had an unrecoverable error. Will restart this plugin.
and es error:
[2020-11-23T17:29:23,162][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://xx.xx.xx.xx:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://xx.xx.xx.xx:9200/][Manticore::SocketException] Connection refused (Connection refused)"}
[2020-11-23T17:29:28,174][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://xx.xx.xx.xx:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://xx.xx.xx.xx:9200/][Manticore::SocketException] Connection refused (Connection refused)"}
[2020-11-23T17:29:33,185][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://xx.xx.xx.xx:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://xx.xx.xx.xx:9200/][Manticore::SocketException] Connection refused (Connection refused)"}
[2020-11-23T17:29:38,196][WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://xx.xx.xx.xx:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://xx.xx.xx.xx:9200/][Manticore::SocketException] Connection refused (Connection refused)"}