meta données pour cette page
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| oracle:database:duplicate_pdb_to_another_cdb [11/03/2024 14:41] – mdl | oracle:database:duplicate_pdb_to_another_cdb [02/12/2025 10:47] (Version actuelle) – mdl | ||
|---|---|---|---|
| Ligne 91: | Ligne 91: | ||
| => Directory Location: | => Directory Location: | ||
| <code BASH> | <code BASH> | ||
| - | nohup expdp < | + | nohup expdp < |
| </ | </ | ||
| Ligne 99: | Ligne 99: | ||
| srvctl disable service -d CHRMSP1 -s P_HRDP_SVC | srvctl disable service -d CHRMSP1 -s P_HRDP_SVC | ||
| </ | </ | ||
| - | 3) clone P_HRDP database from source container(CHRMSP1) to target container(CHRMSP2) | ||
| - | ** Source Container (CHRMSP1) ** | + | 3) clone P_HRDP database from source container(CHRMSP1) to target container(CHRMSP2) |
| - | + | ** Source Container (CHRMSP1) ** | |
| - | | + | <code PLSQL> |
| - | + | ALTER SESSION SET CONTAINER=P_HRDP; | |
| - | | + | CREATE USER remote_clone_user IDENTIFIED BY remote_clone_user; |
| - | + | GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO remote_clone_user; | |
| - | | + | Grant select any dictionary to remote_clone_user; |
| - | + | ALTER PLUGGABLE DATABASE P_HRDP CLOSE IMMEDIATE instances=all; | |
| - | | + | ALTER PLUGGABLE DATABASE P_HRDP OPEN READ ONLY instances=all; |
| - | + | SHOW PDBS | |
| - | | + | </ |
| - | + | **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 ' | CREATE DATABASE LINK clone_link CONNECT TO remote_clone_user IDENTIFIED BY remote_clone_user USING ' | ||
| - | + | </ | |
| - | ** 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=' | Select username from dba_users@clone_link where(oracle_maintained=' | ||
| - | + | </ | |
| - | | + | * Create a shell script to clone PDB |
| + | <code BASH> | ||
| cd / | cd / | ||
| - | |||
| vi clone_P_HRDP_pdb.sh | vi clone_P_HRDP_pdb.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=' | select username from dba_users@clone_link where(oracle_maintained=' | ||
| - | |||
| 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; | ||
| + | </ | ||
| + | |||
| - | ! | + | * 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=/ | $ export ORACLE_HOME=/ | ||
| - | |||
| $ nohup clone_P_HRDP_pdb.sh & | $ nohup clone_P_HRDP_pdb.sh & | ||
| + | </ | ||
| ** Logs | ** Logs | ||
| + | <code PLSQL> | ||
| | | ||
| - | |||
| 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 | ||
| - | |||
| | | ||
| - | |||
| 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 | CON_ID CON_NAME | ||
| - | |||
| ---------- ------------------------------ ---------- ---------- | ---------- ------------------------------ ---------- ---------- | ||
| - | |||
| 2 PDB$SEED | 2 PDB$SEED | ||
| - | |||
| 3 P_HRDP | 3 P_HRDP | ||
| SQL> select name from v$services; | SQL> select name from v$services; | ||
| - | |||
| NAME | NAME | ||
| - | |||
| | | ||
| - | |||
| | | ||
| - | |||
| | | ||
| - | |||
| | | ||
| - | |||
| | | ||
| - | |||
| | | ||
| - | |||
| | | ||
| - | + | </ | |
| - | 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 " | srvctl add service -db CHRMSP2 -pdb P_HRDP -service P_HRDP_SVC -failovertype SELECT -failovermethod BASIC -preferred " | ||
| Ligne 214: | Ligne 179: | ||
| srvctl status service -db CHRMSP2 | srvctl status service -db CHRMSP2 | ||
| + | </ | ||
| + | 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; | ||