Cloning a Non CDB into CDB database through dblink

Cloning a Non CDB into CDB database through dblink

Step 1. On Non CDB database i.e TEST
Start the database in read only mode.


Shutdown immediate;
startup mount
alter database open read only;

Step 2. Open CDB database and make a link between CDB and NON CDB databases:
On CDB database:


create database link noncdbtocdb connect to system identified by password1 using 'TEST';

Step 3. Check the name of PDB database present in container database.
On CDB database:


SELECT pdb_name, status FROM dba_pdbs ORDER BY pdb_name;

SELECT name, open_mode FROM v$pdbs ORDER BY name;

Step 4. Start the process of creating PDB database from noncdb:
On CDB database:


create pluggable database PDB2 from NON$CDB@noncdbtocdb create_file_dest='D:\container\oradata\cdb1\pdb2';

or

CREATE PLUGGABLE DATABASE pdb2 FROM NON$CDB@noncdbtocdb FILE_NAME_CONVERT = ('D:\container\oradata\test', 'D:\container\oradata\cdb1\pdb2');

Error: If oracle is managed and use command you will got following error

ERROR at line 1:
ORA-01276: Cannot add file
D:\CONTAINER\ORADATA\CDB1\PDB2\DATAFILE\O1_MF_SYSTEM_CL3P1NXX_.DBF.
File has an Oracle Managed Files file name.

Error: if service name is not configured properly

SQL> CREATE PLUGGABLE DATABASE pdb2 FROM NON$CDB@noncdbtocdb1 FILE_NAME_CONVERT = ('D:\oracle12101\o
radata\IC12101\IC12101', 'D:\container\oradata\cdb1\pdb2');
CREATE PLUGGABLE DATABASE pdb2 FROM NON$CDB@noncdbtocdb1 FILE_NAME_CONVERT = ('D:\oracle12101\oradata\IC12101\IC12101', 'D:\container\oradata\cdb1\pdb2'')

ERROR at line 1:
ORA-17627: ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor
ORA-17629: Cannot connect to the remote database server

Solution: Configured service name in netmgr tool and reload the listener

Step 5: Completed
On CDB database:


create pluggable database PDB2 from NON$CDB@noncdbtocdb create_file_dest='D:\container\oradata\cdb1\pdb2';
Pluggable database created.

Step 6: Check the status of new database:
On CDB database:


select name,open_mode from v$pdbs;

NAME      OPEN_MODE
--------  ----------
PDB$SEED  READ ONLY
PDB1      MOUNTED
PDB2      MOUNTED


Step 7: Make entry of service name and tns entry in network (netmgr tool/netca) of oracle
 
Step 8: Run the following command to convert the noncdb to pdb completely
On CDB database:


@?\rdbms\admin\noncdb_to_pdb.sql;

Note: It will run for approx 10 to 20 min.
 
Step 9: Open the pluggable database

alter pluggable database pdb2 open;

Step 10: check the status

select name,open_mode from v$pdbs;

Step 11: Open the NON CDB database in read write mode
Non CDB database:

shutdown immediate;
startup

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s