Quantcast
Channel: SanOraLife
Viewing all 112 articles
Browse latest View live

How to get explain plan from Netezza?

$
0
0

explain verbose select * from tablename;






ORA-03001: unimplemented feature

$
0
0

Change the current_schema to the actual table owner by connecting as some other user in sql*plus and try renaming the table:


SQL> alter session set current_schema=scott;
Session altered.
SQL> rename emp to emp_back;
rename emp to emp_back
*
ERROR at line 1:
ORA-03001: unimplemented feature

Now: Try running the following command to rename the same table being in the same session with current_schema=scott;

SQL> alter table emp rename to emp_back;
Table altered.
SQL>




How to Install Oracle TEXT manually in 10gR2

$
0
0
OK, By Default Oracle TEXT (CTXSYS Schema) is installed in the database if DBCA is used.

In case if its missed out and need to install manually then dont panic as installing Oracle Text is too simple as showed below:

Step#1:
Connect to the database as SYS and run:

SQL> @?/ctx/admin/catctx.sql CTXSYS SYSAUX TEMP NOLOCK

Above, CTXSYS is the password and SYSAUX is the default tablespace for user CTXSYS and TEMP is the temp tablespace and NOLOCK specifies that this account is not locked.

This will create CTXSYS schema with all objects.

Step#2:

The next step is to install appropriate language-specific default preferences. There is script which creates language-specific default preferences for every language Oracle text supports in /ctx/admin/defaults directory, such as English(US), Danish(DK), Dutch(NL), Finnish(SF), French(F), German(D), Italian(IT), Portuguese(PT), Spanish(E), and Swedish(S). They are named in the form drdefXX.sql, where XX is the international license plate code.
To manually install US default preferences, for example, log into sqlplus as CTXSYS, and run 'drdefus.sql' as described below:

Connect as CTXSYS:

SQL> connect CTXSYS/password@your_DB
SQL> @?/ctx/admin/defaults/drdefus.sql

Step3#:
Grant CTXAPP Role to the developer who needs it along with any other EXECUTE Privs on CTXSYS Packages that are required.

Hope this helps.

How to find RAC Cluster Name and Version?

$
0
0

Run cemutlo command under grid home to get Cluster info such as name and version.

Options:
        -n prints the cluster name
        -w prints the clusterware version in the following format:
                 ::

Wait event: kksfbc child completion

$
0
0
Noticed this wait event "kksfbc child completion" in one of our database when a client complained that the report which was generally taking few seconds is hung today for more than hours!!!

When looked into the sessions, found that this session is waiting on "kksfbc child completion".

This is confirmed bug "6795880 - Session spins / OERI after 'kksfbc child completion' wait - superceded [ID 6795880.8]"

Bug Description:


This fix has been superseded by bug:8575528.

A session may go into an infinite spin just after a wait
for 'kksfbc child completion'. The spin occurs with
a stack including kksSearchChildList -> kkshgnc where
kksSearchChildList loops forever.

This problem can also lead to internal error such as any of
ORA-600 [kksSearchChildList1], ORA-600 [kksSearchChildList2]
ORA-600 [kksSearchChildList3], ORA-600 [kkshgnc-nextchild]

Or Trace dumps on kksSearchChildList4 .

Note:
  This fix is disabled by default in 10g.
  To enable this fix you must explicitly set the following
  parameter for instance startup:
    "_cursor_features_enabled" = 10

Metalinks Info on this bug:


Bug 6795880  Session spins / OERI after 'kksfbc child completion' wait - superceded

 This note gives a brief overview of bug 6795880. 
 The content was last updated on: 05-APR-2011
 Click here for details of each of the sections below.

Affects:

Product (Component)Oracle Server (Rdbms)
Range of versions believed to be affectedVersions BELOW 11.2
Versions confirmed as being affected
Platforms affectedGeneric (all / most platforms affected)

 Note that this fix can cause / expose the problem described in Bug:8575528

 Note that this fix has been superceded by the fix in Bug:8575528 

Fixed:

This issue is fixed in

Symptoms:

Related To:



ORA-00245: control file backup operation failed

$
0
0
If you are getting the error "ORA-00245: control file backup operation failed" in 11gR2 then the solution is to use the backup location which is a Shared Location (which can be seen by all Nodes within the Cluster) for any form of controlfile backups.

Here is the Metalink Notes (ID: 1472171.1) that describes about this New Feature in 11g Release 2 RAC Environment:

Excerpt from Metalinks for whom they do not have access to metalinks:


Oracle Server - Enterprise Edition - Version 11.2.0.1.0 and later
Information in this document applies to any platform.
This issue is only applicable to RAC database.

From 11gR2 onwards, the controlfile backup happens without holding the controlfile enqueue. For non-RAC database, this doesn't change anything. But for RAC database, due to the changes made to the controlfile backup mechanism in 11gR2, any instance in the cluster may write to the snapshot controlfile. Due to this snapshot controlfile need to be visible to all instances.

The snapshot controlfile MUST be accessible by all nodes of a RAC database, if the snapshot controlfile does not reside on a shared device error will be raised at the time of RMAN backup while taking snapshot of controlfile.

This applies to backing up controlfile using sqlplus / having autobackup of controlfile configured on non
shared location.



Description

1. In RAC environment controlfile autobackup fails with ora-0245
Autobackup of controlfile in RMAN is failing with error:
RMAN-571: ===========================================================
RMAN-569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-571: ===========================================================
RMAN-3009: failure of Control File and SPFILE Autobackup command on
ORA_DISK_1 channel at 10/27/2010 12:13:31
ORA-245: control file backup operation failed

2. In RAC environment, backup controlfile to non shared location fails
SQL> ALTER DATABASE BACKUP CONTROLFILE TO '/home/rac1122/test/control.bk' REUSE
*
ERROR at line 1:
ORA-245: control file backup operation failed

3. In RAC environment backing up standby controlfile to non shared location fails
SQL> alter database create standby controlfile as '/home/oracle/renostdbycntrl.ctl';
alter database create standby controlfile as
'/home/oracle/renostdbycntrl.ctl'
*
ERROR at line 1:
ORA-245: control file backup operation failed

4. In RAC environment copy current controlfile to '${DB_BACKUP_DIR}/rac_tnctv_control.bak';
channel ch1: starting datafile copy
copying current control file
RMAN-571: ===========================================================
RMAN-569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-571: ===========================================================
RMAN-3009: failure of backup command on 10/07/2011 11:36:42 channel at ch1
ORA-245: control file backup operation failed

5. In RAC environment, Rman backup fails if snapshot controlfile is not in shared location.
 RMAN-00571: ========================================================
RMAN-00569: ============ ERROR MESSAGE STACK FOLLOWS =============
RMAN-00571: =========================================================
RMAN-03009: failure of resync command on default channel at 03/13/2012 10:19:41
ORA-00245: control file backup operation failed

Occurrence

Only affect Real application Cluster (RAC ), 11.2 specific.

Symptoms

 In RAC environment any form of controlfile backup may fail with ORA-0245 if the location of the Snapshot Controlfile is not a shared location.
The backup of the controlfile actualy makes a backup of the SNAPSHOT controlfile. The Snapshot controlfile is created when the controlfile is about to be backed up.
The Snapshot controlfile is a read-consistent copy of the controlfile.

Workaround

It is changed behaviour which requires that the snapshot controlfile in a RAC environment, is on a shared location. 
1. Check the snapshot controlfile location:

RMAN> show snapshot controlfile name;
2. Configure the snapshot controlfile to a shared disk:
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/snapcf_.f';
Or in case of ASM use
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+/snapcf_.f';

ORA-13516: AWR Operation failed: only a subset of SQL can be issued

$
0
0
First started noticing that OEM is not showing any stats in other words no change in the session activity...
Digging into more found that the error "ORA-13516: AWR Operation failed: only a subset of SQL can be issued" showing up.

So, tried to create a snapshot manually and got the same error:

SQL> exec dbms_workload_repository.create_snapshot;
BEGIN dbms_workload_repository.create_snapshot; END;

*
ERROR at line 1:
ORA-13516: AWR Operation failed: only a subset of SQL can be issued
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 10
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 33
ORA-06512: at line 1


Looking into metalinks note#1226534 its apparent that either you have to run CATAWR.SQL or just bounce the instance (well, in my case its RAC database so no need to bounce the entire db but just the instance). 

Bounced the instance and now everything is running smooth again...
SQL> exec dbms_workload_repository.create_snapshot;

PL/SQL procedure successfully completed.

How to find Cluster Interconnect IP in RAC

$
0
0
Couple of ways around to find the Interconnect IP Address defined in RAC environment.

First thing would be to look in /etc/hosts to see which IP is assigned based on the comments or naming conventions.

Or check ASM Alert logs for the wording "Cluster Communication is configured to use the following interface(s)"

Or
Run the following sql:

select inst_id, ip_address from gv$cluster_interconnects;


File Permissions in Unix - Numeric Representation

$
0
0
chmod 777 file_name - gets you full access to everybody in Unix. What does 777 mean?
First digit is OWNER, Second digit is GROUP and the Third is OTHERS.

So, if a file has rwx-x-x which means, Owner can Read, Write an Execute (rwx) and the Group and the Other can only Execute (x). Below chart represents the numbers (like 755, 644) and its meaning.

Octal digit
Text equivalent
Binary value
Meaning
0
---
000
All types of access are denied
1
--x
001
Execute access is allowed only
2
-w-
010
Write access is allowed only
3
-wx
011
Write and execute access are allowed
4
r--
100
Read access is allowed only
5
r-x
101
Read and execute access are allowed
6
rw-
110
Read and write access are allowed
7
rwx
111
Everything is allowed


As you see that "1" stands for execute only, "2" stands for write only, "4" stands for read only. To combine the permissions you can simply add 1, 2 and 4 to get a needed combination. For instance, to get read and write permissions, you add 4 (read) and 2 (write), thus getting 6 (read and write). To get read and execute permissions, you add  4 (read) and 1 (execute), thus getting 5 (read and execute).

PS: Adding this here for my quick reference not that the world doesn't know about it :)

Table and Index Size...

$
0
0
SQL to list out Tables and Indexes size for a given Schema:

--This Lists out Index size for all indexes in the table:

select ind.table_name, round(tbl.table_size,2) "Table Size (GB)", round(ind.index_size,2) "Indexes Size (GB)", 
       round((tbl.table_size + ind.index_size), 2) "Total Size (GB)"
  from (select segment_name, segment_type, sum(bytes / 1024) / 1024 / 1024 table_size
          from dba_segments
         where segment_type in ('TABLE') 
           and owner = '&Schema_Owner'
        group by segment_name, segment_type
       ) tbl,
       (select db.table_name, da.segment_type, sum(bytes / 1024) / 1024 / 1024 index_size
          from dba_segments da, dba_indexes db
         where da.segment_type in ('INDEX')
           and da.owner = '&Schema_Owner'
           and da.tablespace_name = db.tablespace_name
           and da.segment_name = db.index_name
          group by da.segment_type, db.table_name
       ) ind
 where tbl.segment_name = ind.table_name 
 order by tbl.table_size + ind.index_size desc;


--with Tablespace Info:
select ind.table_name, tbl.tablespace_name "Table TS", round(tbl.table_size,2) "Table Size (GB)", 
       ind.tablespace_name "Index TS", round(ind.index_size,2) "Indexes Size (GB)", 
       round((tbl.table_size + ind.index_size), 2) "Total Size (GB)"
  from (select segment_name, segment_type, tablespace_name, sum(bytes / 1024) / 1024 / 1024 table_size
          from dba_segments 
         where segment_type in ('TABLE') 
           and owner = '&Schema_Owner'
        group by segment_name, segment_type, tablespace_name
       ) tbl,
       (select db.table_name, da.segment_type, da.tablespace_name, sum(bytes / 1024) / 1024 / 1024 index_size
          from dba_segments da, dba_indexes db
         where da.segment_type in ('INDEX')
           and da.owner = '&Schema_Owner'
           and da.tablespace_name = db.tablespace_name
           and da.segment_name = db.index_name
          group by da.segment_type, db.table_name,da.tablespace_name
       ) ind
 where tbl.segment_name = ind.table_name 
 order by tbl.table_size + ind.index_size desc;

--This Lists out Individual Index Size within the Table:
select ind.table_name, ind.index_name, round(tbl.table_size,2) "Table Size (GB)", sum(ind.index_size) "Indexes Size (GB)" 
       --sum(tbl.table_size) + sum(ind.index_size) "Total Size (GB)"
  from (select segment_name, segment_type, sum(bytes / 1024) / 1024 / 1024 table_size
          from dba_segments
         where segment_type in ('TABLE') 
           and owner = '&Schema_Owner'
        group by segment_name, segment_type
       ) tbl,
       (select db.table_name, db.index_name, da.segment_type, sum(bytes / 1024) / 1024 / 1024 index_size
          from dba_segments da, dba_indexes db
         where da.segment_type in ('INDEX')
           and da.owner = '&Schema_Owner'
           and da.tablespace_name = db.tablespace_name
           and da.segment_name = db.index_name
          group by da.segment_type, db.table_name, db.index_name
       ) ind
 where tbl.segment_name = ind.table_name 
 group by rollup (ind.table_name, ind.index_name, tbl.table_size)
 order by 1 
 

"row cache lock" wait event...

$
0
0
One of those things that needs to be worried in RAC environment...

Noticed this event "row cache lock" the other day in our database on a simple insert. SQL is mostly showing waits on this even with so much of wait time.

Digging more, found that there was a sequence which "cache" size was not optimized for RAC environment. It has 20 as cache size. Increased to 20000 and this event disappears...

Finding the issue:

Run the following sql to find the CacheID:

select p1text,p1,p2text,p2,p3text,p3
  from gv$session
 where event = 'row cache lock';

Use the above returned CacheID in the below sql to find the Enqueue type:
select parameter ,count ,gets ,getmisses ,modifications
  from gv$rowcache
 where cache#=13;

This shows me it is dc_sequences.

Now, find the SEQuence which is being used in the SQL and check the cache size and change it.
alter sequence your_sequence
 increment by 1
 minvalue 1
 maxvalue 999999999999999999999999999
 cache 20000
 nocycle
 noorder;

"library cache lock" wait event...

$
0
0
Another wait event that I faced today:

The job that extracts the data from Oracle using fastreader generally finishes pretty fast but today it seems that it never finished...

Looking into session info found that its waiting on "library cache lock".

whats object is it waiting on and who is blocking it?
In my scenario I just ran the following queries to find out which object my select statement (yes it was a select query that was hung on library cache lock and not a DML). Found schedule jobs that were tripping over on Adding and Dropping partitions on this table at the same time made this query to get hung.

First query to find sessions with library cache lock:

select a.sid Waiter,b.SERIAL#,a.event,a.p1raw,
       substr(rawtohex(a.p1),1,30) Handle,
       substr(rawtohex(a.p2),1,30) Pin_addr,
       a.p3
  from gv$session_wait a, gv$session b
 where a.sid=b.sid
   and a.wait_time=0 and a.event like 'library cache lock';

Second query to find the actual object:

select to_char(SESSION_ID,'999') sid, substr(LOCK_TYPE,1,30) "Type",
       substr(lock_id1,1,23) "Object_Name", substr(mode_held,1,4) "HELD",
       substr(mode_requested,1,4) "REQ", lock_id2 "Lock_addr"
  from dba_lock_internal
 where mode_requested<>'None'
   and mode_requested<>mode_held
   and session_id = 1265; --place the sid from the above query to find an object for that session.



Here is the metalink note id:122793.1 which describes how to find answers for above questions.

Here is the excerpt for immediate reference (or for non-metalink users):
It has two methods and I like the first method by goring the SQL's:


METHOD 2: EXAMINE THE X$KGLLK TABLE

The X$KGLLK table (accessible only as SYS/INTERNAL) contains all the library object locks (both held & requested) for all sessions and is more complete than the V$LOCK view although the column names don't always reveal their meaning.

You can examine the locks requested (and held) by the waiting session by looking up the session address (SADDR) in V$SESSION and doing the following select:
select sid,saddr from v$session where event= 'library cache lock';

SID SADDR
---------- --------
16 572ed244


select kgllkhdl Handle,kgllkreq Request, kglnaobj Object
from x$kgllk where kgllkses = '572ed244'
and kgllkreq > 0;

HANDLE   REQUEST   OBJECT
-------- ---------- ------------------------------------------------------------
62d064dc          2 EMPLOYEES

This will show you the library cache lock requested by this session (KGLLKREQ > 0) where KGLNAOBJ contains the first 80 characters of the name of the object.The value in KGLLKHDL corresponds with the 'handle address' of the object in Method 1 Systemstate Analysis as shown above.

 If we now match the KGLLKHDL with the handles of other sessions in X$KGLLK that should give us the address of the blocking session.The session holding the lock will have KGLLKMOD > 0 as it is holding the lock.
select kgllkses saddr,kgllkhdl handle,kgllkmod mod,kglnaobj object
from x$kgllk lock_a
where kgllkmod > 0
and exists (select lock_b.kgllkhdl from x$kgllk lock_b
where kgllkses = '572ed244' /* blocked session */
and lock_a.kgllkhdl = lock_b.kgllkhdl
and kgllkreq > 0);

SADDR     HANDLE   MOD
--------  -------- ----------
OBJECT
------------------------------------------------------------
572eac94  62d064dc          3
EMPLOYEES


If we look a bit further we can then again match KGLLKSES with SADDR in v$session to find further information on the blocking session:

select sid,username,terminal,program from v$session where saddr = '572eac94'

SID        USERNAME                  TERMINAL
---------- ------------------------------ ------------------------------
PROGRAM
------------------------------------------------
12          SCOTT                          pts/20
sqlplus@goblin.forgotten.realms (TNS V1-V3)

In the same way we can also find all the blocked sessions:
select sid,username,terminal,program from v$session
where saddr in
(select kgllkses from x$kgllk lock_a
 where kgllkreq > 0
 and exists (select lock_b.kgllkhdl from x$kgllk lock_b
             where kgllkses = '572eac94' /* blocking session */
             and lock_a.kgllkhdl = lock_b.kgllkhdl
             and kgllkreq = 0)
);

SID        USERNAME                       TERMINAL
---------- ------------------------------ ------------------------------
PROGRAM
------------------------------------------------
13         SCOTT                           pts/22
sqlplus@goblin.forgotten.realms (TNS V1-V3)

16         SCOTT                           pts/7
sqlplus@goblin.forgotten.realms (TNS V1-V3)



Method 1: Systemstate Analysis

Systemstate event will create a tracefile containing detailed information on every Oracle process. This information includes all the resources held & requested by a specific process.

While an operation is hanging, open a new session and launch the following statement:
For Oracle 9.2.0.1 or higher:
$sqlplus '/ as sysdba'
oradebug setmypid
oradebug unlimit
oradebug dump systemstate 266

For older versions you can use the following syntax that is also possible in higher versions.The level 266 is not available before 9.2.0.6
alter session set max_dump_file_size=unlimited;
alter session set events 'immediate trace name systemstate level 10'

 Oracle will create a systemstate tracefile in your USER_DUMP_DEST directory.

Get the PID (ProcessID) of the 'hanging' session:
select pid from v$process where addr=
(select paddr from v$session where sid= );

The systemstate dump contains a separate section with information for each process.
Open the tracefile and do a search for "PROCESS ".
In the process section search for the wait event by doing a search on 'waiting for'.
PROCESS 20:
----------------------------------------
SO: 0x7d2bd820, type: 2, owner: (nil), flag: INIT/-/-/0x00
(process) Oracle pid=20, calls cur/top: 0x7d3d62d0/0x7d3d85dc, flag: (0) -
int error: 0, call error: 0, sess error: 0, txn error 0
(post info) last post received: 109 0 4
last post received-location: kslpsr
last process to post me: 7d2b8d94 1 6
last post sent: 0 0 24
last post sent-location: ksasnd
last process posted by me: 7d2b8d94 1 6
(latch info) wait_event=0 bits=0
Process Group: DEFAULT, pseudo proc: 0x7d2ed5dc
O/S info: user: oracle, term: pts/7, ospid: 19759
OSD pid info: Unix process pid: 19759, image: goblin.forgotten.realms (TNS V1-V3)



(session) sid: 141 trans: (nil), creator: 0x7d2bd820, flag: (41) USR/- BSY/-/-/-/-/-
DID: 0001-0014-00000668, short-term DID: 0000-0000-00000000
txn branch: (nil)
oct: 6, prv: 0, sql: 0x62d01c34, psql: 0x7c20f24c, user: 542/SCOTT
service name: SYS$USERS
O/S info: user: oracle, term: pts/7, ospid: 19758, machine: goblin.forgotten.realms
program: sqlplus@goblin.forgotten.realms (TNS V1-V3)
application name: SQL*Plus, hash value=3669949024
waiting for 'library cache lock' blocking sess=0x(nil) seq=36 wait_time=0 seconds since wait started=11
handle address=62d064dc, lock address=79f88a68, 100*mode+namespace=c9

  • Use the handle address to find information on the object locked:

SO: 0x79f88a68, type: 53, owner: 0x7d3d62d0, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=79f88a68 handle=62d064dc request=S
call pin=(nil) session pin=(nil) hpc=0000 hlc=0000
htl=0x79f88ab4[0x79e71e60,0x79e71e60] htb=0x79e71e60 ssga=0x79e716fc
user=7d3a13b8 session=7d3a13b8 count=0 flags=[0000] savepoint=0xce
LIBRARY OBJECT HANDLE: handle=62d064dc mtx=0x62d06590(0) cdp=0
name=SCOTT.EMPLOYEES

We see the library object lock is being requested in Shared mode (request=S)
Name of the the object is SCOTT.EMPLOYEES
  • Use the 'handle address' to find the process that is holding the lock on  your resource by doing a search on the address within the same tracefile.

PROCESS 18:
----------------------------------------
SO: 0x7d2bcca8, type: 2, owner: (nil), flag: INIT/-/-/0x00
(process) Oracle pid=18, calls cur/top: 0x79f3ab84/0x7d3d5fc8, flag: (0) -
int error: 0, call error: 0, sess error: 0, txn error 0
(post info) last post received: 109 0 4
last post received-location: kslpsr
last process to post me: 7d2b8d94 1 6
last post sent: 0 0 24
last post sent-location: ksasnd
last process posted by me: 7d2b8d94 1 6



SO: 0x75fe8f7c, type: 53, owner: 0x7b751914, flag: INIT/-/-/0x00
LIBRARY OBJECT LOCK: lock=75fe8f7c handle=62d064dc mode=X
call pin=(nil) session pin=(nil) hpc=0000 hlc=0000
htl=0x75fe8fc8[0x79f81790,0x79fc3ef8] htb=0x79f81790 ssga=0x79f8102c
user=7d3988d0 session=7d3988d0 count=1 flags=[0000] savepoint=0x146e
LIBRARY OBJECT HANDLE: handle=62d064dc mtx=0x62d06590(0) cdp=0
name=SCOTT.EMPLOYEES

From the output we can see that the Process 18 (pid)  is holding  an exclusive lock (mode=X) on the object we are trying to access. Using V$PROCESS and V$SESSION we can retrieve the sid, user, terminal, program,... for this process.

The actual statement that was launched by this session is also listed in the tracefile (statements and other library cache objects are preceded by 'name=').


OPatch failed with error code 135

$
0
0
OK, I am in process of upgrading one of our 11.2.0.2 RAC Environment to 11.2.0.3 and as a pre-req I have to install a patch 12539000.

First we need to create OCM Response file which is mandatory so I created the file under "/opt/grid/app/11.2.0/grid/OPatch/ocm/bin" using emocmrsp from the grid home OPatch/ocm/bin folder.

Now, when I try to apply a patch using "opatch auto" it asks me:
"OPatch  is bundled with OCM, Enter the absolute OCM response file path:"

As a response I gave the path "/opt/grid/app/11.2.0/grid/OPatch/ocm/bin" where the response file was created.

Now, opatch comes back saying "apply failed for home"

Looking into the log, I see the following:


Argument(s) Error... Given 'ocmrf' file is a directory and not a file.
Please check the arguments and try again.
 OPatch failed with error code 135

The problem is that when it asks for OCM Response file path, it is actually expecting the file name also in the path like this "/opt/grid/app/11.2.0/grid/OPatch/ocm/bin/ocm.rsp". So, try again with that path including the file name and you will be fine applying a patch...

What I do not understand here is:
emocmrsp command does not asks for the file name and it creates a standard file named "ocm.rsp" so, why is OPatch needed the file name in the path!!!

Anyways, just thought of blogging....

Faster way to get a row count on a huge table...

$
0
0
We all know how to get a row count of a table:
select count(1)from table_name;

What if the table is so huge!!!
Quick way we generally tend to go around to get the count is from user_tables data dictionary NUM_ROWS column value... wait... that wont give you the accurate number of rows!!! meaning that value is updated in that dictionary when the stats were generated...

Gathering stats to get that value populated is an option? depends on how big the table how long that stats gathering takes place.

So, is there any other way to get number of records faster in a table!!!

Yes...

There is a data dictionary named all_tab_modifications. You can read more about this from the link below (from where i learned this):




Basically, once the insert opeartion is done you have to flush the statistics (which is what Oracle does every often) as below:

exec dbms_stats.flush_database_monitoring_info

Once the flush is done you can query all_tab_modifications table for the results:

select dbta.owner||'.'||dbta.table_name tab_name ,dbta.num_rows anlyzd_rows,
       to_char(dbta.last_analyzed,'yymmdd hh24:mi:ss')  last_anlzd,
  nvl(dbta.num_rows,0)+nvl(dtm.inserts,0) - nvl(dtm.deletes,0) tot_rows,
  nvl(dtm.inserts,0)+nvl(dtm.deletes,0)+nvl(dtm.updates,0) chngs,
  nvl(dtm.inserts,0)+nvl(dtm.deletes,0)+nvl(dtm.updates,0)) / greatest(nvl(dbta.num_rows,0),1) pct_c,
  dtm.truncated trn
  from dba_tables dbta
  -- replace below with all_tab_modifications if you need
       left outer join sys.dba_tab_modifications dtm
  on dbta.owner = dtm.table_owner
     and dbta.table_name = dtm.table_name
          and dtm.partition_name is null
 where dbta.table_name ='PERSON'
   and dbta.owner     ='TRAINER'
/

Finding Oracle allocated semaphores in Linux...

$
0
0
As I always say, there is always something to know/learn.

Having some issues with high usage of semaphores in our environment and digging more found this nice utility from Oracle (yeah its been there since 8.1 but today I came to know about it) called "sysresv".

If you have access to metalink then here is the ID#123322.1

BTW, you can still get all semaphores allocated by oracle with a simple command:
ipcs -s |grep oracle --This will list out all semaphores allocated for all instances on the server.

sysresv utility gives the list of semaphores only for the instance that you pointed to...

Once you get the semaphore id (semid) try below to get more info on that semid like process id (pid):
ipcs -si semid

This will give detailed info like below:


Semaphore Array semid=331382805
uid=80   gid=80  cuid=80         cgid=80
mode=0660, access_perms=0660
nsems = 128
otime = Tue Feb  5 16:45:46 2013
ctime = Tue Feb  5 16:45:46 2013
semnum     value      ncount     zcount     pid
0                 1          0             0          1315
1             18380      0             0          1315
2             18703      0             0          1315


From the above try to ps -ef |grep pid and see if this shows any OS process that is related to Oracle (in our case). If ps -ef does not return anything then that is a dead process and time clear that semaphore allocation using ipcrm -s semid.

Here is the info about this nice utility if you do not have metalink access:


SYSRESV Utility [ID 123322.1]

The sysresv utility included with Oracle 8.1.5 and above provides instance
status (and OS resources used) for specified ORACLE_SIDs.  This utility is
especially useful when multiple instances are running.  OS resources can be
removed using this utility if the specified instance is detected to be dead.

This utility may be useful when an instance has crashed or was aborted
and memory and semaphores related to this instance were not cleaned up
automatically.  This utility is also helpful in determining which instance
is running.

The sysresv utility, located in $O_H/bin, can be used from locations other
than $O_H/bin.

Point your environment to the instance of interest before using sysresv.

Usage:
------

sysresv:
usage   : sysresv [-if] [-d ] [-l sid1 ...]
          -i : Prompt before removing ipc resources for each sid
          -f : Remove ipc resources silently, oevrrides -i option
          -d : List ipc resources for each sid if on
          -l sid1 .. : apply sysresv to each sid
Default : sysresv -d on -l $ORACLE_SID
Note    : ipc resources are attempted to be deleted for a
          sid only if there is no currently running instance
          with that sid.

 
Examples:
---------

o  Instance is not running:

   /u02/app/oracle/product/8.1.7> sysresv

   IPC Resources for ORACLE_SID "R817" :
   Shared Memory
   ID              KEY
   No shared memory segments used
   Semaphores:
   ID              KEY
   No semaphore resources used
   Oracle Instance not alive for sid "R817"


o  Instance is running:

   /u03/app/oracle/product/8.1.6> sysresv

   IPC Resources for ORACLE_SID "X816" :
   Shared Memory:
   ID              KEY
   16437           0xe4efa8dc
   Semaphores:
   ID              KEY
   12320802        0x09d48346
   Oracle Instance alive for sid "X816"


o  Attempting to remove memory and semphores using sysresv when Oracle
   detects an instance is running:

   /u03/app/oracle/product/8.1.6> sysresv -f

   IPC Resources for ORACLE_SID "X816" :
   Shared Memory:
   ID              KEY
   16437           0xe4efa8dc
   Semaphores:
   ID              KEY
   12320802        0x09d48346
   Oracle Instance alive for sid "X816"
   SYSRESV-005: Warning
           Instance maybe alive - aborting remove for sid "X816"


o  Removing IPC resources:

   [Sysresv shows memory and semaphores exist but Oracle determines the
    instance is not alive.  Cleanup is needed.]

   /u03/app/oracle/product/8.1.6> sysresv

   IPC Resources for ORACLE_SID "X816" :
   Shared Memory:
   ID              KEY
   16837           0xe4efa8dc
   Semaphores:
   ID              KEY
   12714018        0x09d48346
   Oracle Instance not alive for sid "X816"


o  Removing IPC resources using sysresv:

   /u03/app/oracle/product/8.1.6> sysresv -i

   IPC Resources for ORACLE_SID "X816" :
   Shared Memory
   ID              KEY
   No shared memory segments used
   Semaphores:
   ID              KEY
   No semaphore resources used
   Oracle Instance not alive for sid "X816"
   Remove ipc resources for sid "X816" (y/n)?y
   Done removing ipc resources for sid "X816"
   /u03/app/oracle/product/8.1.6


   Verify the resources were removed:

   /u03/app/oracle/product/8.1.6> sysresv

   IPC Resources for ORACLE_SID "X816" :
   Shared Memory
   ID              KEY
   No shared memory segments used
   Semaphores:
   ID              KEY
   No semaphore resources used
   Oracle Instance not alive for sid "X816"

   
o  If you need to remove memory segments, and Oracle detects the
   instance is alive through sysresv:

   % ipcrm -m

   Where is the memory id shown in the sysresv output.

   Example:
   % ipcrm -m 16437

   If you need to remove semaphores, and Oracle detects the
   instance is alive through sysresv:

   % ipcrm -s

   where is the semaphore id shown in the sysresv output.

   Example:
   % ipcrm -s 12320802


RMAN-12012: multiple records for DISK parallelism found in catalog

$
0
0
While trying to restore (TSPITR) using RMAN Catalog I ran into this wired errors stating while allocating channels...


RMAN> recover tablespace abc123
until time "to_date('19-FEB-2013 00:00:00','DD-MON-YYYY HH24:MI:SS')"
AUXILIARY DESTINATION '/ora05/auxdest';

Starting recover at 20-FEB-13
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/20/2013 16:43:10
RMAN-12010: automatic channel allocation initialization failed
RMAN-12012: multiple records for DISK parallelism found in catalog

RMAN> exit

Doing some research, found the solution to reset config and try again.

SQL> exec dbms_backup_restore.resetconfig;

Now try again and you will have no issues allocating channels...

RMAN TSPITR

$
0
0
Example on using RMAN TSPITR (Tablespace Point-in-Time Recovery):


Login into your RMAN Catalog by setting up your database environment.

rman catalog rman/password@catalogdb target /

RMAN> configure channel 1 device type sbt_tape parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=adm_p,OB2BARLIST=restore_job)';

RMAN> configure channel 2 device type sbt_tape parms 'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=adm_p,OB2BARLIST=restore_job)';

I am configuring the above channels manually as I had issues RMAN allocating channels for AUXILIARY instance...



run {
SET NEWNAME FOR DATAFILE '/ora05/oradata/db1/abc_ts_01.dbf' TO '/ora03/oradata/db1/abc_ts_01.dbf'; --here I am changing the default location of a datafile to a new location
recover tablespace abc_ts until time "to_date('16-FEB-2013 06:41:00','DD-MON-YYYY HH24:MI:SS')" AUXILIARY DESTINATION '/ora05_1/auxdest'; --this is optional but I personally wanted to give a storage to RMAN for its dynamic Auxiliary instance.
}

The above will restore your tablespace until the time specified.

Once the above is successful, you will notice that tablespace is OFFLINE as Oracle wants you to take a backup of that tablespace and lets you bring that tablespace online.

So, take a backup:

RMAN> backup tablespace abc_ts; --or take a backup from your backup software...

and bring it online:

RMAN> sql 'alter tablespace abc_ts online';

ORA-19550: cannot use backup/restore functions while using dispatcher

$
0
0
Your RMAN connection is going thru SHARED SERVER Mode.
Make a TNS entry with DEDICATED Mode ( (server=dedicated) ) and try again.


19550, 00000, "cannot use backup/restore functions while using dispatcher"
// *Cause:  Attempted to use backup/restore functions while connected to the
//          dispatcher in a shared server.
//          This is not allowed because the device that is
//          used for backup and restore must remain allocated to a single
//          process.
// *Action: Connect directly to the instance then re-execute the backup or
//          restore function.

TNS-04404: no error caused by: oracle.net.config.ConfigException: TNS-04414: File error

$
0
0
Got this error while trying to create a database using DBCA.

TNS-04404: no error caused by: oracle.net.config.ConfigException: TNS-04414: File error caused by: TNS-04612

Nothing to worry or panic. Just check your tnsnames.ora file for entries and am pretty sure it will have some syntax errors like missing closed parenthesis etc., 

ORACLE error 29308 encountered

$
0
0
Got this error while doing TSPITR:


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Export done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported

About to export Tablespace Point-in-time Recovery objects...
EXP-00008: ORACLE error 29308 encountered
ORA-29308: view TS_PITR_CHECK failure
ORA-06512: at "SYS.DBMS_PITR", line 889
ORA-06512: at line 1
EXP-00000: Export terminated unsuccessfully
host command complete

Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/14/2013 14:08:50
RMAN-03015: error occurred in stored script Memory Script
RMAN-06135: error executing host command: Additional information: 256
Additional information: 11

RMAN>



Basically what it is telling is there are some objects in the tablespace that are dependent on some other tablespace which is not in the TSPITR list.

Running the following query shows me that there are some indexes those belong in SYSTEM.

TSPITR Check Query:
SELECT * 
FROM SYS.TS_PITR_CHECK 
WHERE (
        TS1_NAME IN ('DATA_8K') 
        AND TS2_NAME NOT IN ('DATA_8K')
      )
OR    (
        TS1_NAME NOT IN ('DATA_8K') 
        AND TS2_NAME IN ('DATA_8K')
      ); 

But that is not true because if I run dbms_tts.transport_set_check it wont show any violations:

begin
 sys.dbms_tts.transport_set_check('DATA_8K',TRUE,TRUE);
end;

select * from sys.transport_set_violations; -- returns no rows means DATA_8K tablespace objects are all self contained...

So, what is the issue with RMAN TSPITR!!!!

Its a bug identified and the issue is fixed in 11g. RMAN TSPITR has issues when IOT (Index Organized Tables) are present in the tablespace.

Bug#6620517: DO TSPITR SUPPORT IOT IN 10.2 Database.


Bug Attributes


B - Defect11.2
2 - Severe Loss of Service10.2.0.3.0
80 - Development to QA/Fix Delivered Internal268 - z*OBSOLETE: Microsoft Windows Server 2003 R2 (64-bit AMD64 and Intel EM64T)
Nov 9, 2007
Sep 15, 2011N/A
10.2.0.3.0Generic
Oracle

Related Products


Oracle Database ProductsOracle Database
Oracle Database5 - Oracle Database - Enterprise Edition

Viewing all 112 articles
Browse latest View live