Remote PDB cloning method is basically use to clone the PDB from source to target database and for that we use Database link to clone the PDB.
Pre-Checks For Remote PDB Cloning
➢ From 12cR2 we don’t need to put the Source PDB in read-only mode now we can clone the source PDB while it’s working in read-write mode, However for 12cR1 we’ve to put the PDB in read-only mode prior to start the cloning.
➢ Database link must be able to connect with source CDB , if it’s not there then create a database link.➢ User that we use to perform the PDB cloning can either be a common user OR a local user at PDB level
➢ The user that is suppose to perform cloning must have CREATE PLUGGABLE DATABASE privileges
➢ When cloning from a NON-CDB then source & target database must be using 12cR1 or higher
➢ The endian format , character set of both source & target CDB should be same
SOURCE CDB
➢ Create a common user in source CDB with CREATE PLUGGABLE DATABASE privilege , So that the same user can be use for remote cloning
Create user remote_user identified by welcome#1;
Grant create session to remote_user container=all;
Grant create pluggable database to remote_user container=all;
Note : If DB Version is 12cR1 then put the Source PDB in read-only mode
Alter pluggable database S_PDB close immediate instaces=all;
Alter pluggable database S_PDB open read only instances=all;
Start PDB Service Othewise It Won't Be Able To Clone The PDB
Srvctl start service -d <DB_UNIQUE_NAME> -s <PDB_SERVICE_NAME>
Srvctl status service -d <DB_UNIQUE_NAME > -s <PDB_SERVICE_NAME>
Create Database Link Between Source & Target Database For Remote Cloning
Create pluggable database link “test_link” connect to “remote_user” identified by Welcome#123 using <”PDB_SERVICE_NAME”>
Verify That DB Link Is Working Fine
Verify That DB Link Is Working Fine
SQL> Select sysdate from dual@test_link;
SYSDATE
-------------
23-APR-22
Shell Script To Run PDB Cloning In Background
Sqlplus -S “/ as sysdba” <<EOF
Set echo on
Set timing on
Create pluggable database T_PDB from test_link@<PDB_SERVICE_LINK> parallel 32;
Exit;
EOF
Note : The duration of the cloning totally depends upon the size of the source PDB and also the network bandwidth for data transfer between source & target server
SQL Query To Monitor The Progress Of Cloning Operation
Select a.inst_id,a.service_name,a.sid,a.serial#,a.sql_id,a.sql_text,a.logon_time,a.username,a.target ,sofar,totalwork,opname,time_remaining still,elapsed_seconds tillnow,round(c.SOFAR*100/c.TOTALWORK,0)||’%’ as “%DONE%” from gv$session a,gv$ql b,gv$session_longops c Where a.sid=c.sid AND a.sql_address=b.address AND a.sql_address=c.sql_address AND status=’ACTIVE’ AND time_reamining>0 order by target;
Select a.inst_id,a.service_name,a.sid,a.serial#,a.sql_id,a.sql_text,a.logon_time,a.username,a.target ,sofar,totalwork,opname,time_remaining still,elapsed_seconds tillnow,round(c.SOFAR*100/c.TOTALWORK,0)||’%’ as “%DONE%” from gv$session a,gv$ql b,gv$session_longops c Where a.sid=c.sid AND a.sql_address=b.address AND a.sql_address=c.sql_address AND status=’ACTIVE’ AND time_reamining>0 order by target;
Open Newly Created Target PDB In Read-Write Mode
Once the cloning will be done then by default the PDB started in mount mode so post remote cloning we’ve to start the target PDB in read-write mode.
Alter pluggable database T_PDB open instances=all;