This is continuation of my previous post (Remote PDB Cloning).
The process of remote clone for Non-CDB is basically the same as for PDB, there is just one additional step that needs to be performed.
Let’s confirm that our source database is Non-CDB.
SQL> select name, open_mode, cdb from v$database; NAME OPEN_MODE CDB --------- -------------------- --- NONCDB READ WRITE NO
We need to make sure that the database is 12c because we can only remotely clone 12c Non-CDBs.
SQL> select version from v$instance; VERSION ----------------- 126.96.36.199.0
Before we start with the cloning procedure we need to configure the network communication between the two servers. For that purpose we need to configure tnsnames.ora entry for the source database on the db-srv2 server.
NONCDB_SOURCE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db-srv1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = noncdb) ) )
Next, we need to create database link object which will be used in the CREATE PLUGGABLE DATABASE statement.
SQL> create database link noncdb_source connect to system identified by oracle using 'NONCDB_SOURCE'; Database link created.
The Non-CDB source database must be in read-only mode. We need to perform consistent shutdown and open the database in read-only mode.
SQL> startup mount ORACLE instance started. Total System Global Area 1140850688 bytes Fixed Size 2923584 bytes Variable Size 419431360 bytes Database Buffers 704643072 bytes Redo Buffers 13852672 bytes Database mounted. SQL> SQL> alter database open read only; Database altered.
We are now ready to start the cloning remotely via database link.
SQL> create pluggable database pdb2 from NON$CDB@noncdb_source; Pluggable database created.
After successful PDB creation additional step that needs to be performed for Non-CDB cloning. We need to execute @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql to modify some metadata and convert (map) the Non-CDB to PDB. The script needs to be run from the PDB logged as SYS user.
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql . . . SQL> SQL> -- leave the PDB in the same state it was when we started SQL> BEGIN 2 execute immediate '&open_sql &restricted_state'; 3 EXCEPTION 4 WHEN OTHERS THEN 5 BEGIN 6 IF (sqlcode <> -900) THEN 7 RAISE; 8 END IF; 9 END; 10 END; 11 / PL/SQL procedure successfully completed. SQL> SQL> WHENEVER SQLERROR CONTINUE; SQL> SQL> select con_id, name, open_mode from v$pdbs; CON_ID NAME OPEN_MODE ---------- ------------------------------ ---------- 4 PDB2 MOUNTED 1 row selected. SQL>
As final step open the new PDB and check the user data.
SQL> alter database open; Database altered. SQL> select count(*) from hr.employees; COUNT(*) ---------- 107 1 row selected.