Saturday 14 September 2024

Clone PDB from Remote PDB In Oracle 19C database:

Dear All,

In this post i am going to share how to preform PDB clone from Remote PDB .


Create clones of your PDB within the same DB (Container Database) in a 

DB System. This operation is known as local cloning. 

>>> OCI console level we can do this .

Create clones of your PDB to a different database (Container Database)

of a different DB system. This operation is known as remote cloning.

>>> OCI console level we cannot perform the remote clone .

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


Source DB : PRODDB ( remote ) ( ex: pdb , pdb1 ) 

TARGET DB : TESTDB  ( local ) ( ex: pdb )


Source DB system name : PRODDB01

Destination DB system name: TESTDB01

Source PDB name : PDB1  ( PRODDB ) 

Clone PDB name : CLONE_PDB2 ( TESTDB )

Destination db should be archive log mode enabled and local undo enabled should be true.


Step1 :  Source Database preparation ( PRODDB)


      >  create user in CDB$ROOT and grant the create session and create pluggable database role. 
     > create some test data on pdb1.
/u01/app/oracle/product/19.0.0/db_home/rdbms/admin/utlsampl.sql


CREATE USER c##clone IDENTIFIED BY Welcome_123 CONTAINER=ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##clone CONTAINER=ALL;





Step 2 :: Prepare the destination database ( TESTDB )
   
    > local_undo_enabled should be true 
   > archive log mode  should be enabled 
   > update the source db tnsnames.ora entry in this db. 
   > create the db_link on this server ( TESTDB)  using source db user ( PRODDB).
   > test the db link
   


select property_name,property_value from database_properties where property_name='LOCAL_UNDO_ENABLED';

archive log list;


> Update the remote DB ( PRODDB) tnsnames.ora on Local db tnsnames.ora ( TESTDB)






bounce the listener to update the changes ..


test the connection for Remote db from Local db ..



> create a db link on your destination db ( TESTDB ) to pointing to the source db ( PRODDB)


CREATE PUBLIC DATABASE LINK clone_pdb_dblink CONNECT TO c##clone identified by Welcome_123 using 'PRODDB';



note : Check if the connectivity through database link works fine on destination CDB. As we are not using the database link with the same name as the database it connects to, we need to additionally set the global_names parameter to false. Else, you’ll encounter ORA-02085 error.

alter session set global_names=false;

select * from dual@clone_pdb_dblink;



Step3 : Report PDB clone activity 

  > create remote pdb ( PRODDB) to local pdb( testdb) 
 > start the newly cloned pdb.
 > do the sanity check which we have created some dummy data check that was there or not.





Create a New PDB in the Local DB by cloning the Remote PDB.

Here we need to check with FILE_NAME_CONVERT parameter for 
file name conversions because we are not using OMF (Oracle Managed Files).


create pluggable database CLONE_PDB1 from pdb1@clone_pdb_dblink file_name_convert=('/u01/app/oracle/oradata/PRODDB/pdb1','/u01/app/oracle/oradata/TESTDB/clone_pdb1');


alter pluggable database CLONE_PDB1 open







remote pdb clone successfully completed.


Thanks,
Srini



Sunday 1 September 2024

Configuring and Enable Database Vault for CDB and PDB

 Dear All,

How to enable database vault in oracle 19C Multitenant database.

Configuring and Enable Database Vault for CDB?( On prime database servers ).

 

1.      How to Verify if Label Security and Database Vault are Configured and installed.

col DESCRIPTION format a40

set lines 500

SELECT * FROM SYS.DBA_DV_STATUS;  ( db vault status )

SELECT * FROM DBA_OLS_STATUS; ( db labled status )










We have to create 2 user one for db vault user and another for account manager user .. it will create new users for you.

2.      How to Create new Users for Database Vault

 

GRANT CREATE SESSION, SET CONTAINER TO c##dbv_owner_root IDENTIFIED BY WelcomE_321 CONTAINER = ALL;

GRANT CREATE SESSION, SET CONTAINER TO c##dbv_acctmgr_root IDENTIFIED BY WelcoMe_321 CONTAINER = ALL;




3.      How to Configure Database Vault in CDB$ROOT

BEGIN

CONFIGURE_DV (

dvowner_uname => 'c##dbv_owner_root',

dvacctmgr_uname => 'c##dbv_acctmgr_root',

force_local_dvowner => FALSE);

 END;

 /

 

 exec CONFIGURE_DV('c##dbv_owner_root','c##dbv_acctmgr_root');

 



4.      Compile the invalids if anything ( its advise to compile invalids)

              @?/rdbms/admin/utlrp.sql 





Note : we have to Connect as root admin to perform this activity.

5.      Connect to root as DBV Owner User( c##dbv_owner_root).

Dv_app_protection  not configured ?

DV_CONFIGURE_STATUS >> TRUE ( configured )

Dv_enable_status false ..

 


below command enable db vault .. connect to db vault owner user and execute it.

              EXEC DBMS_MACADM.ENABLE_DV;

Note : above commands shouldn’t execute from sys or other users ..

6.      After the above db vault enabled need to Bounce  the Database

                 Shutdown immediate Startup

                  Now Verify the status of  Label Security and Database Vault are Installed & Configured

                SELECT * FROM SYS.DBA_DV_STATUS;

                SELECT * FROM DBA_OLS_STATUS;





 How to Configure and enable the db vault inside  PDB ?

 

Pre-requisites : db vault should enabled on CDB level first ..

 

Ø  Connect to PDB database

                  Alter session set container=pdb1;

Ø  Verify the Label Security and Database Vault are Installed & Configured

                  SELECT * FROM SYS.DBA_DV_STATUS;

                   SELECT * FROM DBA_OLS_STATUS;

 






Ø  Create sample schema for HR / scott etc  Schema

   create schema from /u01/app/oracle/product/19.0.0/db_1/demo/schema/ human_resources

@hr_main.sql

 



select EMPLOYEE_ID,FIRST_NAME,LAST_NAME,SALARY from hr.employees ;

 



Ø  We no need to create new users , we can use the common users .Configure Database Vault

             BEGIN

                    CONFIGURE_DV (

                 dvowner_uname => 'c##dbv_owner_root',

                dvacctmgr_uname => 'c##dbv_acctmgr_root');

                END;

              /





Ø  Connect as DBV Owner User( c##dbv_owner_root)

Sqlplus  c##dbv_owner_root@pdb

Sqlplus c##dbv_owner_root@192.168.56.156:1521/pdb

 

               EXEC DBMS_MACADM.ENABLE_DV;

 


Ø  Bounce Pluggable database

Alter pluggable database pdb1 close; Alter pluggable database open;

 


Check the Label Security and Database Vault are Installed & Configured -



Thanks,

Srini