postgresqlHow do I set up a PostgreSQL Kafka Connector?
-
Install the Confluent Platform to your machine.
-
Create a Kafka Connector configuration file. The following example uses a file named
postgres-sink.properties
:
name=postgres-sink
connector.class=io.confluent.connect.jdbc.JdbcSinkConnector
tasks.max=1
connection.url=jdbc:postgresql://<hostname>:<port>/<database>
connection.user=<username>
connection.password=<password>
topics=<topic1>,<topic2>
auto.create=true
insert.mode=upsert
- Run the Kafka Connector with the configuration file:
$ confluent load postgres-sink -d postgres-sink.properties
- Verify that the connector is running:
$ confluent status connectors
Output example
postgres-sink RUNNING
- Create a PostgreSQL table for the topics you specified:
CREATE TABLE <topic1> (
id SERIAL,
key VARCHAR(255),
value VARCHAR(255)
);
-
Publish messages to the topics you specified in the configuration file.
-
Verify that the messages have been successfully sent to your PostgreSQL database.
Helpful links
More of Postgresql
- How can Zalando use PostgreSQL to improve its software development?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I set a PostgreSQL interval to zero?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL's "zero if null" feature?
- How do I rename a table in PostgreSQL?
- How do I use PostgreSQL and ZFS together?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
See more codes...