Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Database connected by dblink #71

Open
habolanos opened this issue Nov 4, 2024 · 1 comment
Open

Multi Database connected by dblink #71

habolanos opened this issue Nov 4, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@habolanos
Copy link

habolanos commented Nov 4, 2024

Hello, gvenzl. It’s a pleasure to greet you again.

First of all, I want to express my appreciation for the fantastic work you do. It’s incredibly valuable to our community, and we follow your work with great enthusiasm.

Today I bring you a new requirement, which involves ensuring a dblink to a database when they are created in multiple mode.

How could we generate a dblink to one or more databases when they are created in multiple mode?

@habolanos habolanos changed the title Schema to apply the initial scripts associated with the /container-entrypoint-initdb.d volume Multi Database connected by dblink Nov 4, 2024
@gvenzl gvenzl self-assigned this Dec 7, 2024
@gvenzl gvenzl added the question Further information is requested label Dec 7, 2024
@gvenzl
Copy link
Owner

gvenzl commented Dec 7, 2024

Hi @habolanos,

Likewise!
Thanks for the kind words, and also, thank you for your continued interest in these images!

I'm afraid I will need more details to provide a good answer.
First of all, when you say multiple databases, do you mean pluggable databases inside the container database within one running Docker container, or do you mean multiple Docker containers running and trying to facilitate DB Link communication across these?

I'm also not aware of the multiple mode, could you elaborate more?

For the former of having multiple PDBs within a CDB, a DB link is fairly easily created. As everything is within the same network, you can easily reference the individual PDBs via their service name, for example:

CREATE DATABASE LINK gerald_remote 
   CONNECT TO gerald IDENTIFIED BY LetsTest1
   USING '(DESCRIPTION=
            (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
            (CONNECT_DATA=(SERVICE_NAME=<PDB_name>))
          )';

For the latter, this is where container networking comes in, and depending on the containerization solutions (docker, podman, minikube, etc) it will work differently.
For Podman, you have to first create a network and make sure that all containers are within the same network.
That's done also very easily, just:

podman network create <network_name>
podman run ... --network <network_name> --name container1 gvenzl/oracle-free:slim

Make sure that you properly name your containers with the --name parameter, then the container can be referenced via this name from other containers. It essentially becomes the hostname for the container. So in the example of the first container having the name container1 above, in a second container sharing the same network (the podman run also had the --network <network_name>), you can reference the container1 in the DB link, for example:

CREATE DATABASE LINK gerald_remote 
   CONNECT TO gerald IDENTIFIED BY LetsTest1
   USING '(DESCRIPTION=
            (ADDRESS=(PROTOCOL=TCP)(HOST=container1)(PORT=1521))
            (CONNECT_DATA=(SERVICE_NAME=<PDB_name>))
          )';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants