Subscribe to Posts by Email

Subscriber Count

    705

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Oracle Compression: Concepts & Usage

As the data grows in relational databases (new business requirements, managing audit data etc), the cost associated with the disk systems to store that data and the resources required to manage them becomes vital.

Hence it is necessary to adopt techniques like compression, de-duplication etc to reduce the storage costs.

Lets go one by one of compression techniques and usage, I will be discussing the de-duplication in length in another post.

Types of Compression

Physical Compression

Logical Compression

External Compression

Hardware Assisted

Block/Page Level

Segment Level

Row Level

TDE

Binary Compression

Use custom algorithm for ex: CLEMCOM etc for mainframes

What is compression for Any RDBMS?

 

Continue reading Oracle Compression: Concepts & Usage

ORA-01200: actual file size of X is smaller than correct size of Y

Yesterday My colleague has encountered the following issue, which is interesting.

Environment:-

1) Linux & 10g Database

2) Oracle Block size =8192

3) OS Block/Page size = 4096

Issue:- ORA-01200: actual file size of X is smaller than correct size of Y

Verification:-

1) Database was not opening (non system datafile)

2) DBV says no corruption

Continue reading ORA-01200: actual file size of X is smaller than correct size of Y

SQL : Query to generate dates or weekday for a year etc.

 

When I was working for a tool in Apex some time back, need some scripts on automatic date generation, after some googling and changing the modified ones, here are some scripts that useful to generate a date in sequence etc.

 

Generating dates for a month
===================

select to_date('01 2010','MM YYYY')-1 + level as DateRange from    dual  where  (to_date('12 2010','MM YYYY')-1+level) <= last_day(to_date('12 2010','MM YYYY')) connect by level<=31

Generating sequence of dates

====================

SELECT TO_DATE('01-JAN-2010') + ROWNUM - 1
FROM (
  SELECT ROWNUM FROM (
    SELECT 1 FROM DUAL
    CONNECT BY LEVEL <= (TO_DATE('01-DEC-2010') - TO_DATE('01-JAN-2010'))
  )
);

Generate Each Friday
==================

SELECT each_day "friday"
  FROM (SELECT     (SYSDATE - 60) + LEVEL each_day
              FROM DUAL
        CONNECT BY LEVEL <= 365)
WHERE TO_CHAR (each_day, 'D') = '6' order by 1

Have fun using them!!!

Geek DBA

Crontab: Nice explanation of a crontab entries

If anyone want to know about the cron tab entries sequence, here it is.

- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

 

Helped?

-Regards

Geek DBA

Dataguard: Best practices document

Dear All,

Attached the document for all your reference, which I found very useful and informative on dataguard best practices. this also helps in diagnosing and tuning dataguard related issues.

Enjoy reading.

http://db.geeksinsight.com/wp-content/uploads//2012/10/dataguard_bestpractices.doc

-Thanks

Geek DBA

Scripts: Database,Table,Tablespace Growth Report using AWR

Want to know new features in 12c, 18c, 19c, 20c ??? Follow this

More than 100+ features listed here : http://db.geeksinsight.com/category/12c-database/

More than 50+ features listed here: http://db.geeksinsight.com/category/18c-database/

More than 40 features listed here: http://db.geeksinsight.com/category/19c-database/

Upcoming 20c features : http://db.geeksinsight.com/category/20c-database/

Hello

The following code snippets are collected from various sources and updating here, (not sure even about copy write of those, if any found so, I am happy to remove from here), until then we will try to use them.

Some background,  Oracle AWR by default collects the information about the segment growth periodically. This information can be queried using views DBA_HIST_SEG_STAT.

Script #1 : script to display table size changes between two periods. 

column "Percent of Total Disk Usage" justify right format 999.99
column "Space Used (MB)" justify right format 9,999,999.99
column "Total Object Size (MB)" justify right format 9,999,999.99
set linesize 150
set pages 80
set feedback off
select * from (select to_char(end_interval_time, 'MM/DD/YY') mydate, sum(space_used_delta) / 1024 / 1024 "Space used (MB)", avg(c.bytes) / 1024 / 1024 "Total Object Size (MB)",
round(sum(space_used_delta) / sum(c.bytes) * 100, 2) "Percent of Total Disk Usage"
from
   dba_hist_snapshot sn,
   dba_hist_seg_stat a,
   dba_objects b,
   dba_segments c
where begin_interval_time > trunc(sysdate) - &days_back
and sn.snap_id = a.snap_id
and b.object_id = a.obj#
and b.owner = c.owner
and b.object_name = c.segment_name
and c.segment_name = '&segment_name'
group by to_char(end_interval_time, 'MM/DD/YY'))
order by to_date(mydate, 'MM/DD/YY');

 

Script #2:-  Database Growth in 1 hour intervals

Declare
    v_BaselineSize    number(20);
    v_CurrentSize    number(20);
    v_TotalGrowth    number(20);
    v_Space        number(20);
    cursor usageHist is
            select a.snap_id,
            SNAP_TIME,
            sum(TOTAL_SPACE_ALLOCATED_DELTA) over ( order by a.SNAP_ID) ProgSum
        from
            (select SNAP_ID,
                sum(SPACE_ALLOCATED_DELTA) TOTAL_SPACE_ALLOCATED_DELTA
            from DBA_HIST_SEG_STAT
            group by SNAP_ID
            having sum(SPACE_ALLOCATED_TOTAL) <> 0
            order by 1 ) a,
            (select distinct SNAP_ID,
                to_char(END_INTERVAL_TIME,'DD-Mon-YYYY HH24:Mi') SNAP_TIME
            from DBA_HIST_SNAPSHOT) b
        where a.snap_id=b.snap_id;
Begin
    select sum(SPACE_ALLOCATED_DELTA) into v_TotalGrowth from DBA_HIST_SEG_STAT;
    select sum(bytes) into v_CurrentSize from dba_segments;
    v_BaselineSize := v_CurrentSize - v_TotalGrowth ;

    dbms_output.put_line('SNAP_TIME           Database Size(MB)');

    for row in usageHist loop
            v_Space := (v_BaselineSize + row.ProgSum)/(1024*1024);
        dbms_output.put_line(row.SNAP_TIME || '           ' || to_char(v_Space) );
    end loop;
end;

 

Script #3: Top 50 Query which can be used to query segments with highest growth. This will also report the present size of the segment which is very useful in identifying the growth percentage.

SELECT o.OWNER , o.OBJECT_NAME , o.SUBOBJECT_NAME , o.OBJECT_TYPE ,
    t.NAME "Tablespace Name", s.growth/(1024*1024) "Growth in MB",
    (SELECT sum(bytes)/(1024*1024)
    FROM dba_segments
    WHERE segment_name=o.object_name) "Total Size(MB)"
FROM DBA_OBJECTS o,
    ( SELECT TS#,OBJ#,
        SUM(SPACE_USED_DELTA) growth
    FROM DBA_HIST_SEG_STAT
    GROUP BY TS#,OBJ#
    HAVING SUM(SPACE_USED_DELTA) > 0
    ORDER BY 2 DESC ) s,
    v$tablespace t
WHERE s.OBJ# = o.OBJECT_ID
AND s.TS#=t.TS#
AND rownum < 51
ORDER BY 6 DESC
/

 

Script #4: List object growth over last N days, sorted by growth desc

set feedback on
select * from (select c.TABLESPACE_NAME,c.segment_name “Object Name”,b.object_type,
sum(space_used_delta) / 1024 / 1024 “Growth (MB)”
from dba_hist_snapshot sn,
dba_hist_seg_stat a,
dba_objects b,
dba_segments c
where begin_interval_time > trunc(sysdate) – &days_back
and sn.snap_id = a.snap_id
and b.object_id = a.obj#
and b.owner = c.owner
and b.object_name = c.segment_name
and c.owner =’SIEBEL’
group by c.TABLESPACE_NAME,c.segment_name,b.object_type)
order by 3 asc;

 

Script #5: generates tablespace usage trend/growth.

SET MARKUP HTML ON ENTMAP ON SPOOL ON PREFORMAT OFF;
set linesize 125
set numwidth 20
set pagesize 50
COL NAME FOR A30
col SNAP_ID for 9999999
set serveroutput off;
SPOOL TBS_TREND.xls;
set verify off;
set echo off;

SELECT
distinct DHSS.SNAP_ID,VTS.NAME,
TO_CHAR(DHSS.END_INTERVAL_TIME, 'DD-MM HH:MI') AS SNAP_Time,
ROUND((DHTS.TABLESPACE_USEDSIZE*8192)/1024/1024)/&&max_instance_num AS USED_MB,
ROUND((DHTS.TABLESPACE_SIZE*8192)/1024/1024)/&&max_instance_num AS SIZE_MB
FROM DBA_HIST_TBSPC_SPACE_USAGE DHTS,V$TABLESPACE VTS,DBA_HIST_SNAPSHOT DHSS
WHERE VTS.TS#=DHTS.TABLESPACE_ID
AND DHTS.SNAP_ID=DHSS.SNAP_ID
AND DHSS.INSTANCE_NUMBER=1
AND TABLESPACE_ID=&id
ORDER BY 1;
SPOOL OFF;

 

Wish this is useful.

Geek DBA

Dataguard: ORA-16047: DGID mismatch between destination setting and standby

 

In My primary alert log,

******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_3
******************************************************************
LGWR: Error 16047 creating archivelog file 'STREAMS'
Mon Oct 15 23:58:24 IST 2012
Errors in file /u02/app/oracle/admin/PROD/bdump/prod2_lns2_16765.trc:
ORA-16047: DGID mismatch between destination setting and standby
LNS: Failed to archive log 5 thread 2 sequence 2759 (16047)
Mon Oct 15 23:58:30 IST 2012
Errors in file /u02/app/oracle/admin/PROD/bdump/prod2_arc1_11140.trc:
ORA-16047: DGID mismatch between destination setting and standby
Mon Oct 15 23:58:30 IST 2012
FAL[server, ARC1]: Error 16047 creating remote archivelog file 'STREAMS'
FAL[server, ARC1]: FAL archive failed, see trace file.
Mon Oct 15 23:58:30 IST 2012
Errors in file /u02/app/oracle/admin/PROD/bdump/prod2_arc1_11140.trc:
ORA-16055: FAL request rejected

 

NAME                  TYPE      VALUE
--------------------- --------- ------------------------------
log_archive_dest_3    string    SERVICE=STREAMS LGWR ASYNC NOREG
                                                ISTER VALID_FOR=(ONLINE_LOGFIL
                                                ES,PRIMARY_ROLE) DB_UNIQUE_NAM
                                                E=STREAMS

 

Well, my bad, I have changed the database name from TEST to STREAMS using NID, but forgot  to changed the db_unique_name.

 

Settings in my standby

 

SQL> show parameter db_unique_name

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
db_unique_name                       string                    TEST1

SQL> show parameter db_name

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
db_name                              string                           STREAMS

SQL> show parameter Instance_name

NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
instance_name                        string                           STREAMS

SQL>

🙁

Change the db_unique_name and bounced the instance , resolve the issue.

SQL> show parameter db_unique_name

NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
db_unique_name string STREAMS

 

-Geek DBA

EXPDP: FLAHSBACK_TIME, ora-01841

For doing a consistent expdp backup to use flashback_time , documentation provides to use systimestamp where it will fail always (as in my case now)

Error:-

Conneted to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64 bit Production
With the Partionining,OLAP, Data Mining and Real Applicatiojn Testing options
ORA-39001: invalid argument value
ORA-39150: bad flashback time
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
ORA-00911: invalid character

I am sure and remember well systimestamp should work, but some how not working

Instead of flashback_time=systimestamp

use flashback_time="TO_TIMESTAMP('16-10-2012 00:30:00', 'DD-MM-YYYY HH24:MI:SS')"

Hope this helps

-Thanks

Geek DBA

11g Dataguard Standby Password file case sensitive issue

A call today from one of my friend regarding switchover issue, once the role swap has been performed the standby (current primary) is not able to ship the redo log files.

Verification:-

1) v$managed_standby in production(current standby) stucks at sequence “waiting for log”

2) Trace files shows

Redo shipping client performing standby login
OCISessionBegin failed -1
.. Detailed OCI error val is 1017 and errmsg is 'ORA-01017: invalid username/password; logon denied
'
OCISessionBegin failed. Error -1
.. Detailed OCI error val is 1031 and errmsg is 'ORA-01031: insufficient privileges
'
OCISessionBegin failed. Error -1
.. Detailed OCI error val is 1031 and errmsg is 'ORA-01031: insufficient privileges

3) ORA-16191

As usual, its a password file issue, we have done

1) Recreated the password file – no luck

2) Copied the password from standby (current primary) to production (current standby)

But no luck,

After a lot of scratching, got that the database is running 11gR2, apparently my doubt turns to password case sensitive,

1) deleted the password files

2) created the password file with ignorecase=y using orapwd

orapwd file=orapwdgstby entries=100 password=***** ignorecase=y

Viola, this time its worked…….. standby sync resumed. So you will have to use ignorecase=y option for 11g password files as they turned to case sensitive now.

Just for all your information , if you are also may sail in same boat.

-Thanks

Geek DBA

Quiz Post #8: How does RAC Instance failure/membership detection happens in Clusterware/RAC?

 

We all know that CGS (when 10g CRS uses, its OCSSD), (When used third party clusterware, CM) will provide Cluster group service which manages nodes integrity and restart them when there is node level (hardware,network,OS, scheduling) issues happens. So it means the CGS will manage the node level issues and also manages the cluster group membership.

But how does a intra instance or inter instance (RAC Instances) communication or membership happens and their failures?

To know more about it, Remember CM works at cluster level not instance level, In order to serve this purpose, the other important aspect managed by CGS is Instance Membership Recovery (IMR) which will be happen when there is a communication failure between RAC instances.

The node manager (NM) in RAC instances provides information about nodes and their health by registering and communicating with the CM. This NM service will be provided by LMON process.

Now take a closure look at registering and communicating of RAC instance to CGS,

Registering:- When ever the instance is mounted the LMON process registers it status to NM and the cluster level it marks the instance is UP. A bitmap is stored in the GRD of the instance (0 means node dead, 1 means node alive) Every time, node(i want to say instance here) joins /leave the cluster this bitmap will be marked according and updated to the other instances.

Communicating:-  (talking especially about instance death detection)  The cgs is responsible for checking whether all member (here instances) are valid. To determine whether all members are alive, a voting mechanism will be used . But where, The each instance CKPT process updates the control file every three seconds about their status in operation known as heartbeat. A block called checkpoint process record for each instance writes its blocks to Control file and thus acquired a block for each instance in control file. After sometime , CGS (NM) determines the votes (blocks, again this is completely different from the votes in the voting disk) before allowing the GES/GCS reconfiguration to proceed if the instance is failed and mark the bitmap accordingly in GRD. there by providing I/O fencing and flush the pending I/O to disk for the failed instance.

So the OCSSD process (CGS) will be doing membership of the RAC instances in terms of IMR and LMON will be responsible in registering with CGS and control file heartbeat (votes) determine the instance health (not the voting disk votes).

Might be confusing, yes that’s what it is.

Reference:- http://www.amazon.co.uk/Oracle-Database-Application-Clusters-Handbook/dp/0071752625

-Thanks

Geek DBA