meta données pour cette page
  •  

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
oracle:database:duplicate_pdb_to_another_cdb [11/03/2024 14:44] mdloracle:database:duplicate_pdb_to_another_cdb [02/12/2025 10:47] (Version actuelle) mdl
Ligne 111: Ligne 111:
 SHOW PDBS  SHOW PDBS
 </code> </code>
- ** Target Container (CHRMSP2) **    +**Target Container (CHRMSP2)**  
- +
-    ** Create database link pointing to source PDB   +
  
 +  * Create database link pointing to source PDB   
 +<code PLSQL>
        CREATE DATABASE LINK clone_link CONNECT TO remote_clone_user IDENTIFIED BY remote_clone_user USING 'P_HRDP_MIG'; <<< Use TNS Entry which was created in above step        CREATE DATABASE LINK clone_link CONNECT TO remote_clone_user IDENTIFIED BY remote_clone_user USING 'P_HRDP_MIG'; <<< Use TNS Entry which was created in above step
- +</code> 
-           ** Test Database link (check users list and confirm it is connecting to correct database) +  * Test Database link (check users list and confirm it is connecting to correct database) 
 +<code PLSQL>
        DESC user_tables@clone_link        DESC user_tables@clone_link
  
        Select username from dba_users@clone_link where(oracle_maintained='N');         Select username from dba_users@clone_link where(oracle_maintained='N');
- +</code> 
-        ** Create a shell script to clone PDB +  * Create a shell script to clone PDB 
 +<code BASH>
        cd /home/oracle         cd /home/oracle
- 
        vi clone_P_HRDP_pdb.sh        vi clone_P_HRDP_pdb.sh
- 
        #!/bin/sh          #!/bin/sh  
- 
        sqlplus /nolog << ! >> /dev/null        sqlplus /nolog << ! >> /dev/null
- 
        connect / as sysdba        connect / as sysdba
- 
        spool clone_P_HRDP_pdb_02Jan2024.log        spool clone_P_HRDP_pdb_02Jan2024.log
- 
        select username from dba_users@clone_link where(oracle_maintained='N' and username not like 'C##%');        select username from dba_users@clone_link where(oracle_maintained='N' and username not like 'C##%');
- 
        CREATE PLUGGABLE DATABASE P_HRDP FROM P_HRDP@clone_link;        CREATE PLUGGABLE DATABASE P_HRDP FROM P_HRDP@clone_link;
- 
        alter pluggable database P_HRDP open instances=all services=all;        alter pluggable database P_HRDP open instances=all services=all;
- 
        spool off;        spool off;
 +</code>
 +      
  
-       !  + * Before executing a script make sure environment is set for target container CHRMSP2 
- +<code BASH>
-    ** Before executing a script make sure environment is set for target container CHRMSP2 +
        $ export ORACLE_SID=CHRMSP2        $ export ORACLE_SID=CHRMSP2
- 
        $ export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_2        $ export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_2
- 
        $ nohup clone_P_HRDP_pdb.sh &         $ nohup clone_P_HRDP_pdb.sh &
 +</code>
        ** Logs        ** Logs
 +<code PLSQL>
           $ sqlplus / as sysdba           $ sqlplus / as sysdba
- 
        SQL*Plus: Release 19.0.0.0.0 - Production on Fri Sep 22 17:58:42 2023        SQL*Plus: Release 19.0.0.0.0 - Production on Fri Sep 22 17:58:42 2023
- 
        Version 19.17.0.0.0        Version 19.17.0.0.0
- 
         Copyright (c) 1982, 2022, Oracle.  All rights reserved.         Copyright (c) 1982, 2022, Oracle.  All rights reserved.
- 
        Connected to:        Connected to:
- 
        Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production        Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
- 
        Version 19.17.0.0.0         Version 19.17.0.0.0
- 
        SQL> show pdbs                  SQL> show pdbs          
  
            CON_ID CON_NAME                       OPEN MODE  RESTRICTED            CON_ID CON_NAME                       OPEN MODE  RESTRICTED
- 
            ---------- ------------------------------ ---------- ----------            ---------- ------------------------------ ---------- ----------
- 
         2 PDB$SEED                       READ ONLY  NO         2 PDB$SEED                       READ ONLY  NO
- 
         3 P_HRDP                         READ WRITE NO         3 P_HRDP                         READ WRITE NO
  
        SQL> select name from v$services;        SQL> select name from v$services;
- 
     NAME     NAME
- 
     ----------------------------------------------------------------     ----------------------------------------------------------------
- 
     CHRMSP2XDB     CHRMSP2XDB
- 
     CHRMSP2.db.test.com     CHRMSP2.db.test.com
- 
     SYS$BACKGROUND     SYS$BACKGROUND
- 
     P_HRDP_SVC     P_HRDP_SVC
- 
     SYS$USERS     SYS$USERS
- 
     P_HRDP      P_HRDP
- +</code> 
-        Note: Here, we can see that cloning the pdb will also copy all the services associate with source PDB+**Note**: Here, we can see that cloning the pdb will also copy all the services associate with source PDB
  
  4.Create a high availability service for the new PDB in CHRMSP2  4.Create a high availability service for the new PDB in CHRMSP2
 +<code BASH>
    srvctl add service -db CHRMSP2 -pdb P_HRDP -service P_HRDP_SVC -failovertype SELECT -failovermethod BASIC -preferred "CHRMSP21,CHRMSP22"    srvctl add service -db CHRMSP2 -pdb P_HRDP -service P_HRDP_SVC -failovertype SELECT -failovermethod BASIC -preferred "CHRMSP21,CHRMSP22"
  
Ligne 208: Ligne 179:
  
    srvctl status service -db CHRMSP2     srvctl status service -db CHRMSP2
 +</code>
 + 5. Rename global name of Source PDB(P_HRDP) to P_HRDP_OLD in source container CHRMSP1 (This step is required to avoid conflict of pdb with same name on same server)
  
- 5. Rename global name of Source PDB(P_HRDP) to P_HRDP_OLD in source container CHRMSP1 (This step  +  * Login to CHRMSP1 container
- +
-           is required to avoid conflict of pdb with same name on same server) +
- +
-    Login to CHRMSP1 container    +
 <code PLSQL> <code PLSQL>
 alter pluggable database P_HRDP close immediate instances=all; alter pluggable database P_HRDP close immediate instances=all;