CloudNative PostgreSQL 17 container with Oracle integration support (Oracle version 19.25.0.0.0)
617
This project provides a Docker image for PostgreSQL with Oracle Foreign Data Wrapper (FDW) support, enabling seamless interaction between PostgreSQL and Oracle databases.
The image is built on top of the CloudNative PostgreSQL image and includes the Oracle Instant Client and the oracle_fdw extension. This setup allows PostgreSQL to efficiently query and manipulate data stored in Oracle databases, facilitating data integration and migration scenarios.
Key features of this Docker image include:
Dockerfile: Contains the instructions for building the Docker imageREADME.md: This file, providing project documentationTo build the Docker image locally, run the following command in the repository root:
docker build -t postgres-oracle-fdw .
To start a container using this image:
docker run -d --name postgres-oracle -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword postgres-oracle-fdw
Replace mysecretpassword with a secure password of your choice.
You can connect to the PostgreSQL database using any PostgreSQL client. For example, using psql:
psql -h localhost -U postgres
You will be prompted for the password you set when starting the container.
To use the Oracle Foreign Data Wrapper, follow these steps:
CREATE EXTENSION oracle_fdw;
CREATE SERVER oracle_server
FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver '//oracle-host:1521/ORCLPDB1');
-- or connect with TNS service
CREATE SERVER oracle_server
FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver
'(description=(load_balance=on)(failover=on)
(address_list=(source_route=yes)
(address=(protocol=tcp)(host=oracle-host)(port=1521))
(address=(protocol=tcp)(host=oracle-host)(port=1522))
)
(connect_data=(service_name=ORCLPDB1)))'))
Replace oracle-host with your Oracle server's hostname or IP address, and ORCLPDB1 with your Oracle service name.
CREATE USER MAPPING FOR CURRENT_USER
SERVER oracle_server
OPTIONS (user 'oracle_user', password 'oracle_password');
Replace oracle_user and oracle_password with your Oracle database credentials.
CREATE FOREIGN TABLE oracle_employees (
employee_id integer,
first_name text,
last_name text
)
SERVER oracle_server
OPTIONS (schema 'HR', table 'EMPLOYEES');
This creates a foreign table oracle_employees that maps to the EMPLOYEES table in the HR schema of your Oracle database.
SELECT * FROM oracle_employees LIMIT 5;
If you encounter this error, ensure that:
CREATE SERVER statement.To enable verbose logging for oracle_fdw:
ALTER SERVER oracle_server OPTIONS (ADD log_level 'debug');
Check the PostgreSQL logs for detailed debug information:
docker logs postgres-oracle
pg_stat_foreign_tables view for statistics on foreign table usage.EXPLAIN ANALYZE to understand query execution plans involving foreign tables.When a query is executed against a foreign table in PostgreSQL:
[PostgreSQL Client] <-> [PostgreSQL] <-> [oracle_fdw] <-> [Oracle Instant Client] <-> [Oracle Database]
Note: The Oracle Instant Client and oracle_fdw extension act as intermediaries, handling the communication between PostgreSQL and the Oracle database. This allows for seamless integration of Oracle data into PostgreSQL queries.
The project defines the following infrastructure in the Dockerfile:
ghcr.io/cloudnative-pg/postgresql:17-bullseyeThese components work together to create a PostgreSQL environment capable of interacting with Oracle databases through foreign data wrappers.
Content type
Image
Digest
sha256:ff8ff3098…
Size
561.3 MB
Last updated
12 months ago
docker pull st4nleylaw/postgres-container:17.1.5