繁体   English   中英

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

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

我有一个托管在 AWS RDS 上的 MySQL DB。 我在本地运行 ElasticSearch 并使用 Logstash 从 AWS 上的 MYSQL 服务器检索数据,然后将数据推送到我的 ElasticSearch DB。

问题是我的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}"
        }
    }
}

这就是编程的乐趣所在,对吧?

无论如何,在本地,我在 windows 上,因为您可以从文件路径中看出 jdbc 驱动程序库。 我的 jdbc 连接到 AWS RDS 是从 AWS 控制台复制和粘贴的,因此不涉及拼写错误。

有人告诉我,我只需要 append jdbc:mysql://到 Z572D4E421E5E6B9BC12Z851。 但是在 AWS 控制台中我还有什么需要做的吗? 我需要修改我的 RDS 实例吗?

顺便说一句,错误是:

 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."

我遇到了类似的问题,并且没有启用 SSL 进行通信。 因此,AWS RDS 不允许连接。

我为 JDBC 连接字符串指定了一个额外的查询参数useSSL=false ,问题就解决了。

因此,在您的情况下, 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