我在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-plugins Please click link
ls share / java / kafka-connect-jdbc -l Please click link
任何帮助将不胜感激!
答案 0 :(得分:0)
如前所述,您正在通过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