Cloning a Non CDB into CDB database through dblink Oracle 12c

Cloning a Non CDB into CDB database through dblink

Creating a PDB database from NON CDB database with help of Cloning through the DBLINK. It will take time if CDB database is large in size but easily done.

Following are the steps involved in cloning process:

1. Login on Non CDB database i.e TEST
Start the database in read only mode.

Shutdown immediate;
startup mount
alter database open read only;

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

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

3. Check the name list of PDB database already 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;

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.
Solution
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.

5. Completed the creating of PDB database.
On CDB database:

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

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


7. Make entry of service name and TNS entry in network (netmgr tool/netca) of oracle.

8. Run the following command to convert the NON-CDB to PDB completely.
On CDB database:

@?\rdbms\admin\noncdb_to_pdb.sql;

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

alter pluggable database pdb2 open;

10. Check the status of pluggable database.

select name,open_mode from v$pdbs;

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

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