Connectstrings in the OCI

Connectstrings in the OCI

Under the category; asked and answered. When you have created a Data Guard config, the most obvious is that you eventually would like to connect to the Database. This is done using a connect string, often specified in tnsnames.ora or via jdbc-thin.

When you read this blog post, then you end up with a Primary and Standby database.

One of the questions I got last week “How can we add 2 service names in the same connect string”? I was a bit surprised. After a few questions, the main question was “What is the connect string we need to use in a OCI Data Guard configuration”?

One thing I always recommend is to read the getting started guides. This one is actually pretty good.

Well! That is actually a very good question. When we take this blog post, as the example, you see that we created the CLDGDEMO_PDB1 PDB in this database.

When we check the both db connection strings, we see that for AD1 the SERVICE_NAME=CLDGDEMO_fra1pv.p***.vcn***.oraclevcn.com) is used and for AD2 CLDGDEMO_fra28n.p***m.vcn***.oraclevcn.com

That immediately clarifies the first version of the question, right? The solution is rather simple.

So when you create a Database Service, you provide the PDB-name and that PDB name is also your SERVICE_NAME to connect to. If you need more services, then you need to add them manually using srvctl add service.

On the vm in AD1

When we check the VM on AD2

After a role transition, you can just point and click this operation

When the operation is completed, we expect after the role reversal, primary in AD2 and standby in AD1, but we only want 1 service for the PDB and we want that in AD2 at this point, right?

So lets verify.
AD2

Then we go to AD1 

That looks good and the most important is the service.
AD1 (standby now)

AD2 (now primary)

So this leads to the answer on the question. 
If I take my Demo environment as an example, your connectstring would be:

As always, questions, remarks? 
find me on twitter @vanpupi

Leave a Reply

Your email address will not be published. Required fields are marked *

one + 2 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: