Friday, August 26, 2016

TFA Collector # 11.2.0.4 RAC new Feature

using TFA Collector - Tool for Enhanced Diagnostic Gathering (Doc ID 1513912.2)
Trace File Analyzer Collector (TFA) is a diagnostic collection utility to simplify diagnostic data collection on Oracle Clusterware/Grid Infrastructure, RAC and Single Instance Database systems.  TFA is similar to the diag collection utility packaged with Oracle Clusterware in that it collects and packages diagnostic data

TFA Collector Simplifies diagnostic data collection and with a single command performs clusterwide diagnostic collection is performed with a single command executed from a single node Diagnostic data uploads to Support are reduced by a factor of 10x or more in most cases and Diagnostic files “trimmed” around the incident time. Collected diagnostics are consolidated on a single node and increased efficiency of admin staff

To check TFA Status #
[oracle@tnc1 bin]$ $GRID_HOME/bin/tfactl print status

[oracle@tnc1 bin]$ cd ..
[oracle@tnc1 grid]$ cd crs/
[oracle@tnc1 crs]$ cd install/
[oracle@tnc1 install]$ ls -ltr

To Install TFA tool 
[oracle@tnc1 install]$ ls -ltr tfa_setup.sh
-rwxr-xr-x 1 root oinstall 15343311 Mar 11 04:35 tfa_setup.sh

To print configuration # 
[oracle@tnc1 install]$ $GRID_HOME/bin/tfactl print config


To check Errors in RAC Cluster # 
[oracle@tnc1 install]$ $GRID_HOME/bin/tfactl print errors
Total Errors found in database: 0
DONE

--References # 
https://juliandontcheff.wordpress.com/2013/08/28/oracle-database-11-2-0-4-new-features/
http://www.hhutzler.de/blog/trace-file-analyzer-collector-tfa-collector/
Linux: Oracle RAC Node Reboot Hangs on TFA Process (Doc ID 1983567.1)

--Nikhil Tatineni--
-- RAC 11.2.0.4 # 

Sunday, August 21, 2016

Extract DDL of Table

 Using metadata package DBMS_METADATA to extract DDL of the table 

SQL> set long 9000
SQL> select dbms_metadata.get_ddl ('TABLE','EMP_INFO') from dual;

--Nikhil Tatineni--
--Database --

Global Index and Local Index

Local Index's are created using Oracle table partitions. 
Partitioned table can be by range, hash and list 
create local index on a partitioned table, it automatically creates index partitions as many as in the table partitions. whenever new partition is created automatically index is created 
Local partitioned index creates one to one relationship between the table partitions. The key value for the table partition and the index partition must be identical 

Advantages #
> Local Index’s are very easy to maintain 
> we will go with Local Index’s where drop old partitions and add new partitions  to the table 
> more faster execution plans using partition pruning 

step 1 # create partition table # populate data 
step 2 # create local index on partition key 

CREATE TABLE emp_info
(
emp_id NUMBER NOT NULL,
join_date DATE NOT NULL,
email VARCHAR2(100)
)
PARTITION BY RANGE (join_date)
(
PARTITION emp_info_p0 VALUES LESS THAN (TO_DATE('01-JAN-2011', 'DD-MON-YYYY')) TABLESPACE tnc_stage,
PARTITION emp_info_p1 VALUES LESS THAN (TO_DATE('01-JAN-2012', 'DD-MON-YYYY')) TABLESPACE tnc_stage,
PARTITION emp_info_p2 VALUES LESS THAN (TO_DATE('01-JAN-2013', 'DD-MON-YYYY')) TABLESPACE tnc_stage,
PARTITION emp_info_p3 VALUES LESS THAN (TO_DATE('01-JAN-2014', 'DD-MON-YYYY')) TABLESPACE tnc_stage,
PARTITION emp_info_p4 VALUES LESS THAN (TO_DATE('01-JAN-2015', 'DD-MON-YYYY')) TABLESPACE tnc_stage
);

populate the data into partition table #

declare
begin
for i in 1..100000
loop
insert into emp_info values (i,'13-APR-2010','xyz'||i);
end loop;
end;
/

declare
begin
for i in 100001..200000
loop
insert into emp_info values (i,'13-APR-2011','xyz'||i);
end loop;
end;

declare
begin
for i in 200001..300000
loop
insert into emp_info values (i,'13-APR-2012','xyz'||i);
end loop;
end;
/

declare
begin
for i in 300001..400000
loop
insert into emp_info values (i,'13-APR-2013','xyz'||i);
end loop;
end;
/

declare
begin
for i in 400001..500000
loop
insert into emp_info values (i,'13-APR-2014','xyz'||i);
end loop;
end;
/

populating data completed on partition table #
check row count each partition in user_tab_partitions.NUM_ROWS. 
row count shows Null defines Online statists gathering are off in 11g but not in 12c 

> select TABLE_NAME,PARTITION_NAME,NUM_ROWS from user_tab_partitions where table_name='EMP_INFO';
> select TABLE_NAME,PARTITION_NAME,NUM_ROWS from user_tab_partitions where table_name='EMP_INFO';
TABLE_NAME       PARTITION_NAME NUM_ROWS
------------------------------ ------------------------------ ----------
EMP_INFO       EMP_INFO_P0
EMP_INFO       EMP_INFO_P1
EMP_INFO       EMP_INFO_P2
EMP_INFO       EMP_INFO_P3
EMP_INFO       EMP_INFO_P4

gather stats manually in 11g as follows
SQL> EXEC DBMS_STATS.gather_table_stats('DELTA','EMP_INFO');
PL/SQL procedure successfully completed.


SQL>  select TABLE_NAME,PARTITION_NAME,NUM_ROWS from user_tab_partitions where table_name='EMP_INFO';
TABLE_NAME       PARTITION_NAME NUM_ROWS
------------------------------ ------------------------------ ----------
EMP_INFO       EMP_INFO_P0   100000
EMP_INFO       EMP_INFO_P1   100000
EMP_INFO       EMP_INFO_P2   100000
EMP_INFO       EMP_INFO_P3   100000
EMP_INFO       EMP_INFO_P4   100000

STEP2 # 
Creating Local Index # on partition table 
>create index partition_local_idx on EMP_INFO (join_date) local;

Querys Used to check partition index's 
>select INDEX_NAME,INDEX_type ,GLOBAL_STATS from user_indexes where index_name='partition_local_idx’;
> select index_name, partition_name from user_ind_partitions where index_name='partition_local_idx';

SQL> select index_name, partition_name from user_ind_partitions where index_name='PARTITION_LOCAL_IDX';
INDEX_NAME       PARTITION_NAME
------------------------------ ------------------------------
PARTITION_LOCAL_IDX       EMP_INFO_P0
PARTITION_LOCAL_IDX       EMP_INFO_P1
PARTITION_LOCAL_IDX       EMP_INFO_P2
PARTITION_LOCAL_IDX       EMP_INFO_P3
PARTITION_LOCAL_IDX       EMP_INFO_P4

Online gather stats for index are enabled in 10g and 11g 
No need to gather stats in recent versions of oracle 

Global Index # To be continued -- 

References #
http://www.oraclebuffer.com/oracle/oracle-12c-global-index-maintenance-is-now-asynchronous/

logdump: Scan for Timestamp



Logdump 267 >sfts 2016-07-21 11:00:00

Scan for timestamp >= 2016/07/21 15:00:00.000.000 GMT
___________________________________________________________________
Hdr-Ind    :     E  (x45)     Partition  :     .  (x04)
UndoFlag   :     .  (x00)     BeforeAfter:     A  (x41)
RecLength  :    59  (x003b)   IO Time    : 2016/07/21 11:00:31.999.422
IOType     :    15  (x0f)     OrigNode   :   255  (xff)
TransInd   :     .  (x03)     FormatType :     R  (x52)
SyskeyLen  :     0  (x00)     Incomplete :     .  (x00)
AuditRBA   :     179323       AuditPos   : 111691280
Continued  :     N  (x00)     RecCount   :     1  (x01)

2016/07/21 11:00:31.999.422 FieldComp            Len    59 RBA 161945260
Name: GGADMIN.HEARTBEAT
After  Image:                                             Partition 4   GU s
 0001 000c 0000 0008 6f76 616c 3030 3970 000e 0004 | ........delta09....
 ffff 0000 000f 001f 0000 3230 3136 2d30 372d 3231 | ..........2016-07-21
 3a31 313a 3030 3a33 322e 3233 3136 3936 3030 30   | :11:00:32.231696000
Column     1 (x0001), Len    12 (x000c)
 0000 0008 6f76 616c 3030 3970                     | ....delta09
Column    14 (x000e), Len     4 (x0004)
 ffff 0000                                         | ....
Column    15 (x000f), Len    31 (x001f)
 0000 3230 3136 2d30 372d 3231 3a31 313a 3030 3a33 | ..2016-07-21:11:00:3
 322e 3233 3136 3936 3030 30                       | 2.231696000


--Nikhil Tatineni--

--Goldengate -- 

Thursday, August 18, 2016

RAC Instance Specific Parameters

Parameter file #
*.audit_file_dest='/u01/app/oracle/admin/mipd09/adump'
*.audit_trail='db'
*.cluster_database=TRUE
*.compatible='11.2.0.4.0'
*.control_files='+STAGE/mipd09/controlfile/current.261.917625349','+STAGE/mipd09/controlfile/current.260.917625349'
*.db_block_size=8192
*.db_create_file_dest='+STAGE'
*.db_domain=''
*.db_name='mipd09'
*.db_recovery_file_dest='+STAGE'
*.db_recovery_file_dest_size=3145728000
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=mipd09XDB)'
mipd091.instance_number=1
mipd092.instance_number=2
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=314572800
*.processes=150
*.local_listener=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.90)(PORT=1521))
*.remote_listener='tnc-scan.localdomain:1521'
*.remote_login_passwordfile='exclusive'
*.sga_target=629145600
mipd091.thread=1
mipd092.thread=2
mipd091.undo_tablespace='UNDOTBS2'
mipd092.undo_tablespace='UNDOTBS1'

Instance-Specific Parameters # 


--Nikhil Tatineni--



Sunday, August 14, 2016

Adaptive query optimization : 12c

Adaptive Query Optimization or Real Time Query Optimization # 

After Parse transformation, Query will enter into optimizer . optimizer will generate different execution plans based on selectivity, cardinality and cost  i.e stats available on sysaux tablespace. After generating better execution plan by optimizer, oracle server process executes the query on database and Oracle Server process start processing the query using execution plan delivered by optimizer and before execution. Here in 12c, Optimizer starts comparing the data sets  depend on tables and type of SQL query and join made on base tables. Depend on volume of rows fetched in data set on base tables ( optimizer discovers cardinality mismatch ), Oracle waits to create and Delay in final Execution plan decision after parsing before execution and follow adaptive Query optimization.  The new behavior of 12c optimizer helps to adjust execution plan on run-time adjustments using statistics collector. Optimizer is smart in 12c 

In 10g by default it is set to 2, Dynamic sampling is enabled when table dons’t have stats on it. 
But in 12c functionality remains same and when ever there is cardinality mismatch during execution of sql query optimizer use adaptive statistics and changes execution plan 

set following parameters on database to enable adaptive query optimization #
optimizer_features_enable=12.1.0
optimizer_adaptive_reporting_only=true ( If this is set to true . Optimizer will not execute query optimization plan, it sticks with execution plan generated by cost based optimizer and  but it will store information, how it can help if we enabled enable adaptive query optimization 
optimizer_dynamic_sampling=11 in 12c (This helps optimizer to go with dynamic sampling or not )

dynamic sampling refer following link 


Friday, August 12, 2016

Managing Oracle Physical Standby Databases


Managing Physical Standby database #
we start MRP process on standby database in mount stage 
Start MRP on standby
sql> alter database recover managed standby database disconnect from session;

To check MRP is running on standby:) 
SELECT PROCESS from V$MANAGED_STANDBY where PROCESS like 'MRP%';

To Stop MRP # 
Sql> alter database recover managed standby database cancel; 

Monitoring STANDBY database 
To check what are the background process running on standby, query v$managed_standby 
Select 
   PROCESS,  
   SEQUENCE#, 
   STATUS 
From 
   V$MANAGED_STANDBY;

To check MRP is running on standby:) 
SELECT PROCESS from V$MANAGED_STANDBY where PROCESS like 'MRP%';

what are the logs  shipped from primary and applied on standby database ?
SELECT 'Last Applied  : ' Logs,
       TO_CHAR (next_time, 'DD-MON-YY:HH24:MI:SS') Time
  FROM v$archived_log
 WHERE sequence# = (SELECT MAX (sequence#)
                      FROM v$archived_log
                     WHERE applied = 'YES')
UNION
SELECT 'Last Received : ' Logs,
       TO_CHAR (next_time, 'DD-MON-YY:HH24:MI:SS') Time
  FROM v$archived_log
 WHERE sequence# = (SELECT MAX (sequence#) FROM v$archived_log);

On Standby site, query  “v$archive_dest_status” to find the last archived log received and applied on this site
Select 
   ARCHIVED_THREAD#, 
   ARCHIVED_SEQ#, 
   APPLIED_THREAD#,
   APPLIED_SEQ#
From 
   V$ARCHIVE_DEST_STATUS;

Query’s used to find out archive gap between primary and standby 
Views Used # v$archived_log & v$log_history 
sql> SELECT ARCH.THREAD# “Thread”, ARCH.SEQUENCE# “Last Sequence Received”, APPL.SEQUENCE# “Last Sequence Applied”, (ARCH.SEQUENCE# – APPL.SEQUENCE#) “Difference” FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH, (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;

Views used to Check Database Errors ( v$Archived_gap & v$dataguard_status)
set pages 300 lines 300
column Timestamp Format a20
column Facility  Format a24
column Severity  Format a13
column Message   Format a80 trunc
Select to_char(timestamp,'YYYY-MON-DD HH24:MI:SS') Timestamp,Facility,Severity,error_code,message_num,Message from v$dataguard_status where severity in ('Error','Fatal') order by Timestamp;

sql > select  *  from v$ARCHIVE_GAP;

--Nikhil Tatineni--
--Standby -- 

Querys to monitor RAC

following few  Query's will help to find out culprits-  Query to check long running transaction from last 8 hours  Col Sid Fo...