Friday, July 20, 2018

Displaying Top consuming process in Linux

Displaying top CPU consuming processes:

ps aux | head -1; ps aux | sort -rnk 3 | head -10

Displaying top memory-consuming processes:

ps aux | head -1; ps aux | sort -rnk 4 | head -10

How to create directory in oracle database

SQL> Create directory PAP_HOME_DIR    as '/userdata/applications/cusap/data/gs_data';
SQL> grant read, write on directory PAP_HOME_DIR to APPS;

To query the privileges given to directory execute the following:

SQL> SET lines 80
SQL> COL grantee FORMAT a20
SQL> COL privilege FORMAT a10
SQL> SELECT directory_name, grantee, privilege  FROM user_tab_privs t, all_directories d 
 WHERE t.table_name(+)=d.directory_name ORDER BY 1,2,3;

How to remove and install Oracle XDB

XDB Removal

SQL> spool xdb_removal.log
SQL> set echo on;
SQL> connect / as sysdba
SQL> shutdown immediate;
SQL> startup
SQL> @?/rdbms/admin/catnoqm.sql
SQL> spool off;


XDB Install

SQL> spool xdb_install.log
SQL> set echo on;
SQL> connect / as sysdba
SQL> shutdown immediate;
SQL> startup;
SQL> @?/rdbms/admin/catqm.sql XDB XDB TEMP YES
SQL> @?/rdbms/admin/utlrp.sql
SQL> spool off

Oracle Applications Cloning - EBS R12.2

MOS Note: Cloning Oracle E-Business Suite Release 12.2 with Rapid Clone (Doc ID 1383621.1)

Pre-requisite Tasks
Run AutoConfig on the application tier
sh $ADMIN_SCRIPTS_HOME/adautocfg.sh

Run AutoConfig on the database tier
cd $ORACLE_HOME/appsutil/scripts
sh adautocfg.sh


Prepare the Source System database tier for cloning
1. Log on to the Source System as the oracle user.
2. Source the Database tier environment file.
3. Execute the following commands:

$ cd /appsutil/scripts/
$ perl adpreclone.pl dbTier

Prepare the Source System application tier for cloning
1. Log on to the primary node of the Source System as the applmgr user.
2. Source the environment file of the Run Edition File system.
You can use the following command to confirm that the environment variable FILE_EDITION points to the Run Edition File System:

$ echo $FILE_EDITION
It should return the value: run

3. Execute the following commands:
$ cd /admin/scripts
$ perl adpreclone.pl appsTier

Database Tier Clone 

Copy the database node file system
1. Copy the database (.dbf) files from the Source System to the Target System.
2. Copy the redo log files from the Source System to the Target System
3. Copy the Source System database ORACLE_HOME to the Target System

Configure the Target System database server
Log on to the Target System as the oracle user and enter the following commands:

$ cd /appsutil/clone/bin
$ perl adcfgclone.pl dbTier


Application Tier Clone
Copy the application tier file system from the Source to the Target "Run Edition File System"

Log on to Run Edition File System in the Source System application tier nodes as the applmgr user.
Copy the following application tier directories from the Source Node to the Target Run Edition File System application tier node:





cd $COMMON_TOP/clone/bin  or if it doesn’t exit go to the FS1.

mv FMW_Home FMW_Home_bak on both FS.
Verify /etc/oraInst.loc  points to correct folder

Configure the Target System application tier server nodes
Log on to the Run Edition File System in the Target System as the applmgr user and enter the following commands:
$ cd /clone/bin
$ perl adcfgclone.pl appsTier dualfs

Select No for starting up the services.

Finishing Tasks

update the profile values. replace source information with target details.

Change apps/sysadmin password
FNDCPASS apps/apps 0 Y system/manager SYSTEM APPLSYS newpsswd
FNDCPASS apps/apps 0 Y system/manager USER SYSADMIN newpsswd

Note: if you change apps password, then perform the below:

Start AdminServer using the $INST_TOP/admin/scripts/adadminsrvctl.sh script. Do not start any other application tier services.

Change the “apps” password in WLS Datasource as follows:
Log in to WLS Administration Console.

Click Lock & Edit in Change Center.
In the Domain Structure tree, expand Services, then select Data Sources
On the “Summary of JDBC Data Sources” page, select EBSDataSource
On the “Settings for EBSDataSource” page, select the Connection Pool tab
Enter the new password in the “Password” field.
Enter the new password in the “Confirm Password” field.
Click Save.
Click Activate Changes in Change Center.

Check whether you are able to connect to db using apps
sqlplus apps/ from application tier.

Before Starting all the services. Run Autoconfig.

cd $ADMIN_SCRIPTS_HOME
sh adautocfg.sh

Now start the services

Perform Sanity check

List oracle tables with stale stats


SQL> set pagesize 500 linesize 200
SQL> select owner, table_name, num_rows from dba_tab_statistics where stale_stats = 'YES' order by owner, table_name;

Tuning Concurrent Manager

Tuning the Concurrent Manager

• 1359612.1 Webcast 'E-Business Suite - RAC & Parallel Concurrent Processing
• 1367676.1 Webcast 'E-Business Suite - Concurrent Manager Performance
• 164085.1 Enhancing and Automating Oracle Applications Concurrent Processing
• 1057802.1 Best Practices for Performance for Concurrent Managers
• 1304305.1 E-Business Concurrent Processing Information Center

How to disable OCM scheduled job if you are not using this product


Error:
ORA-12012: error on auto execute of job "ORACLE_OCM"."MGMT_CONFIG_JOB_2_1"

SQL> exec dbms_scheduler.disable(‘ORACLE_OCM.MGMT_CONFIG_JOB’);

PL/SQL procedure successfully completed.

SQL> exec dbms_scheduler.disable(‘ORACLE_OCM.MGMT_STATS_CONFIG_JOB’)

PL/SQL procedure successfully completed.

Oracle CPU patches applied list using opatch


$ORACLE_HOME/OPatch/opatch lsinventory -bugs_fixed | grep MOLECULE

20506699   20449729  Tue Jul 07 12:26:29 GMT 2015   DB-11.2.0.4-MOLECULE-020-CPUAPR2015
20506706   20449729  Tue Jul 07 12:26:29 GMT 2015   DB-11.2.0.4-MOLECULE-021-CPUAPR2015



Identify EBS profile option settings that may be related to performance-degrading debug/trace activity

-- check_ebs_trace_profs.sql
--  Author: John Piwowar
-- Purpose: Identify E-Business Suite system profile option settings that may
--          be related to performance-degrading debug/trace activity
--   Notes: Prompts for a cutoff date for when profile options were set
--          May need additional tweaking for multi-language installations 
set pagesize 9999
set linesize 120
set verify off
 col "Profile Option" for a25
 col "Option Level" for a13
 col "set for" for a20
 col "Value" for a20
 col "Set On" for a11
 col "Blame" for a20
 PROMPT Enter date value in form DD-MON-YYYY for check_since
    select tl.user_profile_option_name "Profile Option"
         , decode( val.level_id
                 , 10001, 'Site'
                 , 10002, 'Application'
                 , 10003, 'Responsibility'
                 , 10004, 'User'
                 , 10005, 'Server'
                 , 10006, 'Organization'
                 , 10007, 'Server+Resp'
                 , 'No idea, boss') "Option Level"
         , decode( val.level_id
                 , 10001
                 , 'EVERYWHERE!'
                 , 10002
                 , (select application_name
                      from fnd_application_tl
                     where application_id = val.level_value)
                 , 10003
                 , (select responsibility_name
                      from fnd_responsibility_tl
                     where responsibility_id = val.level_value
                       and application_id = val.level_value_application_id)
                 , 10004
                 , (select user_name
                      from fnd_user
                     where user_id = val.level_value)
                 , 10005
                 , (select host || '.' || domain
                      from fnd_nodes
                     where node_id = val.level_value)
                 , 10006
                 , (select name
                      from hr_all_organization_units
                     where organization_id = val.level_value)
                 , 10007
                 , 'Look it up' --per specification El-Ay-Zed-why
                 , '''Tis a mystery') "Set for"
         , val.profile_option_value "Value"
         , val.last_update_date "Set on"
         , usr.user_name "Set By"
      from fnd_profile_options opt,
           fnd_profile_option_values val,
           fnd_profile_options_tl tl,
           fnd_user usr
     where opt.profile_option_id = val.profile_option_id
       and opt.profile_option_name = tl.profile_option_name
       and regexp_like( tl.user_profile_option_name
                      , '(trace|log|debug|audit|diag|sql)'
                      , 'i'
                      )
       and not(regexp_like( tl.user_profile_option_name
                          , '(catalog|file|login|utilities)'
                          , 'i'
                          )
              )
       and usr.user_id = val.last_updated_by
       and usr.user_name  not in ( 'AUTOINSTALL'
                                 , 'INITIAL SETUP'
                                 , 'ANONYMOUS')
       and val.last_update_date > '&check_since'
     order by val.last_update_date desc
 ;

oracle RAC diagnostics command

use the below commands to gather information on RAC for troubleshooting

From the grid user account do the following:

1)check the whole CRS installation as it is now:
cluvfy stage -post crsinst -n all -verbose

2) check the whole RAC db install as it is now
cluvfy stage -pre dbinst -n all -verbose

3) compare nodes
cluvfy comp peer -n all -verbose

4) check crs nodes integrity
cluvfy comp crs -n all -verbose

5) check if nodes have been removed previously registered in crs
cluvfy stage -post nodedel

6) validate installation deviations to best practices and mandatory reqs for crs/db
cluvfy comp healthcheck -deviations

Oracle CPU Patches applied list

SQL Query

SQL> col action_time format a30
SQL> select substr(action_time,1,30) action_time,substr(id,1,8) id,substr(action,1,10) action,
substr(version,1,8) version,substr(bundle_series,1,6) bundle,substr(comments,1,20) comments from registry$history;

or

you can also use

SQL> set serverout on
SQL> exec dbms_qopatch.get_sqlpatch_status;

Wednesday, July 18, 2018

How to change hostname in Linux

[root ~]# hostname
old-name

[root ~]# hostname new-name
[root@ ~]# hostname
new-name

[root ~]# vi /etc/sysconfig/network
[root ~]# vi /etc/hosts

[root ~]# pwd
/root
[root ~]# service network restart
Shutting down interface eth650_1.989:                      [  OK  ]
Shutting down interface eth1290_2.989:                     [  OK  ]

Using flashback on oracle RAC database

Here are steps to enable flashback in sit:

To Enable flashback

check make sure archive log is enabled.

alter system set db_recovery_file_dest_size=50G scope=both sid='*';
alter system set DB_RECOVERY_FILE_DEST='+RECOC1' scope=both sid='*';
alter system set db_flashback_retention_target=10080 scope=both sid='*';

srvctl stop database -d
srvctl start instance -d -i -o nomount;

alter system set cluster_database=false scope=spfile;

srvctl stop database -d
srvctl start instance -d -i -o mount;

alter database flashback on;
alter system set cluster_database=true scope=spfile;

srvctl stop database -d
srvctl start database -d


To create restore point

To create a restore point(db snapshot)
sqlplus "/as sysdba"
create restore point ;

To restore the flashback

srvctl stop database -d
srvctl start instance -d -i -o mount

flashback database to restore point 1_07APR15;
alter database open resetlogs;


SET PAUSE ON
SET PAUSE 'Press Return to Continue'
SET PAGESIZE 60
SET LINESIZE 300
SET VERIFY OFF

COLUMN scn FOR 999,999,999,999,999
COLUMN Incar FOR 99
COLUMN name FOR A25
COLUMN storage_size FOR 999,999,999,999
COLUMN guarantee_flashback_database FOR A3

SELECT
      database_incarnation# as Incar,
      scn,
      name,
      time,
      storage_size,
      guarantee_flashback_database
FROM
      v$restore_point
/

Oracle SQL queries for temporary tablespace


useful temporary tablespace commands:

Resize a Temporary Tablespace:
alter tablespace temp resize 1000M;
alter database tempfile 'tempfile_name' resize 3000M;
alter database tempfile 'tempfile_name' autoextend on maxsize 30G;


Shrink a Temporary Tablespace:
alter tablespace temp shrink space;
alter tablespace temp shrink tempfile 'tempfile_name' keep 2000M;

Rename a Temporary Tablespace:
alter tablespace temp rename to temp_x;

To view information about Temporary Tablespace:
select * from dba_temp_files;
select * from v$tempfile;
select * from v$temp_space_header;

Monitor the tempoary tablspace usage:
select * from v$sort_usage;
select *  from v$sort_segment;

Using ETCC in EBS R12.2

Refer Support Note 1594274.1

EBS Technology Codelevel Checker (ETCC) utility provides two scripts you can run to help ensure you have the necessary database and middle tier bugfixes installed on your Oracle E-Business Suite Release 12.2 system.

ETCC can be downloaded via Patch 17537119 from My Oracle Support.

Note: Always use the latest version of ETCC. New bugfixes will not be checked by older versions of the utility.

The two scripts that make up ETCC are:

checkDBpatch.sh (checkDBpatch.cmd on Microsoft Windows). This is the Database EBS Technology Codelevel Checker (DB-ETCC), which determines if all the needed bugfixes exist in the specified database ORACLE_HOME.

checkMTpatch.sh (checkMTpatch.cmd on Microsoft Windows). This is the Middle Tier EBS Technology Codelevel Checker (MT-ETCC), which determines if all the needed bugfixes exist in the middle tier file system.


Oracle EBS Database clone using RMAN

Steps

1. Copy database oracle home to target database server

2. Create Context file and relink Oracle Home using
perl adcfgclone.pl dbTechStack

3. set env
. $ORACLE_HOME/_.env

4.add source tns entry into target's tnsnames.ora
  cd $TNS_ADMIN
vi tnsnames.ora, add, test using sqlplus

5. make sure all the directories exist as in init.ora

6. Use DB_FILE_NAME_CONVERT, LOG_FILE_NAME_CONVERT, EVENT  in init.ora so RMAN can place the files in the correct location in target server.
        For example add these two entries in init.ora, and start the database in nomount
db_file_name_convert=('+DATAC1/SRC/DATAFILE/','/d01/oracle/TGT/data/', '+DATAC1/SRC/TEMPFILE','/d01/oracle/TGT/data/')
log_file_name_convert=('+DATAC1/SRC/ONLINELOG/','/d01/oracle/TGT/data/')

7. Make sure tnsnames.ora has the entries of Target database & Source Database

8. Startup the instance (to be cloned) in nomount
start database nomount

9. Connect to the source and target databases using this command
rman target sys/password@SRC auxiliary / nocatalog

10. Create the duplicate database using this command
run {
allocate auxiliary channel ch1 type disk;
allocate auxiliary channel ch2 type disk;
duplicate target database to TGT;}


11. Make sure temporary data file exists, If not add the datafile using below command
ALTER TABLESPACE TEMP ADD TEMPFILE '/d01/oracle/TGT/data/temp01.dbf' SIZE 2000M; 

12. Remove the parameters added to init.ora file. Change the database to no archive log mode

13. Run autoconfig on database tier
cd $ORACLE_HOME/appsutil/scripts/_
    adautocfg.sh

14. Clean the Node Names
EXEC FND_CONC_CLONE.SETUP_CLEAN;
      COMMIT;

15. shutdown/start by using addbctl.sh/addlnctl.sh

How to stop and start redo transport in oracle Data Guard using dgmgrl

STOP

dgmgrl sys/password@PRMY
edit database 'PRMY' set state='TRANSPORT-OFF';
show database verbose 'PRMY';


START

dgmgrl sys/password@PRMY
edit database 'PRMY' set state='TRANSPORT-ON';
show database verbose 'PRMY';

Query for sanity check in Primary and Standby Oracle database

Primary

SQL> select   thread#, max(sequence#) "Last Primary Seq Generated" from gv$archived_log val, v$database vdb where val.resetlogs_change# = vdb.resetlogs_change# group by thread# order by 1 ;

   THREAD# Last Primary Seq Generated
---------- --------------------------
         1                         41

Standby

SQL> select thread#, max(sequence#) "Last Standby Seq Received" from  v$archived_log val, v$database vdb where  val.resetlogs_change# = vdb.resetlogs_change# group by thread# order by 1;

   THREAD# Last Standby Seq Received
---------- -------------------------
         1                        41

Sending mail in Linux using mutt

echo "This is the message body" | mutt -a "body.txt" -s "test message" --(your email id)

How to check Oracle ASM Diskspace

From OS:

[oracle]$ . oraenv
ORACLE_SID = [+ASM] ? +ASM
The Oracle base remains unchanged with value /u01/app/oracle
[oracle]$ asmcmd lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     30708    28479                0           28479              0             N  DATA/


From Sqlplus:
[oracle]$ . oraenv
ORACLE_SID = [+ASM] ? +ASM
The Oracle base remains unchanged with value /u01/app/oracle

sqlplus / as sysdba
SQL> SELECT name, free_mb, total_mb, free_mb/total_mb*100 as percentage  FROM v$asm_diskgroup;

NAME                  FREE_MB   TOTAL_MB PERCENTAGE
------------------------------ ---------- ---------- ----------
DATA                    28479      30708 92.7413052

Oracle Notes for platform migration from EBS 11i to R12.2.5

1320300.1 - Oracle E-Business Suite Release Notes, Release 12.2
1349240.1 - Database Preparation Guidelines for an Oracle E-Business Suite Release 12.2 Upgrade (choose -> Path B)
1366265.1 - Using Transportable Tablespaces for EBS 11i Using Database 11gR2
1377213.1 - Oracle E-Business Suite - Upgrade & Platform Migration
1448102.2 - R12.1 and 12.2 Oracle E-Business Suite Preinstall Patches Report
1531121.1 - Using the Online Patching Readiness Report in Oracle E-Business Suite Release 12.2
1571256.1 - 11i: PRE-Upgrade GDF Diagnostic to Validate Data
1594274.1 - Oracle E-Business Suite Release 12.2: Consolidated List of Patches and Technology Bug Fixes
1617461.1 - Applying the Latest AD and TXK Release Update Packs to Oracle E-Business Suite Release 12.2
1906873.1 - Can Not Validate CTXSYS.DRIACC Package
1926201.1 - Interoperability Notes Oracle EBS 12.2 with Oracle Database 12c Release 1
1983050.1 - Oracle E-Business Suite Release 12.2.5 Readme
2008451.1 - How To Run The 12.2 EBS Technology Code Level Checker (ETCC)
233044.1  - R11i : About Oracle Applications DBA Minipack 11i.AD.I
252422.1  - R11i / R12 : Requesting Translation Synchronization Patches
396009.1  - Database Initialization Parameters for Oracle E-Business Suite Release 12
874903.1  - R12: What is a Generic Datafix Patch (GDF) and what GDFs are available for Payables?
881505.1  - Interoperability Notes Oracle EBS 11i with Oracle Database 11gR2 (11.2.0)
977512.1  - Updating the RDBMS DST version in 11g Release 2 (11.2.0.1 and up) using DBMS_DST
1493677.1 - Cloning An Existing Oracle Database 12c Release 1 (12.1.0.x) RDBMS Installation Using OUI
1596433.1 - R12.2: How To Create the Stage In Preparation For Installation

Oracle Data Pump Performance Tuning

Commands used

expdp username/password directory=dump_dir dumpfile=full.dmp logfile=full.log full=y parallel=16


impdp username/password directory=dump_dir dumpfile=full.dmp logfile=full.log parallel=16
During the test we noticed that expdp took 13 minutes and impdp took 45 minutes

using export in parallel to multiple files has significantly reduced the time


expdp username/password directory=dump_dir filesize=1G dumpfile=full%U.dmp logfile=fulllog parallel=16


impdp username/password directory=dump_dir dumpfile=full%U.dmp logfile=full.log parallel=16

We noticed expdp took 2 minutes now and impdp took same 45 minutes.

After increasing pga_aggregate_target to 6 GB, performance of import came down to 14 minutes.

How to move SQL Profile from one database to another in EBS

1. Creating a staging table to store the SQL Profiles

SQL> exec DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF (table_name=>'SQL_PROFILES_TT',schema_name=>'APPS');

2. Packing the SQL Profiles to the staging table

--Select SQL profiles names available in the source database.
SQL> SELECT name FROM dba_sql_profiles;
NAME
---------
SYS_SQLPROF_012f26136ae90001
SYS_SQLPROF_012f260d3e1a0000
SYS_SQLPROF_012ed90a425b0003
SYS_SQLPROF_012f2622a4620003

SQL>
EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name => 'SQL_PROFILES_TT',profile_name=>'SYS_SQLPROF_012f26136ae90001');
EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name => 'SQL_PROFILES_TT',profile_name=>'SYS_SQLPROF_012f260d3e1a0000');
EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name => 'SQL_PROFILES_TT',profile_name=>'SYS_SQLPROF_012ed90a425b0003');
EXEC DBMS_SQLTUNE.PACK_STGTAB_SQLPROF (staging_table_name => 'SQL_PROFILES_TT',profile_name=>'SYS_SQLPROF_012f2622a4620003');

3. Export table using “exp” tool from the source database

$ exp APPS/password file=SQL_PROFILES.dmp tables=SQL_PROFILES_TT


4. Import table using “imp” tool into the target database

$ imp SCOTT/password file=SQL_PROFILES.dmp full=y

5. Unpack the SQL Profiles in the target database

SQL> GRANT ADMINISTER SQL MANAGEMENT OBJECT to USER;
SQL> EXEC DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(REPLACE => TRUE,staging_table_name => 'SQL_PROFILES_TT');

SQL query to find file version in EBS

SQL> select * from ad_file_versions where file_id in
(select file_id from ad_files where upper(filename)=upper('appvndrb.pls')
) order by file_version_id desc;

Useful AIX Commands

Show CPU
# prtconf -s
# pmcycles -m
# lsdev -Cc processor
# bindprocessor -q

 Show RAM/Capacity
# prtconf -m
# bootinfo -r
# lsattr -El sys0 -a realmem
# lsattr -El mem0

# vmstat
# getconf REAL_MEMORY

 Show Hard disks/Capacity
# lsdev -Cc disk
# lspv
# bootinfo -s hdisk0

 Show IP Addresses
# ifconfig -a | grep inet
# lsattr -El en0 -a netaddr

Version
uname -a

How to enable database vault in 12.1 oracle RAC database

Verify Database Vault


Use the below query to check if DB Vault is already registered or not.

sqlplus / as sysdba

SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT

SQL> column parameter format a25
SQL> column value format a10
SQL> SELECT parameter,value FROM gv$OPTION WHERE PARAMETER in ('Oracle Database Vault','Oracle Label Security');

PARAMETER                 VALUE
------------------------- ----------
Oracle Label Security     FALSE
Oracle Database Vault     FALSE
Oracle Label Security     FALSE
Oracle Database Vault     FALSE

Note: If the returned value is FALSE, it means DB Vault is not registered and is in disable state.


Enable DB Vault at Container Level


Create DV Admin Users

First, you should create two users. One to administer DB vault and another to manage Oracle users at the database. These two users are required for the separation of duties.

sqlplus / as sysdba

SQL> create user c##dvowner identified by {Pw} CONTAINER=ALL;
User created.

SQL> create user c##dvacctmngr identified by {Pw} CONTAINER=ALL;
User created.

SQL> grant SET CONTAINER,CREATE SESSION to c##dvowner;
Grant succeeded.

SQL> grant SET CONTAINER,CREATE SESSION to c##dvacctmngr;
Grant succeeded.


Configure and Enable Database Vault


Now we can configure DB vault for registration. Then we will compile all the invalid objects.

SQL> BEGIN
DVSYS.CONFIGURE_DV (
dvowner_uname => 'c##dvowner',
dvacctmgr_uname => 'c##dvacctmngr');
END;
/  2    3    4    5    6

PL/SQL procedure successfully completed.

Compile invalid objects

SQL> @?/rdbms/admin/utlrp.sql

PL/SQL procedure successfully completed.

Enable DB Vault

SQL> connect c##dvowner
Enter password:
Connected.

SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> EXEC DBMS_MACADM.ENABLE_DV;

PL/SQL procedure successfully completed.

SQL> commit;
Commit complete.

Restart and Validate


Restart the Database. Otherwise, the value will be still FALSE when you query the table.

srvctl stop database -d
srvctl start database -d

DB Vault is ready now at container database. Use the below query for validation.

SQL> column parameter format a25
SQL> column value format a10
SQL> SELECT parameter,value FROM gv$OPTION WHERE PARAMETER in ('Oracle Database Vault','Oracle Label Security');
SQL> SQL>
PARAMETER                 VALUE
------------------------- ----------
Oracle Label Security     TRUE
Oracle Database Vault     TRUE
Oracle Label Security     TRUE
Oracle Database Vault     TRUE

Now proceed to install the DB Vault in pluggable database.


Enable DB Vault at Pluggable Level


Grant Permission for DV Admin User


Give grants to DV Admin users in pluggable database.

SQL> connect sys@PDB1 as sysdba
Enter password:
Connected.

SQL> show con_name
CON_NAME
------------------------------
PDB1

SQL> grant SET CONTAINER,CREATE SESSION to c##dvowner;
Grant succeeded.

SQL> grant SET CONTAINER,CREATE SESSION to c##dvacctmngr;
Grant succeeded.

Configure and Enable Database Vault


Now we can configure DB vault for registration and compile all the invalid objects.

SQL> BEGIN
2 DVSYS.CONFIGURE_DV (
3 dvowner_uname => ‘c##dvowner’,
4 dvacctmgr_uname => ‘c##dvacctmngr’);
5 END;
6 /
PL/SQL procedure successfully completed.

SQL> commit;
Commit complete.

Compile invalid objects

@?/rdbms/admin/utlrp.sql

PL/SQL procedure successfully completed.

Enable DB Vault for PDB

SQL> connect c##dvowner@PDB1
Enter password:
Connected.

SQL> EXEC DBMS_MACADM.ENABLE_DV;
PL/SQL procedure successfully completed.

SQL> commit;
Commit complete

Restart and Validate


Restart the pluggable Database.

SQL> connect sys@PDB1 as sysdba
Enter password:
Connected.

SQL> alter pluggable database PDB1 close immediate;

Pluggable database altered.

SQL> alter pluggable database PDB1 open;

Pluggable database altered.

Note: Bounce the PDB on Node2 as well.

DB Vault is ready now at pluggable database. Use the below query for validation.

SQL> SELECT parameter,value FROM gv$OPTION WHERE PARAMETER in ('Oracle Database Vault','Oracle Label Security');
SQL> SQL>
PARAMETER                 VALUE
------------------------- ----------
Oracle Label Security     TRUE
Oracle Database Vault     TRUE
Oracle Label Security     TRUE
Oracle Database Vault     TRUE

This completes DB Vault installation on pluggable database.


Disable DB Vault

Perform this step on both nodes

SQL> C##DVOWNER/pw

SQL> EXEC DBMS_MACADM.DISABLE_DV;
PL/SQL procedure successfully completed.

SQL> alter session set container=PDB1;
Session altered.

SQL> EXEC DBMS_MACADM.DISABLE_DV;
PL/SQL procedure successfully completed.
Restart the Database

srvctl stop database -d -o immediate
srvctl start database -d

How to use flashback in 12.2 PDB

Enable Flashback


SQL> Archive log list

SQL> SELECT flashback_on FROM v$database;

SQL> alter system set db_recovery_file_dest_size =200G scope=both sid='*';

SQL> show parameter db_recovery;

SQL> col name format a15
SQL> SELECT NAME, TO_CHAR(SPACE_LIMIT, '999,999,999,999') AS SPACE_LIMIT,
  TO_CHAR(SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE,'999,999,999,999') AS SPACE_AVAILABLE,
  ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1) AS PERCENT_FULL FROM V$RECOVERY_FILE_DEST;


SQL> SELECT flashback_on FROM v$database;

Create Restore Points

SQL> ALTER PLUGGABLE DATABASE PSBXPTL1 CLOSE;

SQL> CREATE CLEAN RESTORE POINT pdb_before_changes FOR PLUGGABLE DATABASE PSBXPTL1 GUARANTEE FLASHBACK DATABASE;

Flashback Pluggable Database

SQL> ALTER PLUGGABLE DATABASE PSBXPTL1 CLOSE;

SQL> FLASHBACK PLUGGABLE DATABASE PSBXPTL1 TO RESTORE POINT pdb_before_changes;
SQL> ALTER PLUGGABLE DATABASE PSBXPTL1 OPEN RESETLOGS;
SQL> select GUARANTEE_FLASHBACK_DATABASE, STORAGE_SIZE, TIME, RESTORE_POINT_TIME, PRESERVED, NAME, PDB_RESTORE_POINT from V$RESTORE_POINT;
SQL> DROP RESTORE POINT pdb_before_changes FOR PLUGGABLE DATABASE PSBXPTL1;