Hot Clone a Remote Pluggable Database
In 12.1 remote cloning was the prerequisite of placing the source PDB or non-CDB into read-only mode before initiating the cloning process.
This made this feature useless for cloning production systems, as that level of down-time is typically unacceptable.
Oracle Database 12c Release 2 (12.2) removes this prerequisite, which enables hot cloning of PDBs and non-CDBs for the first time.
Step 1 : Connect to the remote CDB and prepare the remote PDB for cloning.
[oracle@ram admin]$ export ORACLE_SID=dbwr [oracle@ram admin]$ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Sat Oct 13 01:09:04 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> sho con_name CON_NAME ---------------- CDB$ROOT
Step 2 : Create a user in the remote database for use with the database link. In this case, we will use a local user in the remote PDB
SQL> CREATE USER c##remote_user IDENTIFIED BY remote_user CONTAINER=ALL; User created. SQL> GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##remote_user CONTAINER=ALL; Grant succeeded.
Step 3 : Check the remote CDB is in local undo mode and archivelog mode.
SQL> conn / as sysdba Connected. SQL> col property_name for a30 SQL> col property_value for a30 SQL> SELECT property_name, property_value FROM database_properties WHERE property_name = 'LOCAL_UNDO_ENABLED'; PROPERTY_NAME PROPERTY_VALUE --------------------------- ----------------------- LOCAL_UNDO_ENABLED TRUE SQL> select log_mode from v$database; LOG_MODE ------------ ARCHIVELOG
Step 4 : Because the remote CDB is in local undo mode and archivelog mode, we don’t need to turn the remote database into read-only mode.
Step 5 : Switch to the local server and create a “tnsnames.ora” entry pointing to the remote database for use in the using clause of the database link.
PDB5 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ram.localdomain.com)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = pdb5.carrierzone.com) ) )
Step 6 : Connect to the local database to initiate the clone.
[oracle@ram ~]$ export ORACLE_SID=Petonas [oracle@ram ~]$ sqlplus / as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Sat Oct 13 00:44:25 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> sho con_name CON_NAME ------------ CDB$ROOT
Step 7 : Create a database link in the local database, pointing to the remote database.
SQL> drop database link pdb5_link; Database link dropped. SQL> CREATE DATABASE LINK pdb5_link CONNECT TO c##remote_user IDENTIFIED BY remote_user USING 'pdb5'; Database link created.
Step 8 : Create a new PDB in the local database by cloning the remote PDB. In this case we are using Oracle Managed Files (OMF), so we don’t need to bother with FILE_NAME_CONVERT parameter for file name conversions.
SQL> CREATE PLUGGABLE DATABASE pdb5new FROM pdb5@pdb5_link; Pluggable database created.
We can see the new PDB has been created, but it is in the MOUNTED state.
SQL> COLUMN name FORMAT A30 SQL> select name,open_mode from v$pdbs where name='PDB5NEW'; NAME OPEN_MODE ------------------------------ ---------- PDB5NEW MOUNTED SQL>
Step 9 : The PDB is opened in read-write mode to complete the process.
SQL> alter pluggable database pdb5new open; Pluggable database altered. SQL> SELECT name, open_mode FROM v$pdbs WHERE name = 'PDB5NEW'; NAME OPEN_MODE --------------------- ---------- PDB5NEW READ WRITE SQL>
Thus the remote clone Pluggable Database cloned successfully.
Catch Me On:- Hariprasath Rajaram Telegram:https://t.me/joinchat/I_f4DhGF_Zifr9YZvvMkRg LinkedIn:https://www.linkedin.com/in/hari-prasath-aa65bb19/ Facebook:https://www.facebook.com/HariPrasathdba FB Group:https://www.facebook.com/groups/894402327369506/ FB Page: https://www.facebook.com/dbahariprasath/? Twitter: https://twitter.com/hariprasathdba