Saturday, December 31, 2011

Standalone datagaurd from ASM to ASM in 11gr2..

1.Create database[IRIS] and ASM on primary

2.Install binary and create ASM instance in standby[IRISSTBDY]

3. The primary database must meet two conditions before a standby database can be created from it:

•it must be in force logging mode and

•it must be in archive log mode (also automatic archiving must be enabled and a local archiving destination must be defined



4. Enable Primary to receive redo

alter dataabse add standby logfile ‘+ASM_DATA/IRIS/stdby_redo01.log’ SIZE 200m;

alter dataabse add standby logfile ‘+ASM_DATA/IRIS/PRIMDB/stdby_redo02.log’ SIZE 200m;

alter dataabse add standby logfile ‘+ASM_DATA/IRIS/PRIMDB/stdby_redo03.log’ SIZE 200m;



5.Primary database initialization parameters




Primary Standby

IRIS IRISSTDBY


alter system set db_name=IRIS scope=spfile;

alter system set db_unique_name=IRIS scope=spfile;

alter system set log_archive_config=’dg_config=(IRIS,IRISSTDBY)’ scope=spfile;

alter system set log_archive_dest_1=’location=‘+ASM_DATA/IRIS’ valid_for=(all_logfiles,all_roles) db_unique_name=primdb’ scope=spfile;

alter system set log_archive_dest_2='service=IRISSTDBY async valid_for=(online_logfiles,primary_role) db_unique_name=IRISSTDBY' scope=spfile;

log_archive_dest_2='service=IRISSTDBY async valid_for=(online_logfiles,primary_role) db_unique_name=IRISSTDBY'

alter system set log_archive_dest_state_1=enable scope=spfile;

alter system set log_archive_dest_state_2=enable scope=spfile;

alter system set remote_login_passwordfile=exclusive scope=spfile;

alter system set log_archive_format=’IRIS_%t_%s_%r.arc’ scope=spfile;

alter system set fal_server=IRIS scope=spfile;

alter system set db_file_name_convert=’IRISSTDBY’,'IRIS’ scope=spfile;

alter system set log_file_name_convert=’+ASM_DATA/IRISSTDBY’,‘+ASM_DATA/IRIS’’ scope=spfile;

alter system set standby_file_management=auto scope=spfile;







Primary init.parameters:

IRIS.__db_cache_size=1493172224

IRIS.__java_pool_size=16777216

IRIS.__large_pool_size=16777216

IRIS.__oracle_base='/u01/oradata/oracle'#ORACLE_BASE set from environment

IRIS.__pga_aggregate_target=1375731712

IRIS.__sga_target=2063597568

IRIS.__shared_io_pool_size=0

IRIS.__shared_pool_size=503316480

IRIS.__streams_pool_size=0

*.audit_file_dest='/u01/oradata/oracle/admin/IRIS/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='+ASM_DATA/IRIS/control01.ctl','+ASM_DATA/IRIS/control02.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_file_name_convert='IRISSTDBY','IRIS'

*.db_name='IRIS'

*.db_recovery_file_dest='+ASM_DATA'

*.db_recovery_file_dest_size=4070572032

*.db_unique_name='IRIS'

*.diagnostic_dest='/u01/oradata/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=IRISXDB)'

*.fal_client='IRIS'

*.fal_server='IRISSTDBY'

*.log_archive_config='dg_config=(IRIS,IRISSTDBY)'

*.log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=IRIS'

*.log_archive_dest_2='service=IRISSTDBY async valid_for=(online_logfiles,primary_role) db_unique_name=IRISSTDBY'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.log_archive_format='IRIS_%t_%s_%r.arc'

*.log_file_name_convert='+ASM_DATA/IRISSTDBY','+ASM_DATA/IRIS'

*.memory_target=3435134976

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.standby_file_management='AUTO'

*.undo_tablespace='UNDOTBS1'

6. Create the password file for primary and standby database.

cd $ORACLE_HOME/dbs

orapwd file=orapwTESTSBY password=sree123 entries=10



7. Create pfile from spfile in pri and transfer the pfile to destination server

Check and change the high lighted parameters below:

parameters of standby



[oracle@guestvm10 dbs]$ cat initIRISSTDBY1.ora

db_cache_size=1543503872

java_pool_size=16777216

large_pool_size=16777216

#pga_aggregate_target=1375731712

#sga_target=2063597568

shared_pool_size=452984832

streams_pool_size=0

audit_file_dest='/u01/oradata/oracle/admin/IRISSTDBY/adump'

audit_trail='db'

compatible='11.2.0.0.0'

control_files='+ASM_DATA/IRISSTDBY/control01.ctl','+ASM_DATA/IRISSTDBY/control02.ctl'

DB_FILE_NAME_CONVERT='+ASM_DATA/IRIS','+ASM_DATA/IRISSTDBY'

LOG_FILE_NAME_CONVERT='+ASM_DATA/IRIS','+ASM_DATA/IRISSTDBY'

db_block_size=8192

db_domain=''

db_name='IRIS'

db_recovery_file_dest='+ASM_DATA'

db_recovery_file_dest_size=4070572032

db_unique_name='IRISSTDBY'

#diagnostic_dest='/u01/oradata/oracle'

memory_target=3435134976

open_cursors=300

processes=150

remote_login_passwordfile='EXCLUSIVE'

standby_file_management='AUTO'

undo_tablespace='UNDOTBS1'

dispatchers='(PROTOCOL=TCP) (SERVICE=IRISSTDBYXDB)'

fal_server=IRIS

fal_client=IRISSTDBY

log_archive_config='dg_config=(IRIS,IRISSTDBY)'

log_archive_dest_1='location=+ASM_DATA/IRISSTDBY'

#remote_archive_enable='true'

log_archive_dest_2='SERVICE=IRIS VALID_FOR=(ONLINE_LOGFILES, ALL_ROLES) DB_UNIQUE_NAME=IRIS'

log_archive_dest_state_2='DEFER'

log_archive_format='IRISSTDBY_%t_%s_%r.arc'

8.Listener will be started on standby also when asm instance is created.



listener in pri

[oracle@guestvm9 tmp]$ cat /u01/oradata/oracle/product/11.2.0/grid/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/oradata/oracle/product/11.2.0/grid/network/admin/listener.ora

# Generated by Oracle configuration tools.



LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1523))

(ADDRESS = (PROTOCOL = TCP)(HOST = ahc333.ah.nl)(PORT = 1523))

)

)



ADR_BASE_LISTENER = /u01/oradata/oracle



ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

listener in standby

[oracle@guestvm10 dbs]$ cat /u01/oradata/oracle/product/11.2.0/grid/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/oradata/oracle/product/11.2.0/grid/network/admin/listener.ora

# Generated by Oracle configuration tools.



SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME =IRISSTDBY)

(ORACLE_HOME = /u01/oradata/oracle/product/11.2.0/db1)

(SID_NAME = IRISSTDBY)

)

)



LISTENER =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ahc332.ah.nl)(PORT = 1523))

)



ADR_BASE_LISTENER = /u01/oradata/oracle



ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent



9.Add tns entries of primary and standby then configure the TNS entries in the tnsnames.ora file.

[oracle@guestvm9 tmp]$ cat /u01/oradata/oracle/product/11.2.0/db1/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/oradata/oracle/product/11.2.0/db1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.



IRIS =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ahc333.ah.nl)(PORT = 1523))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = IRIS)

)

)



IRISSTDBY =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ahc332.ah.nl)(PORT = 1523))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = IRISSTDBY)

)

)

tnsnames in standby

[oracle@guestvm10 dbs]$ cat /u01/oradata/oracle/product/11.2.0/db1/network/admin/tnsnames.ora

IRIS =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ahc333.ah.nl)(PORT = 1523))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = IRIS)(UR=A)

)

)



IRISSTDBY =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = ahc332.ah.nl)(PORT = 1523))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = IRISSTDBY)(UR=A)

)

)

10.start standby db in nomount

[oracle@guestvm10 ~]$ ps -ef
grep smon

oracle 23733 1 0 02:47 ? 00:00:00 asm_smon_+ASM

oracle 23939 22555 0 03:11 pts/2 00:00:00 grep smon

[oracle@guestvm10 ~]$ sqlplus / as sysdba



SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 22 03:11:36 2011



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



Connected to an idle instance.



SQL> startup nomount pfile='/u01/oradata/oracle/product/11.2.0/db1/dbs/initIRISSTDBY1.ora';

ORACLE instance started.



Total System Global Area 3423965184 bytes

Fixed Size 2218152 bytes

Variable Size 1862272856 bytes

Database Buffers 1543503872 bytes

Redo Buffers 15970304 bytes

SQL> exit



11.[oracle@guestvm10 ~]$ rman



Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 22 03:49:32 2011



Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.



RMAN> connect target sys/oracle@IRIS



connected to target database: IRIS (DBID=435622768)



RMAN> connect auxiliary sys/oracle@IRISSTDBY



connected to auxiliary database: IRIS (not mounted)

RMAN> show all;



RMAN configuration parameters for database with db_unique_name IRIS are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+ASM_DATA/IRIS/snapcf_IRIS.f';

RMAN> duplicate target database for standby from active database;



Starting Duplicate Db at 08-NOV-11

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=10 device type=DISK



contents of Memory Script:

{

backup as copy reuse

targetfile '/u01/oradata/oracle/product/11.2.0/db1/dbs/orapwIRIS' auxiliary format

'/u01/oradata/oracle/product/11.2.0/db1/dbs/orapwIRISSTDBY' ;

}

executing Memory Script



Starting backup at 08-NOV-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=35 device type=DISK

Finished backup at 08-NOV-11



contents of Memory Script:

{

backup as copy current controlfile for standby auxiliary format '+ASM_DATA/IRISSTDBY/control01.ctl';

restore clone controlfile to '+ASM_DATA/IRISSTDBY/control02.ctl' from

'+ASM_DATA/IRISSTDBY/control01.ctl';

}

executing Memory Script



Starting backup at 08-NOV-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

copying standby control file

output file name=+ASM_DATA/IRIS/snapcf_IRIS.f tag=TAG201234222T035345 RECID=2 STAMP=220529056

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15

Finished backup at 08-NOV-11



Starting restore at 08-NOV-11

using channel ORA_AUX_DISK_1



channel ORA_AUX_DISK_1: copied control file copy

Finished restore at 08-NOV-11



contents of Memory Script:

{

sql clone 'alter database mount standby database';

}

executing Memory Script



sql statement: alter database mount standby database



contents of Memory Script:

{

set newname for tempfile 1 to

"+ASM_DATA/IRISSTDBY/temp01.dbf";

switch clone tempfile all;

set newname for datafile 1 to

"+ASM_DATA/IRISSTDBY/system01.dbf";

set newname for datafile 2 to

"+ASM_DATA/IRISSTDBY/sysaux01.dbf";

set newname for datafile 3 to

"+ASM_DATA/IRISSTDBY/undotbs01.dbf";

set newname for datafile 4 to

"+ASM_DATA/IRISSTDBY/users01.dbf";

backup as copy reuse

datafile 1 auxiliary format

"+ASM_DATA/IRISSTDBY/system01.dbf" datafile

2 auxiliary format

"+ASM_DATA/IRISSTDBY/sysaux01.dbf" datafile

3 auxiliary format

"+ASM_DATA/IRISSTDBY/undotbs01.dbf" datafile

4 auxiliary format

"+ASM_DATA/IRISSTDBY/users01.dbf" ;

sql 'alter system archive log current';

}

executing Memory Script



executing command: SET NEWNAME



renamed tempfile 1 to +ASM_DATA/IRISSTDBY/temp01.dbf in control file



executing command: SET NEWNAME



executing command: SET NEWNAME



executing command: SET NEWNAME



executing command: SET NEWNAME



Starting backup at 08-NOV-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

input datafile file number=00001 name=+ASM_DATA/IRIS/system01.dbf

output file name=+ASM_DATA/IRISSTDBY/system01.dbf tag=TAG40345222T035987

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:04:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00002 name=+ASM_DATA/IRIS/sysaux01.dbf

output file name=+ASM_DATA/IRISSTDBY/sysaux01.dbf tag=TAG40345222T035987

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:04:16

channel ORA_DISK_1: starting datafile copy

input datafile file number=00003 name=+ASM_DATA/IRIS/undotbs01.dbf

output file name=+ASM_DATA/IRISSTDBY/undotbs01.dbf tag=TAG40345222T035987

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00004 name=+ASM_DATA/IRIS/users01.dbf

output file name=+ASM_DATA/IRISSTDBY/users01.dbf tag=TAG40345222T035987

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07

Finished backup at 08-NOV-11



sql statement: alter system archive log current



contents of Memory Script:

{

switch clone datafile all;

}

executing Memory Script



datafile 1 switched to datafile copy

input datafile copy RECID=2 STAMP=770529715 file name=+ASM_DATA/IRISSTDBY/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=3 STAMP=770529717 file name=+ASM_DATA/IRISSTDBY/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=4 STAMP=770529721 file name=+ASM_DATA/IRISSTDBY/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=5 STAMP=770529726 file name=+ASM_DATA/IRISSTDBY/users01.dbf

Finished Duplicate Db at 08-NOV-11

SQL> alter database open;



Database altered.



SQL> alter system switch logfile;



alter system switch logfile

*

ERROR at line 1:

ORA-16000: database open for read-only access





SQL> SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;





Database altered.



SQL> SQL> recover managed standby database cancel;

Media recovery complete.

SQL> alter system switch logfile;

alter system switch logfile

*

ERROR at line 1:

ORA-16000: database open for read-only access



SQL> SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;



SEQUENCE# FIRST_TIM NEXT_TIME

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

37 08-NOV-11 08-NOV-11

38 08-NOV-11 08-NOV-11

39 08-NOV-11 08-NOV-11

40 08-NOV-11 08-NOV-11

41 08-NOV-11 23-DEC-11

42 09-NOV-11 24-DEC-11

43 10-NOV-11 24-DEC-11

44 10-NOV-11 25-DEC-11

45 11-NOV-11 25-DEC-11



9 rows selected.





The following steps show you how to shut down a standby database:

1. Find out if the standby database is performing managed recovery. If the MRP0 or MRP process exists, then the standby database is performing managed recovery.

SQL> SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;



2. Cancel managed recovery operations.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;



3. Shut down the standby database.

SQL> SHUTDOWN IMMEDIATE;

Monday, December 26, 2011

script provides detailed report of features used by each Database Options/Management Packs for Oracle Database

NOTE :- This Script work > 9i

SET LINESIZE 350;


SET PAGESIZE 1000;

SET FEEDBACK OFF;

SET COLSEP '
';



WHENEVER SQLERROR EXIT SQL.SQLCODE;



COL "Option/Management Pack" FORMAT A60;

COL "Used" FORMAT A5;

COL "Feature being Used" FORMAT A50;

COL "Currently Used" FORMAT A14;

COL "Last Usage Date" FORMAT A18;

COL "Last Sample Date" FORMAT A18;

COL "Host Name" FORMAT A30;





with features as(

select a OPTIONS, b NAME from

(

select 'Active Data Guard' a, 'Active Data Guard - Real-Time Query on Physical Standby' b from dual

union all

select 'Advanced Compression', 'HeapCompression' from dual

union all

select 'Advanced Compression', 'Backup BZIP2 Compression' from dual

union all

select 'Advanced Compression', 'Backup DEFAULT Compression' from dual

union all

select 'Advanced Compression', 'Backup HIGH Compression' from dual

union all

select 'Advanced Compression', 'Backup LOW Compression' from dual

union all

select 'Advanced Compression', 'Backup MEDIUM Compression' from dual

union all

select 'Advanced Compression', 'Backup ZLIB, Compression' from dual

union all

select 'Advanced Compression', 'SecureFile Compression (user)' from dual

union all

select 'Advanced Compression', 'SecureFile Deduplication (user)' from dual

union all

select 'Advanced Compression', 'Data Guard' from dual

union all

select 'Advanced Compression', 'Oracle Utility Datapump (Export)' from dual

union all

select 'Advanced Compression', 'Oracle Utility Datapump (Import)' from dual

union all

select 'Advanced Security', 'ASO native encryption and checksumming' from dual

union all

select 'Advanced Security', 'Transparent Data Encryption' from dual

union all

select 'Advanced Security', 'Encrypted Tablespaces' from dual

union all

select 'Advanced Security', 'Backup Encryption' from dual

union all

select 'Advanced Security', 'SecureFile Encryption (user)' from dual

union all

select 'Change Management Pack (GC)', 'Change Management Pack (GC)' from dual

union all

select 'Data Masking Pack', 'Data Masking Pack (GC)' from dual

union all

select 'Data Mining', 'Data Mining' from dual

union all

select 'Diagnostic Pack', 'Diagnostic Pack' from dual

union all

select 'Diagnostic Pack', 'ADDM' from dual

union all

select 'Diagnostic Pack', 'AWR Baseline' from dual

union all

select 'Diagnostic Pack', 'AWR Baseline Template' from dual

union all

select 'Diagnostic Pack', 'AWR Report' from dual

union all

select 'Diagnostic Pack', 'Baseline Adaptive Thresholds' from dual

union all

select 'Diagnostic Pack', 'Baseline Static Computations' from dual

union all

select 'Tuning Pack', 'Tuning Pack' from dual

union all

select 'Tuning Pack', 'Real-Time SQL Monitoring' from dual

union all

select 'Tuning Pack', 'SQL Tuning Advisor' from dual

union all

select 'Tuning Pack', 'SQL Access Advisor' from dual

union all

select 'Tuning Pack', 'SQL Profile' from dual

union all

select 'Tuning Pack', 'Automatic SQL Tuning Advisor' from dual

union all

select 'Database Vault', 'Oracle Database Vault' from dual

union all

select 'WebLogic Server Management Pack Enterprise Edition', 'EM AS Provisioning and Patch Automation (GC)' from dual

union all

select 'Configuration Management Pack for Oracle Database', 'EM Config Management Pack (GC)' from dual

union all

select 'Provisioning and Patch Automation Pack for Database', 'EM Database Provisioning and Patch Automation (GC)' from dual

union all

select 'Provisioning and Patch Automation Pack', 'EM Standalone Provisioning and Patch Automation Pack (GC)' from dual

union all

select 'Exadata', 'Exadata' from dual

union all

select 'Label Security', 'Label Security' from dual

union all

select 'OLAP', 'OLAP - Analytic Workspaces' from dual

union all

select 'Partitioning', 'Partitioning (user)' from dual

union all

select 'Real Application Clusters', 'Real Application Clusters (RAC)' from dual

union all

select 'Real Application Testing', 'Database Replay: Workload Capture' from dual

union all

select 'Real Application Testing', 'Database Replay: Workload Replay' from dual

union all

select 'Real Application Testing', 'SQL Performance Analyzer' from dual

union all

select 'Spatial' ,'Spatial (Not used because this does not differential usage of spatial over locator, which is free)' from dual

union all

select 'Total Recall', 'Flashback Data Archive' from dual

)

)

select

t.o "Option/Management Pack",

t.u "Used",

t.n "Feature being Used",

t.v "Version",

t.cu "Currently Used",

t.du "Detected Usage",

t.lud "Last Usage Date",

t.ts "Total Samples",

t.lsd "Last Sample Date",

d.DBID "DBID",

d.name "DB Name",

i.version "Curr DB Version",

i.host_name "Host Name",

to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') "ReportGen Time"

from (

select f.OPTIONS o,

'YES' u,

f_stat.version v,

case when f_stat.name in ('Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)') then 'Data Pump Compression'

when f_stat.name in ('Data Guard') then 'Data Guard Network Compression'

else f_stat.name

end n,

f_stat.CURRENTLY_USED cu,

(f_stat.DETECTED_USAGES) du,

to_char(f_stat.LAST_USAGE_DATE, 'DD-MON-YY HH24:MI:SS') lud,

(f_stat.TOTAL_SAMPLES) ts,

to_char(f_stat.LAST_SAMPLE_DATE, 'DD-MON-YY HH24:MI:SS') lsd

from features f,

sys.dba_feature_usage_statistics f_stat

where f.name = f_stat.name and

( (f_stat.currently_used = 'TRUE' and

f_stat.detected_usages > 0 and

(sysdate - f_stat.last_usage_date) < 366 and

f_stat.total_samples > 0

)

or

(f_stat.detected_usages > 0 and

(sysdate - f_stat.last_usage_date) < 366 and

f_stat.total_samples > 0)

) and

( f_stat.name not in('Data Guard', 'Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)')

or

(f_stat.name in('Data Guard', 'Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)') and

f_stat.feature_info is not null and trim(substr(to_char(feature_info), instr(to_char(feature_info), 'compression used: ',1,1) + 18, 2)) != '0')

)

) t,

v$instance i,

v$database d

order by t.o,t.n,t.v

;

exit;

Sunday, December 25, 2011

script provides detailed report of features used by each Database Options/Management Packs for Oracle Database

SET LINESIZE 350;

SET PAGESIZE 1000;
SET FEEDBACK OFF;
SET COLSEP '
';
 WHENEVER SQLERROR EXIT SQL.SQLCODE;


COL "Option/Management Pack" FORMAT A60;
COL "Used" FORMAT A5;
COL "Feature being Used" FORMAT A50;
COL "Currently Used" FORMAT A14;
COL "Last Usage Date" FORMAT A18;
COL "Last Sample Date" FORMAT A18;
COL "Host Name" FORMAT A30;
with features as(
select a OPTIONS, b NAME from
(
select 'Active Data Guard' a, 'Active Data Guard - Real-Time Query on Physical Standby' b from dual


union all


select 'Advanced Compression', 'HeapCompression' from dual


union all


select 'Advanced Compression', 'Backup BZIP2 Compression' from dual


union all


select 'Advanced Compression', 'Backup DEFAULT Compression' from dual


union all


select 'Advanced Compression', 'Backup HIGH Compression' from dual


union all


select 'Advanced Compression', 'Backup LOW Compression' from dual


union all


select 'Advanced Compression', 'Backup MEDIUM Compression' from dual


union all


select 'Advanced Compression', 'Backup ZLIB, Compression' from dual


union all


select 'Advanced Compression', 'SecureFile Compression (user)' from dual


union all


select 'Advanced Compression', 'SecureFile Deduplication (user)' from dual


union all


select 'Advanced Compression', 'Data Guard' from dual


union all


select 'Advanced Compression', 'Oracle Utility Datapump (Export)' from dual


union all


select 'Advanced Compression', 'Oracle Utility Datapump (Import)' from dual


union all


select 'Advanced Security', 'ASO native encryption and checksumming' from dual


union all


select 'Advanced Security', 'Transparent Data Encryption' from dual


union all


select 'Advanced Security', 'Encrypted Tablespaces' from dual


union all


select 'Advanced Security', 'Backup Encryption' from dual


union all


select 'Advanced Security', 'SecureFile Encryption (user)' from dual


union all


select 'Change Management Pack (GC)', 'Change Management Pack (GC)' from dual


union all


select 'Data Masking Pack', 'Data Masking Pack (GC)' from dual


union all


select 'Data Mining', 'Data Mining' from dual


union all


select 'Diagnostic Pack', 'Diagnostic Pack' from dual


union all


select 'Diagnostic Pack', 'ADDM' from dual


union all


select 'Diagnostic Pack', 'AWR Baseline' from dual


union all


select 'Diagnostic Pack', 'AWR Baseline Template' from dual


union all


select 'Diagnostic Pack', 'AWR Report' from dual


union all


select 'Diagnostic Pack', 'Baseline Adaptive Thresholds' from dual


union all


select 'Diagnostic Pack', 'Baseline Static Computations' from dual


union all


select 'Tuning Pack', 'Tuning Pack' from dual


union all


select 'Tuning Pack', 'Real-Time SQL Monitoring' from dual


union all


select 'Tuning Pack', 'SQL Tuning Advisor' from dual


union all


select 'Tuning Pack', 'SQL Access Advisor' from dual


union all


select 'Tuning Pack', 'SQL Profile' from dual


union all


select 'Tuning Pack', 'Automatic SQL Tuning Advisor' from dual


union all


select 'Database Vault', 'Oracle Database Vault' from dual


union all


select 'WebLogic Server Management Pack Enterprise Edition', 'EM AS Provisioning and Patch Automation (GC)' from dual


union all


select 'Configuration Management Pack for Oracle Database', 'EM Config Management Pack (GC)' from dual


union all


select 'Provisioning and Patch Automation Pack for Database', 'EM Database Provisioning and Patch Automation (GC)' from dual


union all


select 'Provisioning and Patch Automation Pack', 'EM Standalone Provisioning and Patch Automation Pack (GC)' from dual


union all


select 'Exadata', 'Exadata' from dual


union all


select 'Label Security', 'Label Security' from dual


union all


select 'OLAP', 'OLAP - Analytic Workspaces' from dual


union all


select 'Partitioning', 'Partitioning (user)' from dual


union all


select 'Real Application Clusters', 'Real Application Clusters (RAC)' from dual


union all


select 'Real Application Testing', 'Database Replay: Workload Capture' from dual


union all


select 'Real Application Testing', 'Database Replay: Workload Replay' from dual


union all


select 'Real Application Testing', 'SQL Performance Analyzer' from dual


union all


select 'Spatial' ,'Spatial (Not used because this does not differential usage of spatial over locator, which is free)' from dual


union all


select 'Total Recall', 'Flashback Data Archive' from dual


)


)


select


t.o "Option/Management Pack",


t.u "Used",


t.n "Feature being Used",


t.v "Version",


t.cu "Currently Used",


t.du "Detected Usage",


t.lud "Last Usage Date",


t.ts "Total Samples",


t.lsd "Last Sample Date",


d.DBID "DBID",


d.name "DB Name",


i.version "Curr DB Version",


i.host_name "Host Name",


to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') "ReportGen Time"


from (


select f.OPTIONS o,


'YES' u,


f_stat.version v,


case when f_stat.name in ('Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)') then 'Data Pump Compression'


when f_stat.name in ('Data Guard') then 'Data Guard Network Compression'


else f_stat.name


end n,


f_stat.CURRENTLY_USED cu,


(f_stat.DETECTED_USAGES) du,


to_char(f_stat.LAST_USAGE_DATE, 'DD-MON-YY HH24:MI:SS') lud,


(f_stat.TOTAL_SAMPLES) ts,


to_char(f_stat.LAST_SAMPLE_DATE, 'DD-MON-YY HH24:MI:SS') lsd


from features f,


sys.dba_feature_usage_statistics f_stat


where f.name = f_stat.name and


( (f_stat.currently_used = 'TRUE' and


f_stat.detected_usages > 0 and


(sysdate - f_stat.last_usage_date) < 366 and


f_stat.total_samples > 0


)


or


(f_stat.detected_usages > 0 and


(sysdate - f_stat.last_usage_date) < 366 and


f_stat.total_samples > 0)


) and


( f_stat.name not in('Data Guard', 'Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)')


or


(f_stat.name in('Data Guard', 'Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)') and
f_stat.feature_info is not null and trim(substr(to_char(feature_info), instr(to_char(feature_info), 'compression used: ',1,1) + 18, 2)) != '0')
)
) t,
v$instance i,
v$database d
order by t.o,t.n,t.v
;

exit;

Friday, December 23, 2011

Script to Determining Installed Features/Options, Usage and Usage Statistics

COL "Host Name" FORMAT A30;


COL "Option/Management Pack" FORMAT A60;


COL "Used" FORMAT A5;


with features as(


select a OPTIONS, b NAME from


(


select 'Active Data Guard' a, 'Active Data Guard - Real-Time Query on Physical Standby' b from dual


union all


select 'Advanced Compression', 'HeapCompression' from dual


union all


select 'Advanced Compression', 'Backup BZIP2 Compression' from dual


union all


select 'Advanced Compression', 'Backup DEFAULT Compression' from dual


union all


select 'Advanced Compression', 'Backup HIGH Compression' from dual


union all


select 'Advanced Compression', 'Backup LOW Compression' from dual


union all


select 'Advanced Compression', 'Backup MEDIUM Compression' from dual


union all


select 'Advanced Compression', 'Backup ZLIB, Compression' from dual


union all


select 'Advanced Compression', 'SecureFile Compression (user)' from dual


union all


select 'Advanced Compression', 'SecureFile Deduplication (user)' from dual


union all


select 'Advanced Compression', 'Data Guard' from dual


union all


select 'Advanced Compression', 'Oracle Utility Datapump (Export)' from dual


union all


select 'Advanced Compression', 'Oracle Utility Datapump (Import)' from dual


union all


select 'Advanced Security', 'ASO native encryption and checksumming' from dual


union all


select 'Advanced Security', 'Transparent Data Encryption' from dual


union all


select 'Advanced Security', 'Encrypted Tablespaces' from dual


union all


select 'Advanced Security', 'Backup Encryption' from dual


union all


select 'Advanced Security', 'SecureFile Encryption (user)' from dual


union all


select 'Change Management Pack', 'Change Management Pack (GC)' from dual


union all


select 'Data Masking Pack', 'Data Masking Pack (GC)' from dual


union all


select 'Data Mining', 'Data Mining' from dual


union all


select 'Diagnostic Pack', 'Diagnostic Pack' from dual


union all


select 'Diagnostic Pack', 'ADDM' from dual


union all


select 'Diagnostic Pack', 'AWR Baseline' from dual


union all


select 'Diagnostic Pack', 'AWR Baseline Template' from dual


union all


select 'Diagnostic Pack', 'AWR Report' from dual


union all


select 'Diagnostic Pack', 'Baseline Adaptive Thresholds' from dual


union all


select 'Diagnostic Pack', 'Baseline Static Computations' from dual


union all


select 'Tuning Pack', 'Tuning Pack' from dual


union all


select 'Tuning Pack', 'Real-Time SQL Monitoring' from dual


union all


select 'Tuning Pack', 'SQL Tuning Advisor' from dual


union all


select 'Tuning Pack', 'SQL Access Advisor' from dual


union all


select 'Tuning Pack', 'SQL Profile' from dual


union all


select 'Tuning Pack', 'Automatic SQL Tuning Advisor' from dual


union all


select 'Database Vault', 'Oracle Database Vault' from dual


union all


select 'WebLogic Server Management Pack Enterprise Edition', 'EM AS Provisioning and Patch Automation (GC)' from dual


union all


select 'Configuration Management Pack for Oracle Database', 'EM Config Management Pack (GC)' from dual


union all


select 'Provisioning and Patch Automation Pack for Database', 'EM Database Provisioning and Patch Automation (GC)' from dual


union all


select 'Provisioning and Patch Automation Pack', 'EM Standalone Provisioning and Patch Automation Pack (GC)' from dual


union all


select 'Exadata', 'Exadata' from dual


union all


select 'Label Security', 'Label Security' from dual


union all


select 'OLAP', 'OLAP - Analytic Workspaces' from dual


union all


select 'Partitioning', 'Partitioning (user)' from dual


union all


select 'Real Application Clusters', 'Real Application Clusters (RAC)' from dual


union all


select 'Real Application Testing', 'Database Replay: Workload Capture' from dual


union all


select 'Real Application Testing', 'Database Replay: Workload Replay' from dual


union all


select 'Real Application Testing', 'SQL Performance Analyzer' from dual


union all


select 'Spatial' ,'Spatial (Not used because this does not differential usage of spatial over locator, which is free)' from dual


union all


select 'Total Recall', 'Flashback Data Archive' from dual


)


)


select t.o "Option/Management Pack",


t.u "Used",


d.DBID "DBID",


d.name "DB Name",


i.version "DB Version",


i.host_name "Host Name",


to_char(sysdate, 'YYYY-MM-DD HH24:MIS') "ReportGen Time"


from


(select OPTIONS o, DECODE(sum(num),0,'NO','YES') u


from


(


select f.OPTIONS OPTIONS, case


when f_stat.name is null then 0


when ( ( f_stat.currently_used = 'TRUE' and


f_stat.detected_usages > 0 and


(sysdate - f_stat.last_usage_date) < 366 and


f_stat.total_samples > 0


)


or


(f_stat.detected_usages > 0 and


(sysdate - f_stat.last_usage_date) < 366 and


f_stat.total_samples > 0)


) and


( f_stat.name not in('Data Guard', 'Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)')


or


(f_stat.name in('Data Guard', 'Oracle Utility Datapump (Export)', 'Oracle Utility Datapump (Import)') and


f_stat.feature_info is not null and trim(substr(to_char(feature_info), instr(to_char(feature_info), 'compression used: ',1,1) + 18, 2)) != '0')


)


then 1


else 0


end num


from features f,


sys.dba_feature_usage_statistics f_stat


where f.name = f_stat.name(+)


) group by options) t,


v$instance i,


v$database d


order by 2 desc,1


;






exit;

Tuesday, April 19, 2011

ORA-08104: this index object 85828 is being online built or rebuilt

Hi

in one of the incident while rebuilding the INDEX we found that other session is blocking the session which is trying to rebuilt the index

We saw that


---------- ----------
BLOCKING_STATUS
----------------------------------------------------------------------
40277 250
IKBBAT@ahc204 ( SID=250 ) is blocking SYS@ahc263 ( SID=189 )

SID 250 is blocking my id[189] which is trying to rebuild the index
 
 
so we killed the SYS session and after that we killed the other blocking session due to some issue
 
then we tried to rebuild the index and we faced the issue while rebuilding the index
 
SQL> conn / as sysdba


Connected.

SQL> alter index EMS_IKB_STAGE.TMP_POS_DATA_IX rebuild online;

alter index EMS_IKB_STAGE.TMP_POS_DATA_IX rebuild online
*
ERROR at line 1:
ORA-08104: this index object 85828 is being online built or rebuilt

so to solve the issue we did this.....
==========================
 
 
SQL> DECLARE

RetVal BOOLEAN;
OBJECT_ID BINARY_INTEGER;
WAIT_FOR_LOCK BINARY_INTEGER;

BEGIN
OBJECT_ID := 85828;
WAIT_FOR_LOCK := NULL;

RetVal := SYS.DBMS_REPAIR.ONLINE_INDEX_CLEAN (OBJECT_ID);
COMMIT;
END;
/
PL/SQL procedure successfully completed.

and we ran the rebuilt and it went fine... :)
SQL> alter index EMS_IKB_STAGE.TMP_POS_DATA_IX rebuild online;

Sunday, January 23, 2011

Script to Find HOT BLOCKS

SET LINESIZE 200


SET VERIFY OFF



SELECT *

FROM (SELECT name,

addr,

gets,

misses,

sleeps

FROM v$latch_children

WHERE name = 'cache buffers chains'

AND misses > 0

ORDER BY misses DESC)

WHERE rownum < 11;



ACCEPT address PROMPT "Enter ADDR: "



COLUMN owner FORMAT A15

COLUMN object_name FORMAT A30

COLUMN subobject_name FORMAT A20



SELECT *

FROM (SELECT o.owner,

o.object_name,

o.subobject_name,

o.object_type,

bh.tch,

bh.obj,

bh.file#,

bh.dbablk,

DECODE(bh.class,1,'data block',

2,'sort block',

3,'save undo block',

4,'segment header',

5,'save undo header',

6,'free list',

7,'extent map',

8,'1st level bmb',

9,'2nd level bmb',

10,'3rd level bmb',

11,'bitmap block',

12,'bitmap index block',

13,'file header block',

14,'unused',

15,'system undo header',

16,'system undo block',

17,'undo header',

18,'undo block') AS class,

DECODE(bh.state, 0,'free',

1,'xcur',

2,'scur',

3,'cr',

4,'read',

5,'mrec',

6,'irec',

7,'write',

8,'pi',

9,'memory',

10,'mwrite',

11,'donated') AS state

FROM x$bh bh,

dba_objects o

WHERE o.data_object_id = bh.obj

AND hladdr = '&address'

ORDER BY tch DESC)

WHERE rownum < 11;

Script to find Session_log_on_time

set line 200


col osuser format a10 trunc heading "OSUSER AS"

col orauser format a10 trunc

col machine format a10 trunc

col sprogram format a15 trunc

col process format a20 trunc

col server format a3 trunc

col sess_id format 9999

col proc_id format a10

col logon_time format a20

SELECT s.osuser osuser,

s.username orauser,

s.machine machine,

s.program sprogram,

p.program process,

s.sid sess_id,

s.serial# sess_num,

p.spid proc_id,

to_char(s.logon_time, 'hh24:mi dd/mm/yy') login_time,

s.server server,status

---s.client_info

FROM v$session s,

v$process p

WHERE s.paddr = p.addr

AND type != 'BACKGROUND'

AND p.username is not null

ORDER BY 9 desc

/

col osuser clear

col machine clear

col orauser clear

ttitle off

Finding Clustering Factor for Oracle Index

A good CF is equal (or near) to the values of number of blocks of table.

-  A bad CF is equal (or near) to the number of rows of table.
 
It not 100% true that Rebuilding of index can improve the CF.To improve the CF, it’s the table that must be rebuilt (and reordered)
 
====== Script to find the same ======
 
select a.index_name,b.num_rows,b.blocks,a.clustering_factor


from dba_indexes a, dba_tables b

where

index_name in('INDEX_1','INDEX_2','INDEX_3')

and a.table_name=b.table_name;
 

Taking export in Compressed form + Running Export in nohup mode

It is one of the regular DBA activity to take the Backup of database of the schema via exp utility..if we are facing any issue related to the space we can alway is this command to compress the backups and ...if export schema is big and going to take time no need to waste your sleep just run that in backgroung using nohup

 and here it goes

=== Generating Export dump in compressed form ====


iinerva(ammsc001):/m002/oradata/ak>vi exp_4schm.sh

"exp_4schm.sh" 1 line, 1 character

rm exp_pipe

mknod exp_pipe p

compress < exp_pipe > 4Schema_SRF100303.dmp.Z &

exp userid=vijay/spring*****@AMMSC001 file=exp_pipe owner=SALSY,SALEX,SALPF,SALVO statistics=none
buffer=100000
~
~
====== Running in nohup mode =======

iinerva(ammsc001):/m002/oradata/ak>nohup sh exp_4schm.sh &

[1] 74842

iinerva(ammsc001):/m002/oradata/ak>Sending nohup output to nohup.out.

iinerva(ammsc001):/m002/oradata/ak>tail -f nohup.out

About to export SALSY's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export SALSY's tables via Conventional Path ...

. . exporting table AFDELINGEN 7510 rows exported

. . exporting table AFDELINGENGROEPEN 58 rows exported

. . exporting table AFDELINGENGROEPKODES 14 rows exported

. . exporting table AHOLD_LOONKODES 734 rows exported

. . exporting table AHOLD_MUTATIES 5748 rows exported

. . exporting table ARBEIDSRELATIES 450424 rows exported

. . exporting table AVW_CAO_KODES 81 rows exported

. . exporting table AVW_GROEPEN 3215 rows exported

. . exporting table AVW_GROEPKODES 58 rows exported

. . exporting table

........