Creating Services with Pluggable database in RAC


For applications to access the Pluggable database, you need to create services for the PDB.  

Example:  Create order_oltp service associated with pocpdb1 (PDB) prefered on poccdb1(Container DB instance 1) and available on poccdb2 (Container DB instance 2)

srvctl add service -db poccdb -service order_oltp -pdb pocpdb1 -preferred poccdb1 -available poccdb2

srvctl start service -d poccdb -s order_oltp

SQL> connect sys@pocpdb1 as sysdba
Enter password:
Connected.
SQL> show con_name
POCPDB1

To check services of the pluggable database

select name, pdb from all_services;

From clusterware, you can check the service configuration of a container database using srvctl command

poccdb1 > srvctl config service -db poccdb
Service name: order_oltp
Service is enabled
Server pool: poccdb_order_oltp
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Global: false
Commit Outcome: false
Failover type:
Failover method:
TAF failover retries:
TAF failover delay:
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Edition:
Pluggable database name: pocpdb1
Maximum lag time: ANY
SQL Translation Profile:
Retention: 86400 seconds
Replay Initiation Time: 300 seconds
Session State Consistency:
Preferred instances: poccdb1
Available instances: poccdb2

Creating order_oltp Net Service name for Pluggale database

After define the service with property of the pluggable database, you can create the net service name order_oltp in the tnsnames.ora file for applications to access the PDBs.  The connection string should look like this..

ORDER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 12cracpoc-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = order_oltp)
    )
  )

sqlplus > connect sys@ORDER as sysdba
Enter password:

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

No comments:

Post a Comment