Archive

Author Archive

AOUG Experts Forum 13.10.2011: Storage Technologies for Oracle Database Systems and Best Practices

October 14th, 2011 Matthias Pölzinger No comments

InITSo was invited to hold a lecture on Oracle ACFS / Oracle Cloud File System at the Austrian Oracle User Group’s Experts Forum on Storage Technologies for Oracle Database Systems – Best Practices (“AOUG Expertentreff: Storage Technologien Oracle Datenbanksystem – Best Practices“).

If you are interested in this topic, you can download an English or German version of the presentation via the following links:

 

Linux: How to query the WWPN of Fibre Channel HBA ports

October 8th, 2011 Matthias Pölzinger No comments

Problem description:

The WWPNs (World Wide Port Numbers) of your HBAs are required e.g. in order to configure Fibre Channel LUN Access. You want to use Linux instruments to access this information in order to avoid rebooting the servers and access the information from BIOS or any other utility.

 
Problem resolution:

Current Linux kernel versions provide relevant information about FC HBAs through the sysfs Filesystem mounted at /sys. The location for detailed information depends on your Linux OS version. For CentOS / Red Hat Enterprise Linux / Oracle Linux 5 the path is /sys/class/scsi_host/host*/device/fc_host*/, but for Version 6 it changed to /sys/class/fc_host/host*/ which makes it easier to separate between SCSI controllers and FC HBAs.

Example for Centos / RHEL / Oracle Linux 5:

[root@initso01 ~]# ls -al /sys/class/scsi_host/host5/device/fc_host:host5/
total 0
drwxr-xr-x 4 root root    0 Oct  5 17:03 .
drwxr-xr-x 6 root root    0 Oct  5 17:03 ..
lrwxrwxrwx 1 root root    0 Oct  5 17:03 device -> ../../../devices/pci0000:00/0000:00:03.0/0000:15:00.0/host5
-r--r--r-- 1 root root 4096 Oct  7 10:07 fabric_name
--w------- 1 root root 4096 Oct  7 10:07 issue_lip
-r--r--r-- 1 root root 4096 Oct  7 10:07 max_npiv_vports
-r--r--r-- 1 root root 4096 Oct  7 10:07 node_name
-r--r--r-- 1 root root 4096 Oct  7 10:07 npiv_vports_inuse
-r--r--r-- 1 root root 4096 Oct  7 10:07 port_id
-r--r--r-- 1 root root 4096 Oct  7 10:07 port_name
-r--r--r-- 1 root root 4096 Oct  7 10:07 port_state
-r--r--r-- 1 root root 4096 Oct  7 10:07 port_type
drwxr-xr-x 2 root root    0 Oct  7 10:07 power
-r--r--r-- 1 root root 4096 Oct  7 10:07 speed
drwxr-xr-x 2 root root    0 Oct  7 10:07 statistics
lrwxrwxrwx 1 root root    0 Oct  5 17:04 subsystem -> ../../fc_host
-r--r--r-- 1 root root 4096 Oct  7 10:07 supported_classes
-r--r--r-- 1 root root 4096 Oct  7 10:07 supported_speeds
-r--r--r-- 1 root root 4096 Oct  7 10:07 symbolic_name
-rw-r--r-- 1 root root 4096 Oct  7 10:07 system_hostname
-rw-r--r-- 1 root root 4096 Oct  7 10:07 tgtid_bind_type
-rw-r--r-- 1 root root 4096 Oct  5 17:03 uevent
--w------- 1 root root 4096 Oct  7 10:07 vport_create
--w------- 1 root root 4096 Oct  7 10:07 vport_delete
[root@initso01 ~]#

 
These fc_host directories can be used to to determine the port speed:

[root@initso01 ~]# for i in `ls /sys/class/scsi_host/host*/device/fc_host*/speed`; do echo $i; echo "==============="; cat $i; done
/sys/class/scsi_host/host5/device/fc_host:host5/speed
===============
unknown
/sys/class/scsi_host/host6/device/fc_host:host6/speed
===============
4 Gbit
/sys/class/scsi_host/host7/device/fc_host:host7/speed
===============
unknown
/sys/class/scsi_host/host8/device/fc_host:host8/speed
===============
4 Gbit
[root@initso01 ~]#

 
or to query the WWPN of each port:

[root@initso01 ~]# for i in `ls /sys/class/scsi_host/host*/device/fc_host*/port_name`; do echo $i; echo "==============="; cat $i; done
/sys/class/scsi_host/host5/device/fc_host:host5/port_name
===============
0x21000024ff2e30ce
/sys/class/scsi_host/host6/device/fc_host:host6/port_name
===============
0x21000024ff2e30cf
/sys/class/scsi_host/host7/device/fc_host:host7/port_name
===============
0x21000024ff2e30cc
/sys/class/scsi_host/host8/device/fc_host:host8/port_name
===============
0x21000024ff2e30cd
[root@initso01 ~]#

 
Just omit the hexidecimal prefix “0x” and you have the WWPN for each Fibre Channel HBA port.

 
Example for Centos / RHEL / Oracle Linux 6:

[root@initso02 ~]# ls -al /sys/class/fc_host/host1/
total 0
drwxr-xr-x. 4 root root    0 Aug 11 07:11 .
drwxr-xr-x. 3 root root    0 Aug 11 07:11 ..
-rw-r--r--. 1 root root 4096 Aug 13 10:29 dev_loss_tmo
lrwxrwxrwx. 1 root root    0 Aug 13 10:29 device -> ../../../host1
-r--r--r--. 1 root root 4096 Aug 13 10:29 fabric_name
--w-------. 1 root root 4096 Aug 13 10:29 issue_lip
-r--r--r--. 1 root root 4096 Aug 13 10:29 max_npiv_vports
-r--r--r--. 1 root root 4096 Aug 13 10:29 node_name
-r--r--r--. 1 root root 4096 Aug 13 10:29 npiv_vports_inuse
-r--r--r--. 1 root root 4096 Aug 13 10:29 port_id
-r--r--r--. 1 root root 4096 Aug 13 10:14 port_name
-r--r--r--. 1 root root 4096 Aug 13 10:29 port_state
-r--r--r--. 1 root root 4096 Aug 13 10:29 port_type
drwxr-xr-x. 2 root root    0 Aug 13 10:29 power
-r--r--r--. 1 root root 4096 Aug 13 10:29 speed
drwxr-xr-x. 2 root root    0 Aug 13 10:29 statistics
lrwxrwxrwx. 1 root root    0 Aug 11 07:11 subsystem -> ../../../../../../../class/fc_host
-r--r--r--. 1 root root 4096 Aug 13 10:29 supported_classes
-r--r--r--. 1 root root 4096 Aug 13 10:29 supported_speeds
-r--r--r--. 1 root root 4096 Aug 13 10:29 symbolic_name
-rw-r--r--. 1 root root 4096 Aug 13 10:29 system_hostname
-rw-r--r--. 1 root root 4096 Aug 13 10:29 tgtid_bind_type
-rw-r--r--. 1 root root 4096 Aug 11 07:11 uevent
--w-------. 1 root root 4096 Aug 13 10:29 vport_create
--w-------. 1 root root 4096 Aug 13 10:29 vport_delete
[root@initso02 ~]#

 
As with Version 5 these fc_host directories can be used to to determine the port speed:

[root@initso02 ~]# for i in `ls /sys/class/fc_host/host*/speed`; do echo $i; echo "==============="; cat $i; done
/sys/class/fc_host/host1/speed
===============
4 Gbit
/sys/class/fc_host/host2/speed
===============
4 Gbit
[root@initso02 ~]#

 
or to query the WWPN of each port:

[root@initso02 ~]# for i in `ls /sys/class/fc_host/host*/port_name`; do echo $i; echo "==============="; cat $i; done
/sys/class/fc_host/host1/port_name
===============
0x24000024ee09a545
/sys/class/fc_host/host2/port_name
===============
0x24000024ee09a578
[root@initso02 ~]#

 
Just omit the hexidecimal prefix "0x" as with Version 5 and you have the WWPN for each Fibre Channel HBA port.

NetApp: “No FCP Target Adapters are present in this system.” when trying to perform FC configuration

September 24th, 2011 Matthias Pölzinger No comments

Problem description:

You have installed FC modules in your NetApp storage system and want to configure Fibre Channel for LUN provisioning, but the fcp command always responds with “No FCP Target Adapters are present in this system.”:

netapp01> fcp config
fcp: No FCP Target Adapters are present in this system.
netapp01> fcp status
fcp: No FCP Target Adapters are present in this system.
netapp01>

 
Altough the “storage show adapter” command correctly displays your FC Host Adapters:

netapp01> storage show adapter
 
Slot:            0a
Description:     Fibre Channel Host Adapter 0a (QLogic 2432 rev. 2)
Firmware Rev:    4.4.0
FC Node Name:    9:00a:098088:25dxyz
FC Packet Size:  2048
Link Data Rate:  4 Gbit
SRAM Parity:     Yes
External GBIC:   No
State:           Disabled
In Use:          No
Redundant:       Yes
 
Slot:            0b
Description:     Fibre Channel Host Adapter 0b (QLogic 2432 rev. 2)
Firmware Rev:    4.4.0
FC Node Name:    9:00a:098188:25dxyz
FC Packet Size:  2048
Link Data Rate:  4 Gbit
SRAM Parity:     Yes
External GBIC:   No
State:           Disabled
In Use:          No
Redundant:       Yes
 
Slot:            0c
Description:     SAS Host Adapter 0c (LSI Logic 1068E rev. B2)
Firmware Rev:    1.26.03.00
Base WWN:        a:060xyz:2000888:00
State:           Enabled
In Use:          Yes
Redundant:       No
Phy State:       [0] Enabled, 3.0Gb/s (9)
                 [1] Enabled, 3.0Gb/s (9)
                 [2] Enabled, 3.0Gb/s (9)
                 [3] Enabled, 3.0Gb/s (9)
Slot:            0e
Description:     IDE Host Adapter 0e
netapp01>

 
Cause:

Newly installed or already installed FC modules are always per default in the so called “initiator mode”:

netapp01> fcadmin config             
 
                  Local   
Adapter Type      State                  Status
---------------------------------------------------
  0a   initiator  CONFIGURED.            online
  0b   initiator  CONFIGURED.            online
 
netapp01>

 
If you want to provide LUNs via Fibre Channel, you have to switch to “target mode”.

 
Problem resolution:

You can change the mode of an adapter via the “fcadmin” command. In this example we will switch both adapters to “target mode”:

netapp01> fcadmin config             
 
                  Local   
Adapter Type      State                  Status
---------------------------------------------------
  0a   initiator  CONFIGURED.            online
  0b   initiator  CONFIGURED.            online
 
netapp01> fcadmin config -d 0a
Mon Sep 19 15:59:38 CEST [netapp01: fci.adapter.offlining:info]: Offlining Fibre Channel adapter 0a.
Mon Sep 19 15:59:38 CEST [netapp01: fci.adapter.offline:info]: Fibre Channel adapter 0a is now offline.
 
netapp01> fcadmin config -t target 0a
Mon Sep 19 15:59:54 CEST [netapp01: fci.config.state:info]: Fibre channel initiator adapter 0a is in the PENDING (target) state.
A reboot is required for the new adapter configuration to take effect.
netapp01>
netapp01> fcadmin config -d 0b
Mon Sep 19 16:00:00 CEST [netapp01: fci.adapter.offlining:info]: Offlining Fibre Channel adapter 0b.
Mon Sep 19 16:00:01 CEST [netapp01: fci.adapter.offline:info]: Fibre Channel adapter 0b is now offline.
 
netapp01> fcadmin config -t target 0b
Mon Sep 19 16:00:40 CEST [netapp01: fci.config.state:info]: Fibre channel initiator adapter 0b is in the PENDING (target) state.
A reboot is required for the new adapter configuration to take effect.
netapp01>
netapp01> fcadmin config             
 
                  Local   
Adapter Type      State                  Status
---------------------------------------------------
  0a   initiator  PENDING (target)       offline
  0b   initiator  PENDING (target)       offline
 
netapp01>

 
In order to complete the configuration, you will have to reboot. After a reboot adapters will be in target mode and you will be able to configure Fibre Channel for storing your servers data.

Categories: NetApp, Storage Tags:

Oracle: SQL*Plus displays “No errors.”

August 18th, 2011 Matthias Pölzinger No comments

Problem description:

Your are compiling an object, but it fails with an error. If you are trying to check the error message(s) for the compilation, SQL*Plus displays “No errors.”:

SQL> ALTER VIEW VIEWNAME compile;
 
Warning: VIEW altered WITH compilation errors.
 
SQL> SHOW errors
No errors.
SQL>

 
Problem resolution:

“show errors” only displays the last error message generated. In some cases (like above) no error messsage will be displayed. In order to force the display of error messages for a specific object, make use of the full functionality of “show errors” and specify the type and name of your object:

SQL> SHOW errors VIEW VIEWNAME
Errors FOR VIEW VIEWNAME:
 
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      ORA-01730: invalid NUMBER OF COLUMN names specified
SQL>

 
You can also use this method to display errors for other objects and object types:

SHOW ERR[ORS] [{FUNCTION | PROCEDURE | PACKAGE | PACKAGE BODY | TRIGGER |
                VIEW | TYPE | TYPE BODY | DIMENSION | JAVA CLASS} [schema.]name]
Categories: Oracle, SQLPlus, Utilities Tags:

Oracle: How to (comfortably) disable Oracle Scheduler job execution

Problem description:

You want to disable the execution of all Oracle Scheduler jobs by a simple command. With Oracle Jobs (pre-Oracle-Scheduler-era) you where able to disable any job execution by simply setting the job_queue_processes parameters to 0:

* Disabling job execution:
 
ALTER SYSTEM SET job_queue_processes = 0;
 
* Enabling job execution (job_queue_processes > 0, e.g. 10):
 
ALTER SYSTEM SET job_queue_processes = 10;

Oracle Scheduler has no instance parameter which defines the number of job processes.

 
Problem resolution:

Although there is no entry in the documentation for disabling the Oracle Scheduler, you can stop the Scheduler job execution by using an undocumented attribute called “SCHEDULER_DISABLED” when executing DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE:

  • Disable Oracle Scheduler job execution
    SQL> EXEC dbms_scheduler.set_scheduler_attribute('SCHEDULER_DISABLED','TRUE');
     
    PL/SQL PROCEDURE successfully completed.
     
    SQL>

     

  • Disable Oracle Scheduler job execution
    SQL> EXEC dbms_scheduler.set_scheduler_attribute('SCHEDULER_DISABLED','FALSE');
     
    PL/SQL PROCEDURE successfully completed.
     
    SQL>

The current Scheduler job execution state can be checked by querying the Data Dictionary view DBA_SCHEDULER_GLOBAL_ATTRIBUTE:

  • Example for a disabled Scheduler
    SQL> col VALUE FOR a40
    SQL> SELECT * FROM dba_scheduler_global_attribute WHERE attribute_name = 'SCHEDULER_DISABLED';
     
    ATTRIBUTE_NAME		       VALUE
    ------------------------------ ----------------------------------------
    SCHEDULER_DISABLED	       TRUE
     
    SQL>

     

  • Example for an enabled Scheduler
    SQL> col VALUE FOR a40
    SQL> SELECT * FROM dba_scheduler_global_attribute WHERE attribute_name = 'SCHEDULER_DISABLED';
     
    no ROWS selected
     
    SQL>

 
Notes:

Please be informed that the usage of DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE(‘SCHEDULER_DISABLED’, ‘TRUE|FALSE’) is currently undocumented and therefore “SCHEDULER_DISABLED” is not a supported scheduler attribute. It should not have a detrimental effect on your system(s), but just in case, as it is with unsupported/undocumented features, we take no responsibility for any damages incurred from the use of the information contained herein.

Categories: Oracle, Scheduler, Undocumented Tags:

Oracle: How to compile strmmon (Streams Monitoring Utility) on UNIX systems

The Streams Monitoring Utility strmmon is a very useful utility for monitoring current Streams activity. You can use it to obtain the current figures for capture, propagation and apply activity in vmstat-style.

To obtain the latest version of the utility use the following link to download it in a zip-file format: strmmon.zip

Compilation on systems prior 10gR2:

  1. Download the latest version
  2. extract the version on your database server in a strmmon directory
  3. make sure that you have set ORACLE_HOME and LD_LIBRARY_PATH correctly
  4. compile the binary inside the directory strmmon using “make -f strmmon.mk strmmon”

Compilation on 10gR2 systems:

  1. Download the latest version
  2. extract the version on your database server in a strmmon directory
  3. copy the files strmmon.c and strmmon.html to your $ORACLE_HOME/rdbms/demo directory
  4. cd $ORACLE_HOME/rdbms/demo
  5. make -f rdbms_demo.mk strmmon

For Oracle Database systems version 11g onwards, strmmon has been replaced by Oracle Streams performance/diagnostic related dictionary views and the DBMS_STREAMS_ADVISOR_ADM PL/SQL Package.

Example on 10.2.0.1:

oracle@oracle01:~$ mkdir strmmon
oracle@oracle01:~$ cd strmmon/
oracle@oracle01:~/strmmon$ mv /tmp/strmmon.zip .
oracle@oracle01:~/strmmon$ unzip strmmon.zip
Archive:  strmmon.zip
inflating: strmmon.mk
inflating: strmmon.htm
inflating: strmmon.c
oracle@oracle01:~/strmmon$ cp strmmon.c $ORACLE_HOME/rdbms/demo
oracle@oracle01:~/strmmon$ cp strmmon.htm $ORACLE_HOME/rdbms/demo
oracle@oracle01:~/strmmon$ cd $ORACLE_HOME/rdbms/demo
oracle@oracle01:/u01/app/oracle/product/10.2.0/db_1/rdbms/demo$ make -f demo_rdbms.mk strmmon
make -f /u01/app/oracle/product/10.2.0/db_1/rdbms/demo/demo_rdbms.mk build EXE=strmmon OBJS=strmmon.o
make[1]: Entering directory `/u01/app/oracle/product/10.2.0/db_1/rdbms/demo'
/usr/bin/gcc -c -I/u01/app/oracle/product/10.2.0/db_1/rdbms/demo -I/u01/app/oracle/product/10.2.0/db_1/rdbms/public -I/u01/app/oracle/product/10.2.0/db_1/plsql/public -I/u01/app/oracle/product/10.2.0/db_1/network/public -I/u01/app/oracle/product/10.2.0/db_1/precomp/public strmmon.c
/usr/bin/gcc -L/u01/app/oracle/product/10.2.0/db_1/lib/ -L/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ -o strmmon strmmon.o -lclntsh   `cat /u01/app/oracle/product/10.2.0/db_1/lib/sysliblist` -ldl -lm
make[1]: Leaving directory `/u01/app/oracle/product/10.2.0/db_1/rdbms/demo'
oracle@oracle01:/u01/app/oracle/product/10.2.0/db_1/rdbms/demo$

Execution example:

oracle@oracle01:/u01/app/oracle/product/10.2.0/db_1/rdbms/demo$ ./strmmon
Usage: strmmon -interval <seconds> -count <number> [-user <user name>]
[-passw <password>] [-dbname <database name>] [-sysdba]
[-long]
 
oracle@oracle01:/u01/app/oracle/product/10.2.0/db_1/rdbms/demo$ ./strmmon -interval 1 -count 5 -user strmadmin -passw SOME_PW -dbname db.initso.at
 
STREAMS Monitor, v 2.6  Copyright Oracle Corp. 2002, 2005.
Interval = 1, Count=5
 
Logon=strmadmin@db.initso.at ORACLE 10.2.0.1.0
 
Streams Pool Size = 132M
 
NET: <client bytes per sec> <dblink bytes per sec>
Cxxx: <lcrs captured per sec> <lcrs enqueued per sec> <capture latency>
PRxx: <messages received per sec>
Qx  : <msgs enqueued per sec> <msgs spilled per sec>
PSxx: <lcrs propagated per sec> <bytes propaged per sec>
Axxx: <lcrs applied per sec> <txns applied per sec> <dequeue latency>
<F>: flow control in effect
<B>: potential bottleneck
AR: apply reader
AS(n): n number of apply server
<x%I x%F x%xx>: <idle wait events percentage> <flow control wait events percentage> <other wait event percentage and name>
xx->: database instance name
 
2009-01-15 16:14:18 || orcl-> |      |
2009-01-15 16:14:19 || orcl-> | NET 16K 0 | <B> C002 0 0 0sec <97%I 0%F ->  |  -  C001 6 0 0sec <97%I 0%F ->  | Q54516 0 0 | PS01 0 0 0 | Q53876 0 0 | PS02 0 0 0
2009-01-15 16:14:20 || orcl-> | NET 13K 0 | <B> C002 0 0 0sec <97%I 0%F ->  |  -  C001 0 0 0sec <97%I 0%F ->  | Q54516 0 0 | PS01 0 0 0 | Q53876 0 0 | PS02 0 0 0
2009-01-15 16:14:21 || orcl-> | NET 13K 0 |  -  C002 6 0 3sec <100%I 0%F ->  |  -  C001 0 0 0sec <97%I 0%F ->  | Q54516 0 0 | PS01 0 0 0 | Q53876 0 0 | PS02 0 0 0
2009-01-15 16:14:23 || orcl-> | NET 6K 0 |  -  C002 0 0 3sec <48%I 0%F ->  |  -  C001 0 0 0sec <48%I 0%F ->  | Q54516 0 0 | PS01 0 0 0 | Q53876 0 0 | PS02 0 0 0
oracle@oracle01:/u01/app/oracle/product/10.2.0/db_1/rdbms/demo$
Categories: Oracle, Streams, STRMMON, Utilities Tags:

Oracle: How to easily display the execution plan of a statement located in the shared pool (command line style)

Problem description:

You want to review the execution plan of a statement currently or previously executed by a session and Oracle Enterprise Manager is not use. Querying V$SQL_PLAN would give you the requested information, but not quiet comfortable.

 
Problem resolution:

As with “EXPLAIN PLAN” generated execution plans, you can use DBMS_XPLAN in order to display the execution plan for a statement in the shared pool. To be more specific, the function DISPLAY_CURSOR will provide you the information by passing the sql_id and cursor child number of the statement in concern:

DBMS_XPLAN.DISPLAY_CURSOR(
   sql_id        IN  VARCHAR2  DEFAULT  NULL,
   child_number  IN  NUMBER    DEFAULT  NULL, 
   format        IN  VARCHAR2  DEFAULT  'TYPICAL');

In addition DBMS_XPLAN.DISPLAY_CURSOR can provide you various plan statistics such as I/O, memory and timing by specifying the format:

  • BASIC: Displays the minimum information in the plan—the operation ID, the operation name and its option.
  • TYPICAL: This is the default. Displays the most relevant information in the plan (operation id, name and option, #rows, #bytes and optimizer cost). Pruning, parallel and predicate information are only displayed when applicable. Excludes only PROJECTION, ALIAS and REMOTE SQL information (see below).
  • SERIAL: Like TYPICAL except that the parallel information is not displayed, even if the plan executes in parallel.
  • ALL: Maximum user level. Includes information displayed with the TYPICAL level with additional information (PROJECTION, ALIAS and information about REMOTE SQL if the operation is distributed).

In addition following keywords can be added to above standard formats in order to customize the output. These keywords must be separated by a comma or a space:

  • ROWS – if relevant, shows the number of rows estimated by the optimizer
  • BYTES – if relevant, shows the number of bytes estimated by the optimizer
  • COST – if relevant, shows optimizer cost information
  • PARTITION – if relevant, shows partition pruning information
  • PARALLEL – if relevant, shows PX information (distribution method and table queue information)
  • PREDICATE – if relevant, shows the predicate section
  • PROJECTION -if relevant, shows the projection section
  • ALIAS – if relevant, shows the “Query Block Name / Object Alias” section
  • REMOTE – if relevant, shows the information for distributed query (for example, remote from serial distribution and remote SQL)
  • NOTE – if relevant, shows the note section of the explain plan
  • IOSTATS – assuming that basic plan statistics are collected when SQL statements are executed (either by using the gather_plan_statistics hint or by setting the parameter statistics_level to ALL), this format will show IO statistics for ALL (or only for the LAST as shown below) executions of the cursor.
  • MEMSTATS – Assuming that PGA memory management is enabled (that is, pga_aggregate_target parameter is set to a non 0 value), this format allows to display memory management statistics (for example, execution mode of the operator, how much memory was used, number of bytes spilled to disk, and so on). These statistics only apply to memory intensive operations like hash-joins, sort or some bitmap operators.
  • ALLSTATS – A shortcut for ‘IOSTATS MEMSTATS’
  • LAST – By default, plan statistics are shown for all executions of the cursor. The keyword LAST can be specified to see only the statistics for the last execution.

 
Examples:

  • Display the execution for your the last executed statement of your session

    SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor);
     
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID	dt0hqkzcdq5ny, child NUMBER 1
    -------------------------------------
    SELECT * FROM TABLE(dbms_xplan.display_cursor)
     
    Plan hash VALUE: 3713220770
     
    ----------------------------------------------------------------------------------------------------
    | Id  | Operation			  | Name	   | ROWS  | Bytes | Cost (%CPU)| TIME	   |
    ----------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT		  |		   |	   |	   |	24 (100)|	   |
    |   1 |  COLLECTION ITERATOR PICKLER FETCH| DISPLAY_CURSOR |	 4 |	 8 |	24   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------
     
    Note
    -----
       - cardinality feedback used FOR this statement
     
     
    17 ROWS selected.
     
    SQL>

     

  • Display the execution plan for a specific statement executed by another session:

    SQL> SELECT sid, sql_id, sql_child_number FROM v$session WHERE sid = 1934;
     
           SID SQL_ID	 SQL_CHILD_NUMBER
    ---------- ------------- ----------------
          1934 2rk5134pp7s3g		1
     
    SQL> 
    SQL> SELECT * FROM TABLE(dbms_xplan.display_cursor('2rk5134pp7s3g', 1));
     
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID	2rk5134pp7s3g, child NUMBER 1
    -------------------------------------
    UPDATE myschema.bycicle SET comment = :comment
    WHERE id = :id
     
    Plan hash VALUE: 960803932
     
    -------------------------------------------------------------------------------------
    | Id  | Operation	   | Name	    | ROWS  | Bytes | Cost (%CPU)| TIME     |
    -------------------------------------------------------------------------------------
    |   0 | UPDATE STATEMENT   |		    |	    |	    |	  1 (100)|	    |
    |   1 |  UPDATE 	   | BYCICLE	    |	    |	    |		 |	    |
    |*  2 |   INDEX UNIQUE SCAN| BYCICLE#ID     |	  1 |	167 |	  1   (0)| 00:00:01 |
    -------------------------------------------------------------------------------------
     
    Predicate Information (IDENTIFIED BY operation id):
    ---------------------------------------------------
     
       2 - access("ID"=:ID)
     
     
    20 ROWS selected.
     
    SQL>
  • Display execution plan for all children of a specific SQL_ID:

    SELECT * FROM TABLE(dbms_xplan.display_cursor('2rk5134pp7s3g'));

 
References:

Categories: Oracle, SQLPlus, Tuning Tags:

Oracle ASM: $ORACLE_HOME/rdbms/audit keeps increasing in total size and number of files

Problem description:

The rdbms/audit directory of your Grid Infrastructure is increasing permanently in number of files and total size:

[grid@rac01 ~]$ du -hs $ORACLE_HOME/rdbms/audit
1151M	/u01/app/grid/11.2.0/grid/rdbms/audit
[grid@rac01 ~]$ 
[grid@rac01 ~]$ cd $ORACLE_HOME/rdbms/audit
[grid@rac01 audit]$ 
[grid@rac01 audit]$ ls -l | wc -l
1112896
[grid@rac01 audit]$

 
Permanent increase in number of files and directory size can cause the file system to run out of free space and may also have performance impact on your ASM instance.

 
Cause:

Audit files are created by every connection as user sys. In a Real Application Cluster environment with Grid Control in place, this might become a problem (although you might want to store this information for a limited time due to security compliance reasons).

Example of an ASM .aud-file:

[grid@rac01 audit]$ cat +asm1_ora_9981_2.aud
Audit file /u01/app/grid/11.2.0/grid/rdbms/audit/+asm1_ora_9981_2.aud
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
ORACLE_HOME = /u01/app/grid/11.2.0/grid
System name:	Linux
Node name:	rac01.initso.at
Release:	2.6.18-194.el5
Version:	#1 SMP Mon Mar 29 22:10:29 EDT 2010
Machine:	x86_64
Instance name: +ASM1
Redo thread mounted by this instance: 0 <none>
Oracle process number: 32
Unix process pid: 9981, image: oracle@rac01.initso.at (TNS V1-V3)
 
Tue Jul  5 12:12:06 2011 +02:00
LENGTH : '144'
ACTION :[7] 'CONNECT'
DATABASE USER:[1] '/'
PRIVILEGE :[6] 'SYSDBA'
CLIENT USER:[6] 'oracle'
CLIENT TERMINAL:[0] ''
STATUS:[1] '0'
DBID:[0] ''
 
[grid@rac01 audit]$

 
Workaround:

Old files can be deleted without any impact. Each SYS connection creates a new audit file. Old aud-files should not be open by any Oracle ASM process.

In order to cleanup old files you might want to use one or both of the following methods:

  • Manual cleanup

    You can cleanup aud-files manually by running a find command similar to the following:

    [grid@rac01 audit]$ find /u01/app/grid/11.2.0/grid/rdbms/audit -maxdepth 1 -name '*.aud' -mtime +30 -delete -print
    /u01/app/grid/11.2.0/grid/rdbms/audit/+asm1_ora_24456_2.aud
    ...
    ...
    /u01/app/grid/11.2.0/grid/rdbms/audit/+asm1_ora_9006_1.aud
    [grid@rac01 audit]$

     

  • Automatic cleanup after 30 days

    Create a cronjob similar to the following by using “crontab -e” as the Grid Infrastructure user (e.g. grid):

    [grid@rac01 ~]$ crontab -l
    # Daily cleanup job for Oracle ASM aud-files not modified in the last 30 days
    30 0 * * * /usr/bin/find /u01/app/grid/11.2.0/grid/rdbms/audit -maxdepth 1 -name '*.aud' -mtime +30 -delete >/dev/null 2>&1
    [grid@rac01 ~]$

Oracle ACFS: How to check if ACFS is supported with the kernel currently in use or gather other ACFS driver related information

Description:

You want to check if the ACFS driver can be used with the kernel currently in use. In addition you might want to gather other ACFS driver related information like if it is installed, loaded or which version is used.

 
Commands:

The acfsdriverstate command enables us to gather ACFS driver related information (especially if ACFS is supported with the kernel in use). This binary is part of the Oracle Grid Infrastructure and can be executed as Grid Infrastructure user (e.g. grid) or root.

The following information can be gathered:

  • If ACFS can be used with the kernel currently in use:
    [grid@rac01 bin]$ $ORACLE_HOME/bin/acfsdriverstate -orahome $ORACLE_HOME supported
    ACFS-9200: Supported
    [grid@rac01 bin]$

     

  • If ACFS driver is installed:
    [grid@rac01 bin]$ $ORACLE_HOME/bin/acfsdriverstate -orahome $ORACLE_HOME installed
    ACFS-9203: true
    [grid@rac01 bin]$

     

  • If ACFS driver is loaded:
    [grid@rac01 bin]$ $ORACLE_HOME/bin/acfsdriverstate -orahome $ORACLE_HOME loaded
    ACFS-9204: false
    [grid@rac01 bin]$

     

  • Version of ACFS driver:
    [grid@rac01 bin]$ $ORACLE_HOME/bin/acfsdriverstate -orahome $ORACLE_HOME version
    ACFS-9325:     Driver OS kernel version = 2.6.18-8.el5(x86_64).
    ACFS-9326:     Driver Oracle version = 100804.1.
    [grid@rac01 bin]$

     

Oracle Character Scanner: csscan is 0 (zero) bytes in size on Solaris SPARC

Problem description:

You are trying to perform a character set scan on Solaris (SPARC), but the binary is exiting immediately:

oracle@ora01 $ cd $ORACLE_HOME/bin
oracle@ora01 $ ./csscan help=y
oracle@ora01 $ echo $?
0
oracle@ora01 $

 
When checking the executable, you’ll see a size of 0 bytes:

oracle@solaris01 $ ls -l /oracle/app/oracle/product/10.1.0/db_1/bin/csscan
-rwxr-xr-x   1 oracle   oinstall       0 Nov  9  2005 /oracle/app/oracle/product/10.1.0/db_1/bin/csscan
oracle@solaris01 $

 
Cause:

You are on Sun Solaris SPARC and have applied the Oracle Patch Set 10.1.0.5. Due to an internal unpublished Oracle bug (5051614), csscan related binaries are 0 bytes in size:

oracle@solaris01 $ cd $ORACLE_HOME/bin
oracle@solaris01 $ ls -l csscan lxchknlb lxegen lxinst
-rwxr-xr-x   1 oracle   oinstall       0 Nov  9  2005 csscan
-rwxr-xr-x   1 oracle   oinstall       0 Nov  9  2005 lxchknlb
-rwxr-xr-x   1 oracle   oinstall       0 Nov  9  2005 lxegen
-rwxr-xr-x   1 oracle   oinstall       0 Nov  9  2005 lxinst
oracle@solaris01 $

 
Problem resolution:

Download Oracle Patch 5051614 and copy/move the contained binaries (csscan, lxchknlb, lxegen and lxinst) to the $ORACLE_HOME/bin directory:

oracle@solaris01 $ pwd
/home/oracle/Patch5051614
oracle@solaris01 $ 
oracle@solaris01 $ unzip p5051614_10105_SOLARIS64.zip 
Archive:  p5051614_10105_SOLARIS64.zip
  inflating: csscan                  
  inflating: lxchknlb                
  inflating: lxegen                  
  inflating: lxinst                  
  inflating: README.txt              
oracle@solaris01 $ 
oracle@solaris01 $ ls -al
total 14838
drwxr-xr-x   2 oracle   oinstall     512 Jul 22 22:18 .
drwxr-xr-x  18 oracle   oinstall    1024 Jul 22 22:18 ..
-rw-rw-r--   1 oracle   oinstall  355952 Nov 29  2006 csscan
-rw-rw-r--   1 oracle   oinstall  940776 Nov 29  2006 lxchknlb
-rw-rw-r--   1 oracle   oinstall 1458272 Nov 29  2006 lxegen
-rwxrwxr-x   1 oracle   oinstall 2933984 Nov 14  2006 lxinst
-rw-r--r--   1 oracle   oinstall 1836231 Jul 22 22:18 p5051614_10105_SOLARIS64.zip
-rwxrwxr-x   1 oracle   oinstall     536 Nov 29  2006 README.txt
oracle@solaris01 $ 
oracle@solaris01 $ cp csscan $ORACLE_HOME/bin
oracle@solaris01 $ cp lxchknlb $ORACLE_HOME/bin
oracle@solaris01 $ cp lxegen $ORACLE_HOME/bin  
oracle@solaris01 $ cp lxinst $ORACLE_HOME/bin  
oracle@solaris01 $

 
After applying the functional binaries from Patch 5051614, you should be able to execute and use csscan:

oracle@solaris01 $ csscan help=y
 
 
Character Set Scanner v2.0 : Release 10.1.0.4.0 - Production on Fri Jul 22 22:48:55 2011
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
 
You can let Scanner prompt you for parameters by entering the CSSCAN        
command followed by your username/password:                                 
 
  Example: CSSCAN SYSTEM/MANAGER                                            
 
Or, you can control how Scanner runs by entering the CSSCAN command         
followed by various parameters. To specify parameters, you use keywords:    
 
  Example: CSSCAN SYSTEM/MANAGER FULL=y TOCHAR=utf8 ARRAY=102400 PROCESS=3  
 
Keyword    Default Prompt Description                                       
---------- ------- ------ ------------------------------------------------- 
USERID             yes    username/password                                 
FULL       N       yes    scan entire database                              
USER               yes    owner of tables to be scanned                     
TABLE              yes    list of tables to scan                            
EXCLUDE                   list of tables to exclude from scan               
TOCHAR             yes    new database character set name                   
FROMCHAR                  current database character set name               
TONCHAR                   new national character set name                   
FROMNCHAR                 current national character set name               
ARRAY      102400  yes    size of array fetch buffer                        
PROCESS    1       yes    number of concurrent scan process                 
MAXBLOCKS                 split table if block size exceed MAXBLOCKS        
CAPTURE    N              capture convertible data                          
SUPPRESS                  maximum number of exceptions logged for each table
FEEDBACK                  report progress every N rows                      
BOUNDARIES                list of column size boundaries for summary report 
LASTRPT    N              generate report of the last database scan         
LOG        scan           base file name of report files                    
PARFILE                   parameter file name                               
PRESERVE   N              preserve existing scan results                    
LCSD       N       no     enable language and character set detection       
LCSDDATA   LOSSY   no     define the scope of the detection                 
HELP       N              show help screen (this screen)                    
---------- ------- ------ ------------------------------------------------- 
Scanner terminated successfully.
oracle@solaris01 $