【问题标题】:How to pull data from aws rds postgresql using kafka locally?如何在本地使用 kafka 从 aws rds postgresql 中提取数据?
【发布时间】:2019-06-01 21:07:29
【问题描述】:

我在 aws 上有 postgresql 数据库服务器。我在本地机器上设置了一个节点 kafka 集群,并想从 postgresql 数据库服务器中提取数据。我一直在使用 jdbc 源连接器,这里是配置(更改了实际值)

name=test-source-postgresql-jdbc-01
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
key.converter=io.confluent.connect.avro.AvroConverter
key.converter.schema.registry.url=http://localhost:8081
connection.url=jdbc:postgresql://hostname:5432/dbname? 
user=abc&password=pwd
connection.user=abc
connection.password=pwd
table.whitelist=abc1
mode=timestamp
timestamp.column.name=timestamp
topic.prefix=test-postgresql-

运行时出现以下错误

ERROR Failed to create job for etc/kafka-connect-jdbc/quickstart-postgresql.properties (org.apache.kafka.connect.cli.ConnectStandalone:102)
ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:113)
java.util.concurrent.ExecutionException: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector 
configuration is invalid and contains the following 2 error(s):
Invalid value org.postgresql.util.PSQLException: Connection to hostname:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. for configuration Couldn't open connection to jdbc:postgresql://abc:5432/dbname?user=abc&password=pwd

curl localhost:8083/connector-pluginsPlease click link

ls share/java/kafka-connect-jdbc -l Please click link

任何帮助将不胜感激!

【问题讨论】:

  • 您需要进一步返回您的工作日志以查看关闭的原因是什么。这可能是由正在关闭的进程(SIGTERM、关闭控制台窗口等)触发的,或者是某些原因导致它中止。
  • 这可能是 SSH 问题,因为我只使用 SSH 连接像 postico/pgAdmin/PSequel 这样的数据库客户端,但 kafka 不确定如何配置它。
  • 你可以使用 GNU screen 来保持进程即使在断开连接时也能运行
  • 我认为问题是我的连接器没有运行。我在问题部分添加了错误日志文件。请看一下。
  • 我在您的问题中看不到错误日志,只有原始日志输出,其中仅显示 Kafka Connect 正在关闭。

标签: postgresql amazon-rds apache-kafka-connect confluent-platform


【解决方案1】:

正如您所提到的,您通过 SSH 隧道连接到 RDS。我认为您不能将 Kafka JDBC 连接器配置为自动通过 SSH 隧道,但您可以手动创建 SSH 隧道,然后配置 Kafka 连接器以通过此隧道连接到 RDS - 详细说明 here

根据您的配置,您可以使用命令创建 SSH 隧道

ssh -N -L 5432:rds.hostname:5432 uername@ec2instnace.com -i ~/.ssh/your_key

您可以使用以下方法测试与数据库的连接:

psql -h localhost -p 5432

您的连接器配置将是

connection.url=jdbc:postgresql://localhost:5432/dbname?user=abc&password=pwd

【讨论】:

  • 正如您建议的那样,我使用 SSH 登录,我使用的是 confluent kafka,所以当我运行时遇到同样的错误。在融合文件夹中我不能这样做,我在终端上运行了这个命令。在kafka中必须有一些使用SSH的过程。有什么想法请告诉我。
猜你喜欢
  • 2018-03-07
  • 2015-11-16
  • 1970-01-01
  • 1970-01-01
  • 2019-09-12
  • 2020-03-12
  • 1970-01-01
  • 2021-09-05
  • 1970-01-01
相关资源
最近更新 更多