简体   繁体   English

Logstash 设置为托管在 AWS RDS 上的 Mysql。 不会连接

[英]Logstash settup to Mysql hosted on AWS RDS. Won't connect

I have a MySQL DB hosted on AWS RDS.我有一个托管在 AWS RDS 上的 MySQL DB。 I am running ElasticSearch locally and using Logstash to retrieve data from MYSQL server that is on AWS to then push the data to my ElasticSearch DB.我在本地运行 ElasticSearch 并使用 Logstash 从 AWS 上的 MYSQL 服务器检索数据,然后将数据推送到我的 ElasticSearch DB。

The problem is that my logstash file isn't settup correctly I guess:问题是我的logstash文件没有正确设置我猜:

input {
    jdbc {
        jdbc_connection_string => "jdbc:mysql://aws.ffffffffff.us-east-1.rds.amazonaws.com:3306/dbName?user=userName&password=pword"
        jdbc_user => "user"
        jdbc_password => "pword"
        schedule => "* * * * *"
        jdbc_validate_connection => true
        jdbc_driver_library => "C:\Program Files (x86)\MySQL\Connector J 8.0\mysql-connector-java-8.0.19.jar"
        jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
        statement => "SELECT * from data-5"
        type => "data-5"
        tags => ["data-5"]
    }

    jdbc {
        jdbc_connection_string => "jdbc:mysql://aws.ffffffffff.us-east-1.rds.amazonaws.com:3306/dbName?user=userName&password=pword"
        jdbc_user => "user"
        jdbc_password => "pword"
        schedule => "* * * * *"
        jdbc_validate_connection => true
        jdbc_driver_library => "C:\Program Files (x86)\MySQL\Connector J 8.0\mysql-connector-java-8.0.19.jar"
        jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
        statement => "SELECT * from data-4"
        type => "data-4"
        tags => ["data-4"]
    }

    jdbc {
        jdbc_connection_string => "jdbc:mysql://aws.ffffffffff.us-east-1.rds.amazonaws.com:3306/dbName?user=userName&password=pword"
        jdbc_user => "user"
    jdbc_password => "pword"
    schedule => "* * * * *"
        jdbc_validate_connection => true
        jdbc_driver_library => "C:\Program Files (x86)\MySQL\Connector J 8.0\mysql-connector-java-8.0.19.jar"
        jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
        statement => "SELECT * from data-3"
        type => "data-3"
        tags => ["data-3"]
    }
}
output {
    stdout { codec => json_lines }

    if "data-5" in [tags] {
        elasticsearch {
            hosts => ["http://127.0.0.1:9200/"]
            index => "data-5"
            document_type => "data-%{+YYYY.MM.dd}"
        }
    }

    if "data-4" in [tags] {
        elasticsearch {
            hosts => ["http://127.0.0.1:9200/"]
            index => "data-4"
            document_type => "data-%{+YYYY.MM.dd}"
        }
    }

    if "data-3" in [tags] {
        elasticsearch {
            hosts => ["http://127.0.0.1:9200/"]
            index => "data-3"
            document_type => "data-%{+YYYY.MM.dd}"
        }
    }
}

This is the fun part of programming right?这就是编程的乐趣所在,对吧?

Anyway, locally I am on windows as you may be able to tell from the file path to the jdbc driver library.无论如何,在本地,我在 windows 上,因为您可以从文件路径中看出 jdbc 驱动程序库。 My jdbc connection to the AWS RDS is copied and pasted from AWS Console, so no typos were involved.我的 jdbc 连接到 AWS RDS 是从 AWS 控制台复制和粘贴的,因此不涉及拼写错误。

I am told that I only need to append jdbc:mysql:// to the url.有人告诉我,我只需要 append jdbc:mysql://到 Z572D4E421E5E6B9BC12Z851。 But is there anything I'm missing to do in the AWS console?但是在 AWS 控制台中我还有什么需要做的吗? Do I need to modify my RDS instance?我需要修改我的 RDS 实例吗?

The error by the way is:顺便说一句,错误是:

 Unable to connect to database. Tried 1 times 
{:error_message=>"Java::ComMysqlCjJdbcExceptions::CommunicationsException: 
Communications link failure\n\n
The last packet sent successfully to the server was 0 milliseconds ago. 
The driver has not received any packets from the server."

I had a similar issue, and SSL was not enabled for communication.我遇到了类似的问题,并且没有启用 SSL 进行通信。 So, AWS RDS was not allowing to connect.因此,AWS RDS 不允许连接。

I specified an additional query param useSSL=false to JDBC connection string, and problem was solved.我为 JDBC 连接字符串指定了一个额外的查询参数useSSL=false ,问题就解决了。

So, in your case, the jdbc_connection_string would be as follows:因此,在您的情况下, jdbc_connection_string如下所示:

"jdbc:mysql://aws.ffffffffff.us-east-1.rds.amazonaws.com:3306/dbName?useSSL=false&user=userName&password=pword"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM