Logstash: невозможно подключиться к внешней базе данных Amazon RDS - PullRequest
0 голосов
/ 16 января 2019

Я относительно новичок в logstash & Elasticsearch ...

Установлен logstash & Elasticsearch с использованием в MacOS Mojave (10.14.2):

brew install logstash
brew install elasticsearch

Когда я проверяю эти версии:

brew list --versions

Получите следующий вывод:

elasticsearch 6.5.4
logstash 6.5.4

Когда я открываю Google Chrome и набираю это в поле URL-адреса:

localhost:9200

Это ответ JSON, который я получаю:

{
    "name" : "9oJAP16",
    "cluster_name" : "elasticsearch_local",
    "cluster_uuid" : "PgaDRw8rSJi-NDo80v_6gQ",
    "version" : {
        "number" : "6.5.4",
        "build_flavor" : "oss",
        "build_type" : "tar",
        "build_hash" : "d2ef93d",
        "build_date" : "2018-12-17T21:17:40.758843Z",
        "build_snapshot" : false,
        "lucene_version" : "7.5.0",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
    },
    "tagline" : "You Know, for Search"
}

Внутри:

/usr/local/etc/logstash/logstash.yml

Содержит следующие переменные:

path.data: /usr/local/Cellar/logstash/6.5.4/libexec/data
pipeline.workers: 2
path.config: /usr/local/etc/logstash/conf.d
log.level: info
path.logs: /usr/local/var/log

Внутри:

/usr/local/etc/logstash/pipelines.yml

Содержит следующие переменные:

- pipeline.id: main
path.config: "/usr/local/etc/logstash/conf.d/*.conf"

Установите следующий файл logstash_etl.conf:

/usr/local/etc/logstash/conf.d

Его содержимое:

input {
    jdbc {
       jdbc_connection_string => "jdbc:mysql://myapp-production.crankbftdpmc.us-west-2.rds.amazonaws.com:3306/products"
       jdbc_user => "products_admin"
       jdbc_password => "products123"
       jdbc_driver_library => "/etc/logstash/mysql-connector/mysql-connector-java-5.1.21.jar"
       jdbc_driver_class => "com.mysql.jdbc.driver"
       schedule => "*/5 * * * *"
       statement => "select * from products"
       use_column_value => false
       clean_run => true
    }
}

# sudo /usr/share/logstash/bin/logstash-plugin install logstash-output-exec
output {
   if ([purge_task] == "yes") {
         exec {
             command => "curl -XPOST 'localhost:9200/_all/products/_delete_by_query?conflicts=proceed' -H 'Content-Type: application/json' -d'
                 {
                   \"query\": {
                     \"range\" : {
                       \"@timestamp\" : {
                         \"lte\" : \"now-3h\"
                       }
                     }
                   }
                 }
             '"
        }
    } 
    else {
        stdout { codec => json_lines}
        elasticsearch {
            "hosts" => "localhost:9200"
            "index" => "product_%{product_api_key}"
            "document_type" => "%{[@metadata][index_type]}"
            "document_id" => "%{[@metadata][index_id]}"
            "doc_as_upsert" => true
            "action" => "update"
            "retry_on_conflict" => 7
        }
    }
}

Когда я делаю это:

brew services start logstash

Получите следующее в моем /usr/local/var/log/logstash-plain.log файле:

[2019-01-15T14:51:15,319][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x399927c7 run>"}
[2019-01-15T14:51:15,663][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-01-15T14:51:16,514][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2019-01-15T14:57:31,432][ERROR][logstash.inputs.jdbc     ] Unable to connect to database. Tried 1 times {:error_message=>"Java::ComMysqlCjJdbcExceptions::CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."}
[2019-01-15T14:57:31,435][ERROR][logstash.inputs.jdbc     ] Unable to connect to database. Tried 1 times {:error_message=>"Java::ComMysqlCjJdbcExceptions::CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."}[2019-01-15T14:51:15,319][INFO ][logstash.pipeline        ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x399927c7 run>"}
[2019-01-15T14:51:15,663][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2019-01-15T14:51:16,514][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
[2019-01-15T14:57:31,432][ERROR][logstash.inputs.jdbc     ] Unable to connect to database. Tried 1 times

Что я, возможно, делаю не так?

Есть ли способ получить дамп (например, mysqldump) с сервера Elasticsearch (Stage или Production), а затем повторно импортировать в локальный экземпляр, на котором работает Elasticsearch, без использования logstash?

Это тот же файл конфигурации, который работает внутри производственного экземпляра Amazon EC-2, но не знаете, почему он не работает в моем локальном экземпляре macOS Mojave?

...