Search code examples
oracleoracle12cpluggable-database

Is it possible to swap oracle 12c PDBs


We have 2 pluggable databases in the same cdb. Lets call them pdb1 and pdb2. These are in out test environment and you can think of thwm as separate uat environments. Each pdb has the defaul service (pdb1/pdb2) as well as 1 service i created (pdb1_s1/pdb2_s2). Several java applications point at either of the pdbs (uat1 app servers point at pdb1 sercices, uat2 servers point at pdb2). Pbd1 and pdb2 have the same tables but with different data.

I would like to 'swap' the pdbs such that uat1 servers still use pdb_s1 service but that service really points at pdb2. Why? Lets say uat1 is the main env we test in but the data in that database (pdb1) is old/corrupted. We cant switch to uat2 for testing since that has other issues in the java servers.

I have 12c installed locally to test a solution. I am using dbms_services since srvctl doesnt seem to work on non clustered env (but in the end will need to get this solution using srvctl since uat is clustered).

I found the only way to accomplish swapping the services is to delete the services from both pdbs and then add them back in opposite pdb (create pdb1_s1 in pdb2 and create pdb2_s1 in pdb1). Then i rename the pdbs (pdb1-> pdb2 and pdb2->pdb1). It sort of works.

The issue is that the default service (pdb1) still points to pdb1. I tried deleting pdb1 service from pdb1 and creating pdb2 service in pdb1 but caused issues (and the service does not start when i restart the database).

Is it possible to delete default service and create a new default service with new name?

How do i make non default services start when the server starts? I tried save state but that doesn seem to work.


Solution

  • The issue was our DBAs were trying to rename the service to one that already exists without deleting those

    existing services:

    • PDB1 / PBD1_S1
    • PDB2 / PBD2_S1

    So if you name PBD1_S1 to PBD2_S1 it is failing since the service already exists in another PBD.

    The solution is to also have temp name for the services as well as the pbds.

    • rename service : PBD1_S1 to PBD1_S1_TEMP
    • rename service : PBD2_S1 to PBD1_S1
    • rename service : PBD1_S1_TEMP to PBD2_S1
    • rename pbd : PBD1 to PBD1_TEMP
    • rename pbd : PBD2 to PBD1
    • rename pbd : PBD1_TEMP to PBD2

    Of course this took me (not a DBA) a week to realize what the issue was. Our DBAs are on a separate team, dont seem to care about what we are trying to do, work mainly during IST hours (10 hour time difference), dont respond to emails or chats, are overloaded with prod support issues hence all other requests take forever, wont share error logs or much of anything they tried to fix the issue, and mainly respond they are waiting for oracle support and are themselves blocked.