En oracle se tiene un esquema llamado debezium que contiene el siguiente script demobld.sql
del cual la tabla EMP y SALGRADE es la que se sincronizara a postgres,creando la estructura de la tabla y sincronizando los insert, update y delete hechos en esa tabla.
Clonar este repositorio
git clone [email protected]:ivziete/debezium-oracle-postgres.git
cd debezium-oracle-postgres
Dentro de esta carpeta descargar el servidor oracle ya configurado
Descomprimir como usuario root
sudo tar xf oracle.xz
tar xf instantclient_12_2.xz
export DEBEZIUM_VERSION=1.3
docker-compose up -d
export DEBEZIUM_VERSION=1.3
docker-compose -f docker-compose-apicurio.yml up -d
export DEBEZIUM_VERSION=1.3
docker-compose -f docker-compose-avro.yml up -d
docker-compose logs -f
- Host: localhost:5432
- SID: orcl
- User: debezium
- Pass: dbz
- Host: localhost:5432
- DB: inventory
- User: postgresuser
- Pass: postgrespw
docker-compose exec postgres bash -c 'psql -U $POSTGRES_USER $POSTGRES_DB'
\dt+
select * from emp
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" http://localhost:8083/connectors/ -d @jdbc-sink.json
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" http://localhost:8083/connectors/ -d @jdbc-sink-salgrade.json
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" http://localhost:8083/connectors/ -d @source.json
Verificar nuevamente postgres ya tendra la tabla emp y salgrade, puede usar el esquema demobld.sql
para referencia.
Pueden ver un demo de como se ve aqui:
docker-compose -f docker-compose-apicurio.yml exec ksqldb ksql http://ksqldb:8088
LIST TOPICS;
print 'emp' from beginning;
print 'salgrade' from beginning;
SET 'auto.offset.reset' = 'earliest';
create stream emp_stream_dbz_src with (KAFKA_TOPIC='emp',value_format='AVRO');
create stream salgrade_stream_dbz_src with (KAFKA_TOPIC='salgrade',value_format='AVRO');
select op,after->empno,before->sal as before_sal,after->sal as after_sal from emp_stream_dbz_src where empno=7934 emit changes;
select op,after->empno,before->sal as before_sal,after->sal as after_sal from emp_stream_dbz_src where after->empno=7934 emit changes;
docker-compose -f docker-compose-apicurio.yml up -d --build
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" http://localhost:8083/connectors/ -d @jdbc-sink-mongo.json