Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
oracle_multitenant_pdb_management [2021/11/13 17:28] – created andonovjoracle_multitenant_pdb_management [2021/11/14 08:31] (current) – [Unplug a PDB] andonovj
Line 1: Line 1:
 +===== Overview =====
 +Management of PDBs is fairly simple now. 
 +
 We can perform several actions with a PDB: We can perform several actions with a PDB:
  
Line 5: Line 8:
   * Close   * Close
   * Restore / Recover   * Restore / Recover
 +  * Clone
 +  * Clone in Hot Mode
  
 +===== Configuration Settings =====
 +PDBs can be heavily customizable and offer variety of features.
 +
 +==== Local / Shared Undo ====
 +One key aspect which we need to consider when creating a PDB is whether we want a shared undo or a local undo
 +Shared undo is the default and it was since 12.1. However with Local undo, we can perform clones of the database while transactions are going.
 +
 +{{:screen_shot_2021-11-13_at_6.32.43_pm.png?600|}}
 +
 +===== Operations ======
 ==== Open ==== ==== Open ====
-After we create a CDB, we need to open it, as follows:+After we create a CDB, we can to open it, as follows:
  
 <Code:bash|Open PDB> <Code:bash|Open PDB>
Line 22: Line 37:
 ==== Unplug a PDB ==== ==== Unplug a PDB ====
 In 12.1 we could unplug a PDB into .xml file and the migration of the PDB, would be the migration of that XML file AND the relevant database files.  In 12.1 we could unplug a PDB into .xml file and the migration of the PDB, would be the migration of that XML file AND the relevant database files. 
 +
 From 12.2 we can also unplug the PDB into a .pdb archive file, which contains information about the PDB AND the relevant database files. That will ease our migration. From 12.2 we can also unplug the PDB into a .pdb archive file, which contains information about the PDB AND the relevant database files. That will ease our migration.
  
Line 210: Line 226:
 Non-CDB in this case, refers to normal database, pre 12c Non-CDB in this case, refers to normal database, pre 12c
 So let's see how it will be done. As before we need to create a user and bring the whole database in read only mode: So let's see how it will be done. As before we need to create a user and bring the whole database in read only mode:
 +In fact there are multiple ways to be done:
 +
 +
 +{{:moving_noncdb_cdb.jpg?600|}}
 +
 +But let's do it cloning:
  
 ==On remote== ==On remote==
-<code:bash|Create user and enable read-only>+<Code:bash|Create user and enable read-only>
 export ORAENV_ASK=NO export ORAENV_ASK=NO
 export ORACLE_SID=db12c export ORACLE_SID=db12c
Line 290: Line 312:
  
 REMEMBER, as the cloned DB wasn't a PDB, we need to run the noncdb_to_pdb.sql. REMEMBER, as the cloned DB wasn't a PDB, we need to run the noncdb_to_pdb.sql.
 +
 +
 +==== Cross-Platform PDB Transport ====
 +We can perform also cross platform migration of PDB, however there are certain requirements:
 +
 +  * COMPATIBLE: Greater or Equal to 12.2
 +  * OPEN_MODE: MOUNTED
 +
 +
 +{{:cross_platform_move.jpg?600|}}
 +
 +This action is done either on the source server, when the backup is done, OR on the destination host, when the restore is done.
 +
 +=== Backup ====
 +We can transform the data either on the source or the destination server. Different situations call for different solutions.
 +
 +==On Source host==
 +
 +<Code:bash|Rman backup & Conversion>
 +RMAN> BACKUP TO PLATFORM 'Linux x86_64-bit'
 +      UNPLUG INTO /tmp/pdb2.xml' PLUGGABLE DATABASE pdb1
 +      FORMAT '/bkp_dir/transport_%U'
 +</Code>
 +
 +Bare in mind, as we backup to XML, that WILL NOT SAVE THE DATA, ONLY THE METADATA, you want the data, dump to .pdb file.
 +
 +==On destination host==
 +<Code:bash|Rman backup & Conversion>
 +RMAN> BACKUP FOR TRANSPORT UNPLUG INTO /tmp/pdb2.xml'
 +      PLUGGABLE DATABASE pdb1 FORMAT '/bkp_dir/transport_%U';
 +</Code>
 +
 +=== Restore ===
 +After we have moved the backup sets and the XML to the destination server. We can start an RMAN session and connect to the target CDB.
 +Also here, depending on where the conversation happened, we have two chocies.
 +
 +== If conversation was on source host ==
 +<Code:bash|RMAN Restore & Conversion>
 +RMAN> RESTORE USING '/tmp/pdb2.xml' FOREIGN PLUUGABLE DATABASE pdb1 to NEW 
 +      FROM BACKUPSET '.bkp_dir/transport_0gqoejqv_1_1';
 +</Code>
 +
 +== If conversation was on the destination host ==
 +<Code:bash|RMAN Restore & Conversation>
 +RMAN> ALTER SYSTEM SET DB_CREATE_FILE_DEST='/oradata/new_pdb';
 +RMAN> RESTORE FROM PLATFORM 'LINUX x86 64-bit' USING '/tmp/pdb2.xml'
 +      FOREIGN PLUGGABLE DATABASE pdb1 TO NEW
 +      FROM BACKUPSET '/bkp_dir/transport_0gqoejqv_1_1';
 +</Code>
 +
  
 ===== Hot clone ===== ===== Hot clone =====
Line 498: Line 570:
  
 SQL> SQL>
-</Code> 
- 
-===== Using DBCA ===== 
-We can use DBCA to create and delete CDB and PDBs as follows: 
- 
-<Code:bash|Examples> 
-# Local container (cdb1). 
-dbca -silent -createDatabase \ 
- -templateName General_Purpose.dbc \ 
- -gdbname cdb1 -sid cdb1 -responseFile NO_VALUE \ 
- -characterSet AL32UTF8 \ 
- -sysPassword SysPassword1 \ 
- -systemPassword SysPassword1 \ 
- -createAsContainerDatabase true \ 
- -numberOfPDBs 1 \ 
- -pdbName pdb1 \ 
- -pdbAdminPassword SysPassword1 \ 
- -databaseType MULTIPURPOSE \ 
- -memoryMgmtType auto_sga \ 
- -totalMemory 2048 \ 
- -storageType FS \ 
- -datafileDestination "/u02/oradata/" \ 
- -redoLogFileSize 50 \ 
- -initParams encrypt_new_tablespaces=DDL \ 
- -emConfiguration NONE \ 
- -ignorePreReqs 
- 
-# Remote container (cdb3) with PDB (pdb5). 
-dbca -silent -createDatabase \ 
- -templateName General_Purpose.dbc \ 
- -gdbname cdb3 -sid cdb3 -responseFile NO_VALUE \ 
- -characterSet AL32UTF8 \ 
- -sysPassword SysPassword1 \ 
- -systemPassword SysPassword1 \ 
- -createAsContainerDatabase true \ 
- -numberOfPDBs 1 \ 
- -pdbName pdb5 \ 
- -pdbAdminPassword SysPassword1 \ 
- -databaseType MULTIPURPOSE \ 
- -memoryMgmtType auto_sga \ 
- -totalMemory 2048 \ 
- -storageType FS \ 
- -datafileDestination "/u02/oradata/" \ 
- -redoLogFileSize 50 \ 
- -initParams encrypt_new_tablespaces=DDL \ 
- -emConfiguration NONE \ 
- -ignorePreReqs 
- 
-# Non-CDB instance (db12c). 
-dbca -silent -createDatabase \ 
- -templateName General_Purpose.dbc \ 
- -gdbname db12c -sid db12c -responseFile NO_VALUE \ 
- -characterSet AL32UTF8 \ 
- -sysPassword SysPassword1 \ 
- -systemPassword SysPassword1 \ 
- -createAsContainerDatabase false \ 
- -databaseType MULTIPURPOSE \ 
- -memoryMgmtType auto_sga \ 
- -totalMemory 2048 \ 
- -storageType FS \ 
- -datafileDestination "/u02/oradata/" \ 
- -redoLogFileSize 50 \ 
- -initParams encrypt_new_tablespaces=DDL \ 
- -emConfiguration NONE \ 
- -ignorePreReqs 
- 
-# Delete the instances. 
-#dbca -silent -deleteDatabase -sourceDB cdb1 -sysDBAUserName sys -sysDBAPassword SysPassword1 
-dbca -silent -deleteDatabase -sourceDB cdb3 -sysDBAUserName sys -sysDBAPassword SysPassword1 
-dbca -silent -deleteDatabase -sourceDB db12c -sysDBAUserName sys -sysDBAPassword SysPassword1 
- 
-#Configure OMF 
-export ORAENV_ASK=NO 
-export ORACLE_SID=cdb3 
-. oraenv 
-export ORAENV_ASK=YES 
- 
-sqlplus / as sysdba <<EOF 
- 
-ALTER SYSTEM SET db_create_file_dest = '/u02/oradata'; 
- 
-SHUTDOWN IMMEDIATE; 
-STARTUP MOUNT; 
-ALTER DATABASE ARCHIVELOG; 
-ALTER DATABASE OPEN; 
- 
-ALTER PLUGGABLE DATABASE pdb5 OPEN; 
-ALTER PLUGGABLE DATABASE pdb5 SAVE STATE; 
- 
-EXIT; 
-EOF 
- 
 </Code> </Code>
  
  
  • oracle_multitenant_pdb_management.1636824499.txt.gz
  • Last modified: 2021/11/13 17:28
  • by andonovj