Clone / Refresh of a PDB from remote database

Using the note from here -

https://oracle-base.com/articles/12c/multitenant-clone-remote-pdb-or-non-cdb-12cr1

"Oracle-Base" always excellent but please check this note on Metalink and the note below if using TDE.

Cloning PDB From PDB Fails With ORA-28357: Password Required To Open The Wallet (Doc ID 2415131.1)

Example database ORAPDB and example password used. 

++++++++++++++++++++++++++++++

[oracle@dev01tier2-dbs admin]$ sqlplus / as sysdba

 SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jul 30 12:25:22 2021

Version 19.9.0.0.0

Copyright (c) 1982, 2020, Oracle.  All rights reserved.

Connected to:

Oracle Database 19c EE High Perf Release 19.0.0.0.0 - Production

Version 19.9.0.0.0

 SQL> DROP DATABASE LINK clone_link;

DROP DATABASE LINK clone_link

                *

ERROR at line 1:

ORA-02024: database link not found

 SQL> CREATE DATABASE LINK clone_link CONNECT TO remote_clone_user IDENTIFIED BY remote_clone_user USING 'ORAPDB';

 Database link created.

 SQL> DESC user_tables@clone_link

 Name                                      Null?    Type

----------------------- -                  -------- ------------

 TABLE_NAME                                NOT NULL VARCHAR2(128)

 TABLESPACE_NAME                                    VARCHAR2(30)

 …etc

 HAS_SENSITIVE_COLUMN                               VARCHAR2(3)

 ADMIT_NULL                                         VARCHAR2(3)

 DATA_LINK_DML_ENABLED                              VARCHAR2(3)

 LOGICAL_REPLICATION                                VARCHAR2(8)

 SQL> show pdbs

  CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 RADND                          READ WRITE NO

         4 RADARPDB                       READ WRITE NO

         5 ORAPDB                         READ ONLY  NO

SQL> drop pluggable database ORAPDB including datafiles;

drop pluggable database ORAPDB including datafiles

*

ERROR at line 1:

ORA-65025: Pluggable database ORAPDB is not closed on all instances.

  // Will try anyway to create to show error

SQL> CREATE PLUGGABLE DATABASE ORAPDB FROM ORAPDB@clone_link;

CREATE PLUGGABLE DATABASE SFSD FROM ORAPDB@clone_link

*

ERROR at line 1:

ORA-65012: Pluggable database ORAPDB already exists.

SQL> alter pluggable database ORAPDB close IMMEDIATE;

Pluggable database altered.

SQL> drop pluggable database ORAPDB including datafiles;

Pluggable database dropped.

 // Now we can create but...

SQL> CREATE PLUGGABLE DATABASE ORAPDB FROM ORAPDB@clone_link;

CREATE PLUGGABLE DATABASE ORAPDB FROM ORAPDB@clone_link

*

ERROR at line 1:

ORA-46697: Keystore password required.

// See Doc ID 2415131.1

  SQL> CREATE PLUGGABLE DATABASE ORAPDB FROM ORAPDB@clone_link keystore IDENTIFIED BY "Password#2021#";

 Pluggable database created.

 SQL> l

  1* SELECT name, open_mode FROM v$pdbs

SQL> /

 NAME                                     OPEN_MODE

---------------------------------------- ----------

PDB$SEED                                 READ ONLY

RADND                                    READ WRITE

RADARPDB                                 READ WRITE

ORAPDB                                   MOUNTED

 

SQL> ALTER PLUGGABLE DATABASE ORAPDB OPEN;

 Pluggable database altered.

 SQL> show pdbs

     CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 RADND                          READ WRITE NO

         4 RADARPDB                       READ WRITE NO

         5 ORAPDB                         READ WRITE NO

 SQL> alter session set container = ORAPDB;

Session altered.

 //Remember to perform sanity check against pdb - check for invalid  objects etc..

 1* select owner, object_type, count(object_type) from dba_objects where status != 'VALID' group by owner, object_type order by 1,2

SQL> /

 OWNER      OBJECT_TYPE             COUNT(OBJECT_TYPE)

---------- ----------------------- ------------------

ABC        FUNCTION                                 4

ABC        PACKAGE BODY                             1

2 rows selected.

No comments:

Post a Comment