
Duplicating an active Pluggable Database (PDB) in Oracle 19c is a crucial task for database administrators. It enables efficient PDB Duplication and Database Cloning, which are essential for various purposes such as testing, development, and disaster recovery. This guide will provide a comprehensive walkthrough on how to perform Duplicate PDB and Active PDB Duplication.
Understanding PDB Duplication
PDB Duplication involves creating a copy of an existing PDB within the same or a different Container Database (CDB). This process is essential for Database Cloning, which allows DBAs to create multiple instances of a database environment for different uses without affecting the original PDB.
Benefits of PDB Cloning
- Testing and Development: Cloning an active PDB provides a separate environment for testing and development without impacting the production environment.
- Disaster Recovery: Having duplicates of critical databases ensures that data can be quickly restored in case of failures.
- Load Balancing: Distributing workloads across multiple PDBs enhances performance and resource management.
Preparing for Duplicate PDB
Before performing Active PDB Duplication, ensure that the environment is properly configured. This includes verifying that the source PDB is open and operational, and that the target CDB has enough resources to accommodate the new PDB.
Prerequisites
- Sufficient Disk Space: Ensure that there is adequate disk space available in the target CDB.
- Network Configuration: If duplicating to a remote CDB, verify that network connections are properly configured.
- Privileges: Ensure that the user performing the duplication has the necessary privileges.
📢 You might also like: Oracle 19c Duplicate a Database (Category: Oracle Database Admin)
Steps to Duplicate an Active PDB
Step 1: Connect to RMAN
Start by connecting to RMAN (Recovery Manager) and target the source CDB.
RMAN> CONNECT TARGET SYS@source_cdb;
Step 2: Perform the Duplication
Execute the RMAN command to duplicate the PDB. This can be done within the same CDB or to a different CDB.
For duplicating within the same CDB:
RMAN> DUPLICATE PLUGGABLE DATABASE source_pdb TO target_pdb;
For duplicating to a different CDB:
RMAN> CONNECT TARGET SYS@target_cdb;
RMAN> DUPLICATE PLUGGABLE DATABASE source_pdb TO target_pdb FROM ACTIVE DATABASE;
Step 3: Open the New PDB
Once the duplication process is complete, open the new PDB in read/write mode.
ALTER PLUGGABLE DATABASE target_pdb OPEN;
Example: Duplicate PDB within the Same CDB
Let’s assume you have a source PDB named pdb1
that you want to duplicate to a new PDB named pdb1_copy
within the same CDB.
RMAN> CONNECT TARGET SYS@cdb1;
RMAN> DUPLICATE PLUGGABLE DATABASE pdb1 TO pdb1_copy;
Example: Duplicate PDB to a Different CDB
If you want to duplicate pdb1
from cdb1
to cdb2
, you would perform the following steps:
RMAN> CONNECT TARGET SYS@cdb2;
RMAN> DUPLICATE PLUGGABLE DATABASE pdb1 TO pdb1_copy FROM ACTIVE DATABASE;
Cloning an Active PDB
Cloning a PDB involves creating a copy of the PDB within the same CDB or another CDB. The main difference between cloning and duplicating is that cloning can be performed using SQL commands directly from within the database, providing more flexibility and control over the cloning process.
Steps to Clone an Active PDB
Step 1: Connect to the CDB
Start by connecting to the CDB where the source PDB resides.
sqlplus sys@cdb1 as sysdba
Step 2: Create the Clone PDB
Use the CREATE PLUGGABLE DATABASE
command to clone the PDB. This command can clone the PDB within the same CDB or to a different CDB.
For cloning within the same CDB:
CREATE PLUGGABLE DATABASE pdb1_clone FROM pdb1;
For cloning to a different CDB:
First, unplug the source PDB and create an XML file:
ALTER PLUGGABLE DATABASE pdb1 UNPLUG INTO '/path/to/pdb1.xml';
Then, plug it into the target CDB:
CREATE PLUGGABLE DATABASE pdb1_clone USING '/path/to/pdb1.xml' COPY;
Step 3: Open the Clone PDB
Open the cloned PDB in read/write mode.
ALTER PLUGGABLE DATABASE pdb1_clone OPEN;
Example: Clone PDB within the Same CDB
To PDB cloning of pdb1
to a new PDB named pdb1_clone
within the same CDB, use the following command:
CREATE PLUGGABLE DATABASE pdb1_clone FROM pdb1;
Example: Clone PDB to a Different CDB
To clone pdb1
from cdb1
to cdb2
, first unplug the PDB and create an XML file, then plug it into the target CDB:
-- Unplugging from cdb1
ALTER PLUGGABLE DATABASE pdb1 CLOSE;
ALTER PLUGGABLE DATABASE pdb1 UNPLUG INTO '/path/to/pdb1.xml';
DROP PLUGGABLE DATABASE pdb1 KEEP DATAFILES;
-- Plugging into cdb2
sqlplus sys@cdb2 as sysdba
CREATE PLUGGABLE DATABASE pdb1_clone USING '/path/to/pdb1.xml' COPY;
ALTER PLUGGABLE DATABASE pdb1_clone OPEN;
Duplicate PDB – Verifying the Duplication and Cloning
After completing the Active PDB Copy or Clone, it is essential to verify that the new PDB is operational and consistent. Use the following queries to check the status:
Check PDB Status
SELECT NAME, OPEN_MODE FROM V$PDBS WHERE NAME = 'TARGET_PDB';
Validate Data Integrity
Perform a quick validation to ensure that the data within the new PDB is consistent and intact.
DBMS_UTILITY.DB_VERIFY(start_block => 1, end_block => DBMS_UTILITY.MAX_BLOCK);
Managing Duplicated and Cloned PDBs
Effective management of duplicated and cloned PDBs involves regular monitoring, maintenance, and applying necessary updates. Oracle Enterprise Manager (OEM) can be used to monitor the performance and status of the PDBs.
Monitoring PDBs
Use Oracle Enterprise Manager to monitor the resource usage, performance metrics, and overall health of the PDBs.
Applying Updates and Patches
Keep the duplicated and cloned PDBs up to date with the latest patches and updates to maintain security and performance.
Conclusion
Duplicating and cloning an active PDB in Oracle 19c are powerful features that enhance the flexibility and manageability of database environments. By following the steps outlined in this guide, DBAs can efficiently perform Duplicate PDB and Active PDB Duplication, ensuring that their databases are robust, scalable, and prepared for various scenarios.
Start leveraging PDB Cloning in your Oracle environment today to enhance your database management capabilities and ensure your data remains protected and easily recoverable.
See more on Oracle’s website!
Be Oracle Database Certified Professional, this world is full of opportunities for qualified DBAs!