[OCI] Clone PDB
![[OCI] Clone PDB](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F4c20418f-c149-484c-a2b7-c30b4cfec47b.png&w=3840&q=75)
Ingeniero informático, Oracle ACE, DBA y Arquitecto OCI, con más de 15 años de experiencia en plataformas Oracle. Certificado en OCI Certified Architect Professional y OCI Migration and Integration Certified Professional.
If you prefer to read in Spanish Spanish version.
Today, let's talk about the steps to clone a PDB using RMAN Active Duplicate or DDL commands betweent differents CDB$Root.
DDL
Let's use a script in order to do it.
This script should run under oracle user on the target machine.
Here the scripts:
https://github.com/dbaenlasombra/OCI/blob/main/remote_clonning.sh
what do the script do?
Define a common user in the source with the necessary grants. The name is absolutly ramdom, not static, generated in unix using "tr -dc 'A-Za-z' </dev/urandom | head -c 5 | tr '[:lower:]' '[:upper:]'" . Regarding the password, it use the same procedure, following Oracle's minimum security requirements.
Define a DB Link in the target. The name is random like the previous steps.
Define PDB in the target.
After creating our PDB, the script will drop the common user and DB Link.
Regarding the names are generated ramdon in order to avoid blocks with another task into the machine.
As the previous steps before running the script, we need to do as follows:
Let's set up an rsa key for the oracle user on the target machine with name id_rsa to allow communication between machines.
Let's upgrade the tnsnames in order to include the local naming "SOURCE" on the target machine.
Let's set the one_step_plugin_for_pdb_with_tde parameter to true on the tharget machine.
Lastly, the parameters that our script are waiting, it's as follows:
IP address of the source machine. The reason is because the scripts connect to the source machine below oracle user in order to create common user and the necessary grants.
Name of the PDB.
Password of the TDE.
Let's run the sh in nohup mode:
[oracle@~]$
nohup ./remote_clonning.sh \(1 \)2 $3 > /tmp/remote_clonning.log 2>&1 &
Output of the sh:
In case of an error, we can see it in the output:
RMAN
In this laboratory, we also have a small script in order to do this.
Here the scripts:
https://github.com/dbaenlasombra/OCI/blob/main/rman_clone_pdb.sh
As the previous steps before running the script, we need to do as follows:
Let's upgrade the tnsnames in both machine to include local naming.
Let's export the wallet on the source machine in order to import it on the target machine.
Let's set the remote_recovery_file_dest parameter on the target machine:
SQL> alter system set remote_recovery_file_dest = '+RECO' scope = both sid = '*';
Let's run the sh in nohup mode:
[oracle@ ~]\( nohup ./rman_clone_pdb.sh "user\)/\(pass@\)local_name" "user\(/\)pass@\(local_name" \)pdb $db > /tmp/rman_clone_pdb.log 2>&1 &
Output of the sh:
Looking forward to seeing you in the next article :)
![[OCI] Check Jobs DBCli](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F4007e787-d6ad-47d9-b238-d69a285383ab.png&w=3840&q=75)
![[26ai] JOIN_TO_ME](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F49867547-f920-47a6-b11f-f5db511bcc73.png&w=3840&q=75)
![[26ai] Cleanup of Obsolete PL/SQL Objects](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F64ada612-0048-411c-b9df-61b8825af6e7.png&w=3840&q=75)
![[26ai] Hybrid Read-Only Mode PDB](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F65605419d28f19cc44df7ef1%2F23e8f92e-f89b-4746-930e-98156e3a1ec4.png&w=3840&q=75)