Clonare un PDB remoto da un CDB a un altro CDB utilizzando il collegamento db
Valido da oracle 12.
Collegarsi al cdb sorgente contenente il pdb da clonare
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
-------- ------------ -------------- --------------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
Il PDB1 deve essere in modalità READ WRITE
SQL> alter pluggable database pdb1 close;
Pluggable database altered.
SQL>
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> alter session set container=pdb1;
SQL> create user cloneuser identified by cloneuser;
Grant create session and create pluggable database privileges to cloneuser. SQL> grant create session, create pluggable database to cloneuser; Controlla i privileges granted to the cloneuser. SQL> select * from dba_sys_privs where grantee = 'CLONEUSER';
Aprire PDB1 in modalità read only.
SQL> alter database open read only;
Verifare PDB1 è in READ ONLY mode.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
-------- --------- ------------- --------------
3 PDB1 READ ONLY NO
Login to Target Container Database, CDB2
Create the database link in the target server to clone the pdb1 from cdb1 to cdb2.
Se non funziona invece di PDB1 usare la stringa di connessione:
Create the database link in the target server to clone the pdb1 from cdb1 to cdb2.
SQL> create database link clone_pdb connect to cloneuser identified by cloneuser using 'pdb1';
Se non funziona invece di PDB1 usare la stringa di connessione:
SQL> create database link clone_pdb connect to cloneuser identified by cloneuser using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = PRD1)))';
# tnsping pdb1
-- sqlplus connection status check $sqlplus sys/sys@pdb1 as sysdba SQL> sho con_name CON_NAME ------------------------------ PDB1 SQL> show parameter instance_name NAME TYPE VALUE -------------- -------- ------- instance_name string cdb1
Su PDB1 in CDB1 vedere il path dei datafileSQL> select name from v$datafile; /u01/app/oracle/oradata/CDB1/PDB1/sysaux01.dbf ......................
Su PDB2 dovrà essere così
/u01/app/oracle/oradata/CDB2/PDB2/sysaux01.dbf
...........................Quindi creare le direcory sul server che contiene il CBD2
mkdir /u01/app/oracle/oradata/CDB2/PDB2
Lanciare su CDB2
SQL> create pluggable database PDB2 from PDB1@clone_pdb file_name_convert=('/u01/app/oracle/oradata/CDB1/PDB1/','/u01/app/oracle/oradata/CBD2/PDB2/');Verifiche dopo la creazione PDB2 sarà nello stato MOUNTED.
SQL> sho pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ---------- ---------- ------------- 2 PDB$SEED READ ONLY NO 3 PDB2 MOUNTED NO
Verify the datafile creation with correct datafile path.SQL> select name from v$datafile; Aprire PDB2 database in CDB2.
SQL> alter session set container=pdb2;
SQL> alter database open; Database altered. SQL> alter session set container=cdb$root; SQL> show pdbs
Riferimento DOC 2882174.1