OCCS: Copying and moving a PDB from a container database located on Container Cloud Service into a container database located on Database Cloud Service


Two Cloud services must be provisioned:

  • One multitenant 12cR2 database located on Database Cloud Services
  • One Container Cloud service

Once these services are provisioned:

  • A 12cR2 docker image must be deployed on the container. Once a container with this images is started, together with the ‘ccs’ multitenant database with a first ccsa pdb, the multitenant database  must be switched to archive log, and a new schema must be created to connect to via the database located on dbcs.
  • Security rules must setup in such a way to allow SQL*Net connectivity between both database hosts.
  • From the container database located on DBcs, a database link must be created to access the container database.

To deploy the 12cR2 image, first added the oracle container registry

ccs01

Then, when deploying the container, map the default listener port 1521 to the host port 1531. Also specify the container name and initial PDB.

ccs2

To switch in archivelog the container database located on the container cloud service, login on the container worker host and launch the following sqlplus command, then proceed as usual to move the database in archivelog

$ docker exec -it <imagename> bash -c "source /home/oracle/.bashrc; sqlplus /nolog"

Login with sys on the container database located on docker, to create a new user with sysoper and create pluggable database privilege:

sqlplus sys/<passwd>@<ccs_worker_host>:1531/ccs.localdomain AS SYSDBA

SQL> CREATE USER c##ccs IDENTIFIED BY <password> CONTAINER=ALL;
SQL> GRANT CREATE SESSION, DBA, SYSOPER, CREATE PLUGGABLE DATABASE TO c##ccs CONTAINER=ALL;

From the multitenant database located on DBcs, create a database link

$ sqlplus sys/<password>@<dbcs_host>:1521/dbcs.aXXX.oraclecloud.internal AS SYSDBA

SQL> CREATE PUBLIC DATABASE LINK ccs_link
     CONNECT TO c##ccs IDENTIFIED BY <passwd>
     USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip_adress_of_the_container_worker>)(PORT = 1531))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ccs.localdomain)))';

Still from the multitenant database located on DBcs, launch the command to create a copy of the database:

SQL> CREATE PLUGGABLE DATABASE ccsa_clone1 FROM ccsa@ccs_link;

To instead relocate the db:

SQL> CREATE PLUGGABLE DATABASE ccs_clone2 FROM ccsa@ccs_link RELOCATE;

Then open the new local PDB in read-write

SQL> ALTER PLUGGABLE DATABASE ccs_clone1 OPEN;
SQL> ALTER PLUGGABLE DATABASE ccs_clone2 OPEN;