Skip to content

udbhav/pg-es-sync-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Postgres -> Elasticsearch Kafka Sync Demo

Getting Started

Bring up the services with docker-compose:

docker-compose up -d

Create a database and table:

docker-compose exec db psql -U postgres -c "create database test;"
docker-compose exec db psql test -U postgres -c "create table test(id serial primary key not null, name text);"

Create the postgres and elasticsearch connectors (If you're using different table names, make sure to update topics in docker/connect/es-writer.json before creating):

curl -H "Accept:application/json" -H "Content-Type:application/json" -vX POST localhost:8083/connectors -d @docker/connect/db-reader.json
curl -H "Accept:application/json" -H "Content-Type:application/json" -vX POST localhost:8083/connectors -d @docker/connect/es-writer.json

Create data in the table:

docker-compose exec db psql test -U postgres -c "insert into test (name) values ('foo');"

Look at your data in elasticsearch: http://localhost:9200/test.public.test/_search

Further Reading

This demo uses images provided by Confluent to run Zookeeper, Kafka, and Kafka Connect, and the docker-compose setup is taken from their cp-all-in-one-community setup.

The Kafka Connect image uses the Confluent base image and adds 2 plugins, the Debezium connector for PostgreSQL and Elasticsearch Service Sink Connector for Confluent Platform.

About

An example of syncing Postgres data to Elasticsearch via Kafka

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published