Friday, September 20, 2013
Find files for a date and time and then copy to a directory
-rw-r--r-- 1 mys1idb oragrid 0 Sep 19 21:23 mys1id5_ora_19242.trc
-rw-r--r-- 1 mys1idb oragrid 0 Sep 19 21:23 mys1id5_ora_19281.trc
-rw-r--r-- 1 mys1idb oragrid 0 Sep 19 21:23 mys1id5_ora_19317.trc
-rw-r--r-- 1 mys1idb oragrid 0 Sep 19 21:23 mys1id5_ora_19325.trc
-rw-r--r-- 1 mys1idb oragrid 0 Sep 19 21:23 mys1id5_ora_19333.trc
-rw-r--r-- 1 mys1idb oragrid 0 Sep 19 21:24 mys1id5_ora_19386.trc
for i in `ls -latR | grep "Sep 19 21" | awk '{print $9}'`; do cp -pr $i /tmp/trace; done
Saturday, September 14, 2013
Trick to generate SQL from an Excel File
="INSERT INTO Table (ID, Name) VALUES (" & C2 & ", '" & D2 & "')"
Wednesday, September 11, 2013
How to resize redo logs for RAC with ASM
Find out the current redo log size
Now create some temporary groups
Now you have to keep switch them until you can drop the group 1 thru 4, you can put that in a script and
keep running until you have dropped group 1 thru 4
Now repeat the process by creating the Group 1 thur 4 with desired size (say 2G each)
Now you can drop the temporary groups 11 thru 14
Redo Threads
Each online redo log has a thread number and a sequence number. The thread number is mainly relevant in RAC databases where
there can be multiple threads; one for each instance. The thread number is not necessarily the same as the instance number.
For single instance databases there is only one redo log thread at any time.
Redo Log Groups
A redo thread consists of two or more redo log groups.
Each redo log group contains one or more physical redo log files known as members. Multiple members are configured to provide
protection against media failure (mirroring). All members within a redo log group should be identical at any time.
Each redo log group has a status. Possible status values include UNUSED, CURRENT, ACTIVE and INACTIVE. Initially redo log
groups are UNUSED. Only one redo log group can be CURRENT at any time. Following a log switch, redo log group continues to be
ACTIVE until a checkpoint has completed. Thereafter the redo log group becomes INACTIVE until it is reused by the LGWR background process.
Log Switches
Log switches occur when the online redo log becomes full. Alternatively log switches can be triggered externally by commands such as:
ALTER SYSTEM SWITCH LOGFILE;
When a log switch occurs, the sequence number is incremented and redo continues to be written to the next
file in the sequence. If archive logging is enabled, then following a low switch the completed online redo log will be copied to the archive
log destination(s) either by the ARCH background process or the LNSn background process depending on the configuration.
Tuesday, September 3, 2013
ETL Vs ELT - Explanation
Very Nice explanation of the terms ETL and ELT...
http://blog.performancearchitects.com/wp/2013/06/13/etl-vs-elt-whats-the-difference/
- credit goes to the original creator of the content.
Saturday, August 31, 2013
Invisible Indexes and its impact on Foreign Keys
Invisible Indexes on Foreign Keys can still be used by Oracle to prevent locking and performance
related issues when delete/update operations are performed on the parent records.
for more information read a very nice article by Richard Foote.
http://richardfoote.wordpress.com/category/invisible-indexes/
Tuesday, August 20, 2013
ORA-02297: cannot disable constraint ( ........ ) - dependencies exist
SQL> alter table scott.employee disable constraint employee_pk ;
ORA-02297: cannot disable constraint (SCOTT.EMPLOYEE_PK) - dependencies exist
Problem
Disable constraint command fails as the table is parent table and it has foreign
key that are dependent on this constraint.
Fix
There are two things we can do here.
1)Find foreign key constraints on the table and disable those foreign key constraints and then disable this table constraint.
Following query will check dependent table and the dependent constraint name.
After that disable child first and then parent constraint.
SELECT p.table_name "Parent Table", c.table_name "Child Table",
p.constraint_name "Parent Constraint", c.constraint_name "Child Constraint"
FROM user_constraints p
JOIN user_constraints c ON(p.constraint_name=c.r_constraint_name)
WHERE (p.constraint_type = 'P' OR p.constraint_type = 'U')
AND c.constraint_type = 'R' AND p.table_name = UPPER('&table_name')
/
The following query will generate a script to drop the child constraints
select 'alter table '||c.table_name||' disable constraint '||c.constraint_name||' ;'
FROM user_constraints p
JOIN user_constraints c ON(p.constraint_name=c.r_constraint_name)
WHERE (p.constraint_type = 'P' OR p.constraint_type = 'U')
AND c.constraint_type = 'R' AND p.table_name = UPPER('&table_name')
/
2)Disable the constraint with cascade option.
SQL> alter table transaction disable constraint EMPLOYEE_PK cascade;
Friday, July 5, 2013
Track Progress of Database Restore
Find out the name of the restore point
1* select name,time from v$restore_point
SQL> /
NAME TIME
------------------------------ ----------------------------------------
JULY_01_2013 01-JUL-13 08.30.29.000000000 AM
SQL>
Startup the database in mount state
SQL> Shutdown immediate
SQL> startup mount
SQL> flashback database to restore point JULY_01_2013 ;
NOW, Track the Progress of the restore using
SQL> select sid,message from v$session_longops where sofar <> totalwork ;
SID
----------
MESSAGE
--------------------------------------------------------------------------------
1173
Flashback Database: Flashback Data Applied : 43160 out of 52292 Megabytes done
SQL>
Wednesday, June 5, 2013
Using QUERY with Data Pump Export - expdp
You can use QUERY within expdp to do a selective export of a table
Here's the exact way you need to format your query
Below EXAMPLE will export the entire schema SCOTT but from table EMP only rows having EMPNO >= 7900 would be exported.
Monday, May 20, 2013
addnode gave PRCF-2023 : The following contents are not transferred as they are non-readable.
While adding a node to an existing four node cluster, got the following error.
The issue in this case was the file permission on the file root.sh_11203
Solution
========
Fix the file permission so that its readable by the user owning the ORACLE_HOME and re-run the add_node command.
Thursday, May 2, 2013
SQL Scripts to find TEMP tablespace usage
Here are various scripts which helps in determining who's using the TEMP tablespace.
Script 1
Script 2
Script 3
Script 4
Useful Oracle Notes in reference to TEMP Tablespace
How Can Temporary Segment Usage Be Monitored Over Time? (Doc ID 364417.1)
TROUBLESHOOTING GUIDE (TSG) : ORA-1652: unable to extend temp segment [ID 1267351.1]
Generate AWR report for a particular SQL
Once you have identified that a particular SQL is causing issues, you can generate the AWR report for a particular SQL between two specific snap_id's for further analysis. SQL "awrsqrpt.sql" is located under $ORACLE_HOME/rdbms/admin
awrsqlrpt_2_66397_66398.html => This report gives lot of good information about that particular SQL including the Plan Statistics and EXECUTION PLAN
Monday, April 22, 2013
srvctl remove commands
SRVCTL REMOVE DATABASE - Removes a database configuration
Syntax and Options
SRVCTL REMOVE INSTANCE - Removes a database instance configuration
Syntax and Options
SRVCTL REMOVE NODEAPPS - Removes the node application configuration from the specified node. You must have
full administrative privileges to run this command. On Linux and UNIX systems, you must be logged in as root
and on Windows systems, you must be logged in as a user with Administrator privileges.
Syntax and Options
srvctl remove nodeapps -n node_name_list [-f]
srvctl remove listener - Removes the listener from the specified node.
Syntax and Options
You will see something like below from $GRID_HOME/bin/crsstat output
Examples
The following command removes the listener LISTENER_MYRAC1D1 from the myrac1d1 node:
Monday, April 8, 2013
ORA-12012: error on auto execute of job : ORA-01878: specified field not found in datetime or interval
You may see the below errors in your alert log file after the daylight time changes if the job happens to run around
the time when the daylight time changes, which is 2 AM.
ORA-12012: error on auto execute of job 219820676
ORA-01878: specified field not found in datetime or interval
You can run the below queries to find out when the job was scheduled to run and who owns the job
Connect to the database with the priv_user from the above query for that particular job and change the next_date manually by running the following
NOTE: If possible move the time of the job to away from 2 AM time, that is when the time change happens twice every year. I did moved the job to 04:00 AM so you are good for the future as well.
Wednesday, March 20, 2013
Create Restore Point and Recover the database using Restore Point
To create a flashback restore point, you must be using FRA and flashback must be turned on.
Check to see if flashback is turned on with the following:
Enabling Flashback Database
Step 1 . Set the parameters
Step 2 . Shutdown the database
Step 3 . Startup mount the database (one node) and turn on Flash Back
Step 4 . Make Sure Flashback is Turned ON and shutdown the instance.
Step 5 . Start up RAC instances
Create Restore Point
Recover Dataabse with Restore Point
PRVG-11050 : No matching interfaces "bond0" for subnet "90.xxx.127.0" on nodes "myrac1,myrac2,myrac3,myrac4"
I got the below errors while running the pre-checks before upgrading from 11gR1 (11.1.0.7) to 11gR2 (11.2.0.3)
PRVG-11050 : No matching interfaces "bond0" for subnet "90.xxx.127.0" on nodes "myrac1,myrac2,myrac3,myrac4"
Check: Node connectivity for interface "bond0"
Result: Node connectivity failed for interface "bond0"
Check the following on one of the nodes.
myrac1:/usr/local/opt/oracle/ $ oifcfg iflist -p -n
bond0 90.xxx.126.0 UNKNOWN 255.255.254.0
bond1 172.29.70.0 PRIVATE 255.255.255.0
myrac1:/usr/local/opt/oracle/ $ oifcfg getif
bond0 90.xxx.127.0 global public
bond1 172.29.70.0 global cluster_interconnect
You would notice that values for bond0 after running oifcfg getif
is different when you run oifcfg iflist -p -n
To solve the issue, work with your Network Admin to find out the real values for the bond0 and update.
In our case it should have been 90.xxx.126.0
Login as ROOT
# oifcfg delif -global bond0/90.xxx.127.0
# oifcfg setif -global bond0/90.xxx.126.0:public
Running the above should solve the issue.
Monday, March 11, 2013
RMAN - unregister database from recovery catalog
DB_KEY DB_NAME RESET_TIME DBINC_ST
---------- -------- ----------- --------
91068668 MYRACDB 17-nov-2010 PARENT
91068668 MYRACDB 12-mar-2008 PARENT
91068668 MYRACDB 02-may-2011 CURRENT
91068668 MYRACDB 28-apr-2011 ORPHAN
91068668 MYRACDB 27-apr-2011 ORPHAN
91068668 MYRACDB 27-apr-2011 ORPHAN
91068668 MYRACDB 28-apr-2011 ORPHAN
7 rows selected.
SQL> select db_key, db_id from RMANCAT.DB where DB_KEY=91068668;
DB_KEY DB_ID
---------- ----------
91068668 232532794
Now Login as RMAN
${ORACLE_HOME}/bin/rman catalog rmancat/cat@rmandb.world.com
RMAN>
Monday, March 4, 2013
Database runInstaller "Nodes Selection" Window Does not Show RAC Nodes
Oracle Clusterware (CRS or GI) is up and running as confirmed by $CRS_HOME/bin/crsctl check crs on all nodes, and $CRS_HOME/bin/olsnodes -n show all the nodes, but database runInstaller does not show all cluster nodes.
There might be an issue with the Inventory for Clusterware home.
Look at inventory.xml file under the oraInventory/ContentsXML directory.
It should show CRS="true" against the correct CRS or GI home and only one entry should have CRS="true" even if there are multiple (older) CRS or GI homes listed.
Do not update the inventory.xml manually. Use the below commands to fix the issue.
$GRID_HOME/oui/bin/runInstaller -silent -ignoreSysPrereqs -updateNodeList ORACLE_HOME="/opt/app/oragrid/oracle/product/11.2.0.3" LOCAL_NODE="myracd1" CLUSTER_NODES="{myracd1,myracd2}" CRS=trueChange the LOCAL_NODE to point to the node from where you are running the command. This needs to be run from every node where you want the inventory.xml updated.
If another CRS_HOME also has CRS="true" as in example below.
then use the below command to set it to false.
$GRID_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME="/opt/app/t5cim1d/oracle/product/crs" CRS=falseOracle Notes 1327486.1 and 1053393.1 has more details.
Sunday, March 3, 2013
Test Box
Font 1
Font 2
Font 3
Font 4
Font 5
select job ,to_char(LAST_DATE,'YYYYMMDD HH24:MI:SS'),to_char( NEXT_DATE ,'YYYYMMDD HH24:MI:SS') from dba_jobs where NEXT_DATE < sysdate; select job, what, log_user, priv_user from dba_jobs where job= select job ,to_char(LAST_DATE,'YYYYMMDD HH24:MI:SS'),to_char( NEXT_DATE ,'YYYYMMDD HH24:MI:SS') from dba_jobs where NEXT_DATE < sysdate; select job, what, log_user, priv_user from dba_jobs where job= |
Friday, March 1, 2013
11gR1 to 11gR2 Upgrade: cluvfy tool found some mandatory patches are not installed
The cluvfy tool found some mandatory patches are not installed.
These patches need to be installed before the upgrade can proceed.
The pre-upgrade checks failed, aborting the upgrade
The above error is mis-leading sometimes. Look under the log file at
$GRID_HOME/cfgtoollogs/crsconfig and re-run the cluvfy commands listed there manually by removing the "-_patch_only"
/bin/su oragrid -c ' /opt/app/oragrid/oracle/product/11.2.0.3/bin/cluvfy stage -pre crsinst -n myrac1,myrac2 -upgrade -src_crshome /opt/app/oracle/product/crs -dest_crshome /opt/app/oragrid/oracle/product/11.2.0.3 -dest_version 11.2.0.3.0 'if the above comes back without issues then the problem is the environment variables ORA_CRS_HOME. If that is set at the session from where you are running rootupgrade.sh, then you will see the above error.
unset ORA_CRS_HOME and re-run the rootupgrade.sh and it should finish without errors.
Oracle Note 1498538.1 has more details about it as well.
Wednesday, February 27, 2013
Oracle DB 11gR2 Global AWR Report Generation
Oracle DB 11gR2 AWR Global Report Generation
Before 11gR2, the awrrpt.sql under $ORACLE_HOME/rdbms/admin only generates awr report for local instance.
You have to collect awr report for each of RAC instances.
In 11gR2 there are two new scripts awrgrpt.sql AND awrgdrpt.sql for RAC
awrgrpt.sql -- AWR Global Report (RAC) (global report)Some other important scripts under $ORACLE_HOME/rdbms/admin
awrgdrpt.sql -- AWR Global Diff Report (RAC)
spawrrac.sql -- Server Performance RAC report
awrsqrpt.sql -- Standard SQL statement Report
awrddrpt.sql -- Period diff on current instance
awrrpti.sql -- Workload Repository Report Instance (RAC)
Wednesday, February 20, 2013
PRCD-1231 : Failed to upgrade configuration of database and PRKC-1136
PROBLEM: After upgrading the database from 11.1.0.7 to 11.2.0.3 (using MANUAL Method), unable to update the CRS with new version of the database
rklx1:11gr2_upgrade/ $ srvctl upgrade database -d racdb -o /usr/local/opt/oracle/product/11.2.0.3
PRCD-1231 : Failed to upgrade configuration of database racdb to version 11.2.0.3.0 in new Oracle home /usr/local/opt/oracle/product/11.2.0.3
PRKC-1136 : Unable to find version for database with name racdb
rklx1:11gr2_upgrade/ $ srvctl remove database -d racdb
PRCD-1120 : The resource for database racdb could not be found.
PRCR-1001 : Resource ora.racdb.db does not exist
SOLUTION:
Login as ROOT to node 1
#$GRID_HOME/bin/./crs_unregister ora.racdb.racdbt4.inst
#$GRID_HOME/bin/./crs_unregister ora.racdb.racdbt3.inst
#$GRID_HOME/bin/./crs_unregister ora.racdb.racdbt2.inst
#$GRID_HOME/bin/./crs_unregister ora.racdb.racdbt1.inst
#$GRID_HOME/bin/./crs_unregister ora.racdb.db
Then Login as Oracle User and Add the database and the instance
srvctl add database -d racdb -o $ORACLE_HOME
srvctl add instance -d racdb -i racdbt1 -n rklx1
srvctl add instance -d racdb -i racdbt2 -n rklx2
srvctl add instance -d racdb -i racdbt3 -n rklx3
srvctl add instance -d racdb -i racdbt4 -n rklx4
and then start the database
srvctl start database -d racdb
Monday, February 18, 2013
PRVG-11055 : Interfaces configured with subnet number "90.xxx.xxx.0" have multiple subnets masks
Checking subnet mask consistency...
Subnet mask consistency check passed for subnet "172.29.70.0".
PRVG-11055 : Interfaces configured with subnet number "90.xxx.xxx.0" have multiple subnets masks
PRVG-11056 : subnet masks "255.255.254.0" are configured with subnet number "90.xxx.xxx.0" on nodes "rklx4,rklx3,rklx2,rklx1"
PRVG-11056 : subnet masks "255.255.255.0" are configured with subnet number "90.xxx.xxx.0" on nodes "rklx4,rklx3,rklx2,rklx1"
Subnet mask consistency check failed.
Result: Node connectivity check failed
SOLUTION
========
# $ORA_CRS_HOME/bin/oifcfg iflist -p -n
bond0 172.xx.xx.0 PRIVATE 255.255.255.0
bond1 90.xxx.xxx.0 UNKNOWN 255.255.254.0
# $ORA_CRS_HOME/bin/crs_stat -p ora.rklx1.vip =====> run this on all nodes of the cluster
You need to modify the subnet mask by running the following
srvctl modify nodeapps -n rklx1 -A 90.xxx.xxx.166/255.255.254.0/bond1
srvctl modify nodeapps -n rklx2 -A 90.xxx.xxx.61/255.255.254.0/bond1
srvctl modify nodeapps -n rklx3 -A 90.xxx.xxx.114/255.255.254.0/bond1
srvctl modify nodeapps -n rklx4 -A 90.xxx.xxx.133/255.255.254.0/bond1
How to remove Disks from Disk Group
=> Find out the group number and name :
SQL> select group_number, name from v$asm_diskgroup ;
GROUP_NUMBER NAME
------------ ------------------------------
1 DATA
2 RECOVERY
3 GRID
=> Find out the name of the disk belonging to GROUP_NUMBER=3 which is GRID Disk Group.
SQL> select DISK_NUMBER, name, failgroup, group_number from v$asm_disk where group_number=3 order by name ;
DISK_NUMBER NAME FAILGROUP GROUP_NUMBER
----------- -------------- ---------------------- ------------
0 ASM2_VMAX00639 ASM2_VMAX00639 3
1 ASM2_VMAX0063A ASM2_VMAX0063A 3
=> so from above, there are two disks belonging to GRID diskgroup, now we'll remove one of the disks from the diskgroup
=> Drop the Disk from diskgroup named GRID
SQL> alter DISKGROUP GRID drop disk ASM2_VMAX00639 ;
=>You can check the re-balance progress using below SQL
SQL> select * from v$asm_operation;
Friday, January 4, 2013
How to Display Directory Structure Linux/Unix
The below command displays the directory tree structure
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
More information at http://www.centerkey.com/tree/
Wednesday, July 18, 2012
Oracle RAC - OCR Backups
Monday, July 2, 2012
Object and Tablespace I/O
Wednesday, March 7, 2012
SQL Query Optimizer
SQL Query Optimizer
Very interesting reading if you want to know how Oracle Processes the SQL statements and deliver the results back.
http://docs.oracle.com/cd/E11882_01/server.112/e16638/optimops.htm#i21299
Monday, January 23, 2012
SQL to find RMAN Backup Duration
select TO_CHAR(start_time,'yyyy-mm-dd hh24:mi:ss') Start_Time,
TO_CHAR(end_time,'yyyy-mm-dd hh24:mi:ss') End_Time , INPUT_TYPE, round(ELAPSED_SECONDS/60) MINUTES
from v$rman_backup_job_details order by Start_Time asc
/
START_TIME END_TIME INPUT_TYPE MINUTES
------------------------------ ------------------------------ ------------- ----------
2012-01-02 01:00:24 2012-01-02 01:43:34 DB INCR 43
2012-01-02 18:01:07 2012-01-02 19:10:20 ARCHIVELOG 69
2012-01-06 14:52:48 2012-01-06 20:11:54 DB FULL 319
Thursday, September 29, 2011
ASM DG to Physical Disk Mapping
#!/bin/ksh
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk -d $i | awk '{print $2}'`
v_minor=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk '{print $1}'`
v_major=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk '{print $2}'`
v_device=`ls -la /dev | grep $v_minor | grep $v_major | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device [$v_minor $v_major]"
done
Wednesday, September 21, 2011
CRS Diagnostic Data Gathering
CRS Diagnostic Data Gathering
For 10gR2
=========
Ensure that the environment variable ORA_CRS_HOME is set to the CRS home
Ensure that the environment variable ORACLE_BASE is set
Ensure that the environment variable HOSTNAME is set to the name of the host.
$./diagcollection.pl -collect
For 11gR1
=========
Execute diagcollection.pl by passing the crs_home as the following
export ORA_CRS_HOME=/u01/crs
$ORA_CRS_HOME/bin/diagcollection.pl -crshome=$ORA_CRS_HOME --collect
For 11gR2
=========
Execute
NOTE: --nocore
OS Watcher (OSW)
================
For platforms where Cluster Health Monitor is not available, OS Watcher can collect OS performance statistics.
The OS Watcher guide for Windows is found in Oracle Metalink Document 433472.1 - OS Watcher For Windows (OSWFW) User Guide. However, CHM for Windows is far superior to OS Watcher for Windows and should be used wherever possible.
For all other platforms, the OS Watcher user guide can be found in Document 301137.1
The OS Watcher output or the compressed output can be manually collected from the osw installation directories. Browsing the OSW output will show the server performance profile.
If OS Watcher is not running, then you can start the data collection manually from the osw installation directory:
nohup ./startOSW.sh &
OS Watcher should be in init.d to ensure that it starts automatically at server start.
The script tarupfiles.sh should be run regularly to compress the OS watcher data collection output. This should be configured in crontab.
Find out about dropped network packets
$ netstat -s
OR
$ ifconfig -a
the above gives information about "dropped network packets"
Friday, July 29, 2011
Wednesday, July 27, 2011
Perl script to run any UNIX/LINUX command and email the output
The following script would run command "lsof -u oracle | wc -l" and then check for
the threshold value and if the threshold is exceeded, it will email the output.
#!/usr/bin/perl -w
use POSIX 'strftime';
my $date = strftime '%m-%d-%Y %H:%M:%S', localtime;
my $command = `/usr/sbin/lsof -u oracle | wc -l `;
my $host = `hostname`; chomp($host);
my $to = "abc\@yahoo.com";
my $title = "LSOF Threshold Exceeded" ;
my $from = "DBA\@yahoo.com";
my $subject = "Threshold lsof exceeded";
my $thresh = 10;
if( $command ge $thresh ) {
open(MAIL, "|/usr/sbin/sendmail -t ");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $title for host : $host\n";
print MAIL "$date\n HOSTNAME: $host\n LSOF Count: $command\n\n";
print MAIL "LSOF Count has Exceeded the threshold of $thresh";
close(MAIL);
}
Wednesday, June 15, 2011
Remove Job from another user : DBMS_IJOB.REMOVE
SQL> exec dbms_job.remove(40682);
BEGIN dbms_job.remove(40682); END;
*
ERROR at line 1:
ORA-23421: job number 40682 is not a job in the job queue
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_IJOB", line 687
ORA-06512: at "SYS.DBMS_JOB", line 174
ORA-06512: at line 1
SQL> EXECUTE SYS.DBMS_IJOB.REMOVE (40682);
PL/SQL procedure successfully completed.
SQL>
Friday, June 3, 2011
Find session activity
select event,'/usr/ucb/ps -aux | grep'||spid,pga_used_mem,sid,a.serial#,b.inst_id,logon_time,a.username,module,last_call_et/60,subst
r(machine,1,20),process,sql_id
from gv$session a,gv$process b where addr=paddr
and status='ACTIVE'
and a.username is not null
and a.username = 'GCP_USER'
and a.inst_id=b.inst_id
and last_call_et/60 > 1
order by b.inst_id
/
Who's using the UNDO segments
SELECT TO_CHAR (s.SID) || ',' || TO_CHAR (s.serial#) sid_serial,
NVL (s.username, 'None') orauser, s.program, r.NAME undoseg,
t.used_ublk * TO_NUMBER (x.VALUE) / 1024 || 'K' "Undo"
FROM SYS.v_$rollname r,
SYS.v_$session s,
SYS.v_$transaction t,
SYS.v_$parameter x
WHERE s.taddr = t.addr
AND r.usn = t.xidusn(+)
AND x.NAME = 'db_block_size'
/
Wednesday, May 18, 2011
Find out who's locking the accounts
set lines 200
set pages 200
column USERNAME format a12
column OS_USERNAME format a12
column USERHOST format a25
column EXTENDED_TIMESTAMP format a40
SELECT USERNAME, OS_USERNAME, USERHOST, EXTENDED_TIMESTAMP
FROM SYS.DBA_AUDIT_SESSION WHERE returncode != 0 and username = '&Account_Locked'
and EXTENDED_TIMESTAMP > (systimestamp-1) order by 4 desc
/
Wednesday, May 11, 2011
Query to find HISTOGRAMS
select owner,table_name,histogram from DBA_TAB_COL_STATISTICS where
owner='SCOTT' and table_name='EMPLOYEE'
Monday, May 9, 2011
Default STATS Collection in 11g
- The GATHER_STATS_JOB Oracle’s default stats collection job does not exist in
11g (the name does not exist) as it was there in 10g. Instead it has been
included in Automatic Maintenance Tasks
- How to check, Oracle’s default stats collection job is enable or disabled
SQL> select CLIENT_NAME,status from DBA_AUTOTASK_CLIENT;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection DISABLED
auto space advisor ENABLED
sql tuning advisor ENABLED
- How to disable if it is enabled (run below query to disable it). Below PL/SQL block has to be executed by SYS
BEGIN
DBMS_AUTO_TASK_ADMIN.DISABLE(
client_name => 'auto optimizer stats collection',
operation => NULL,
window_name => NULL);
END;
Sunday, April 24, 2011
EXPDP - EXCLUDE Multiple TABLES and SCHEMAS
The below example gives syntax to EXCLUDE multiple tables and multiple schemas while doing a full database export using expdp
=== BEGIN expdp_exclude.par
DIRECTORY=DATA_PUMP_DIR
DUMPFILE=abc.dmp
LOGFILE=abc.log
FULL=Y
EXCLUDE=STATISTICS
EXCLUDE=TABLE:"IN ('NAME', 'ADDRESS' , 'EMPLOYEE' , 'DEPT')"
EXCLUDE=SCHEMA:"IN ('WMSYS', 'OUTLN')"
=== END expdp_exclude.par
In the above example parameter file; tables NAME and ADDRESS are owned by SCOTT and tables EMPLOYEE and DEPT are owned by HR
EXCLUDE=TABLE => You do not have to prefix the OWNER name, in fact, if you put the OWNER.TABLE_NAME, it would not work.
It will EXCLUDE all TABLES having the name mentioned in the list, even if more than one owner has the same object name.
For example: If ADDRESS table is owned by user SCOTT and user HR, that table will be EXCLUDED from both the users.
The above commands would work only via parameter file and would not work on the command line.
COMMAND LINE SYNTAX for EXPDP
expdp system/password DIRECTORY=DATA_PUMP_DIR DUMPFILE=abc.dmp FULL=Y
EXCLUDE=TABLE:\"IN \(\'NAME\', \'ADDRESS\' , \'EMPLOYEE\' , \'DEPT\'\)\"
EXCLUDE=SCHEMA:\"IN \(\'WMSYS\', \'OUTLN\'\)\"
Monday, March 28, 2011
Find Current CPU or PSU Applied
mylx1:product/11.1.0/OPatch/ $ ./opatch lsinv -bugs_fixed | grep -i 'database psu'
8833297 9352179 Mon Sep 13 22:00:34 EDT 2010 DATABASE PSU 11.1.0.7.1 (INCLUDES CPUOCT2009)
9209238 9352179 Mon Sep 13 22:00:34 EDT 2010 DATABASE PSU 11.1.0.7.2 (INCLUDES CPUJAN2010)
9352179 9352179 Mon Sep 13 22:00:34 EDT 2010 DATABASE PSU 11.1.0.7.3 (INCLUDES CPUAPR2010)
mylx1:product/11.1.0/OPatch/ $
REM This script outputs the current CPU applied on the database.column action format a15
column action_time format a30
column comments format a35
column action format a20
set linesize 300
select comments,action_time,action
from
(select action,action_time,comments
from sys.registry$history
where action in ('CPU','APPLY')
order by action_time desc)
where comments <> 'view recompilation'
and rownum < 2
/
-- Output from above script --
COMMENTS ACTION_TIME ACTION
----------------------------------- ------------------------------ --------------------
PSU 11.1.0.7.3 09-AUG-10 09.14.20.562314 AM APPLY
Wednesday, February 23, 2011
Expdp Options
expdp system/******** schemas=SCOTT directory=SCOTT_DUMP dumpfile=scott.dmp logfile=scott.log EXCLUDE=TABLE:\"LIKE \'EMP%\'\", TABLE:\"LIKE \'%ABC%\'\"
if you just type EXCLUDE=TABLE:"LIKE 'EMP%'", TABLE:"LIKE '%ABC%'":
you will get the following error.
ORA-39001: invalid argument value
ORA-39071: Value for EXCLUDE is badly formed.
ORA-00911: invalid character
you need to include escape characters in the statement, e.g.:
EXCLUDE=TABLE:\"LIKE \'EMP%\'\", TABLE:\"LIKE \'%ABC%\'\" ,
this would exclude tables starting with EMP and any tables having ABC in their table name.
Using the NOT IN OPERATOR
EXCLUDE=TABLE:\"NOT IN \(\'ABC\',\'XYZ\'\)\"
Using the IN OPERATOR
EXCLUDE=TABLE:\"IN \(\'ABC\',\'XYZ\'\)\"
Monday, November 22, 2010
Find Unindexes FK Constraints
col table_name format a32
col columns format a40
set lines 140
set pages 200
select table_name, constraint_name,
cname1 || nvl2(cname2,','||cname2,null) ||
nvl2(cname3,','||cname3,null) || nvl2(cname4,','||cname4,null) ||
nvl2(cname5,','||cname5,null) || nvl2(cname6,','||cname6,null) ||
nvl2(cname7,','||cname7,null) || nvl2(cname8,','||cname8,null)
columns
from ( select b.table_name,
b.constraint_name,
max(decode( position, 1, column_name, null )) cname1,
max(decode( position, 2, column_name, null )) cname2,
max(decode( position, 3, column_name, null )) cname3,
max(decode( position, 4, column_name, null )) cname4,
max(decode( position, 5, column_name, null )) cname5,
max(decode( position, 6, column_name, null )) cname6,
max(decode( position, 7, column_name, null )) cname7,
max(decode( position, 8, column_name, null )) cname8,
count(*) col_cnt
from (select substr(table_name,1,30) table_name,
substr(constraint_name,1,30) constraint_name,
substr(column_name,1,30) column_name,
position
from user_cons_columns ) a,
user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'R'
group by b.table_name, b.constraint_name
) cons
where col_cnt > ALL
( select count(*)
from user_ind_columns i
where i.table_name = cons.table_name
and i.column_name in (cname1, cname2, cname3, cname4,
cname5, cname6, cname7, cname8 )
and i.column_position <= cons.col_cnt
group by i.index_name
)
order by table_name
/
(Credit goes to the original author, found it somewhere on internet)
Friday, November 5, 2010
FTS with Table Name
select distinct a.sql_id,b.object_name
--dbms_lob.substr(a.sql_text)
from dba_hist_sqltext a,
(select SQL_ID,object_name from dba_hist_sql_plan where object_owner='SCOTT'and OPERATION = 'TABLE ACCESS' and OPTIONS =
'FULL') b
where a.sql_id = b.sql_id
order by 1
/
Wednesday, November 3, 2010
Find SQLs doing Full Table Scans
select sql_id,sql_text from dba_hist_sqltext
where sql_id in (select distinct SQL_ID from dba_hist_sql_plan where object_owner='SCOTT'
and OPERATION = 'TABLE ACCESS' and OPTIONS = 'FULL')
/
Monday, October 11, 2010
crsctl.bin: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
After upgrading the CRS to 11g (11.1.0.7) and at the time of running the root111.sh (at 11.1.0.7), got the below error
/usr/local/opt/oracrs/bin/crsctl.bin: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory
And found the workaround in the below note.
After Installing Patchset Crsctl Fails To Load Libclntsh.so [ID 333233.1]
Workaround was to manually change the permission of libclntsh.so.11.1 and After applying the workaround all services in the cluster were ONLINE.
Monday, October 4, 2010
Oracle RAC Commands
To shutdown RDBMS on all nodes run the following command:
$ORACLE_HOME/bin/srvctl stop database -d dbname
To shutdown RDBMS instance on the local node run the following command:
$ORACLE_HOME/bin/srvctl stop instance -d dbname -i instance_name
To shutdown ASM instances run the following command on each node:
$ORACLE_HOME/bin/srvctl stop asm -n
To shutdown listeners run the following command on each node:
$ORACLE_HOME/bin/srvctl stop listener -n
To shutdown nodeapps run the following comand on each node:
$ORA_CRS_HOME/bin/srvctl stop nodeapps -n
To shutdown CRS daemons on each node by running as root:
# crsctl stop crs
Monday, September 27, 2010
How to suppress Oracle Banner
Disabling "Banner" assumes significance in case of Oracle RAC Install. The result of not temporarily removing the banner is that the dba will see errors that say, "User equivalence failed for user oracle".
• Log in (or sudo to) user oracle
• cd ~/.ssh
• Modify (or create) a file named “config” in this directory, to add the following line (case-sensitive, left-justified):
LogLevel QUIET
• Save and close the file.
• Test to ensure that oracle can ssh to all other RAC nodes in the cluster, without being presented with a banner.
What is displayed as Banner is stored under /usr/localcw/opt/tcpwrapper/banners/
How to start Oracle runInstaller in TRACING mode
Launch the installer with tracing turned on
./runInstaller -J-DTRACING.ENABLED=true -J-DTRACING.LEVEL=2
Friday, September 24, 2010
How to Check OCR and Voting Disk
How to find out which raw devices are used for OCR and which ones are used for Voting Disk.
mylxd1->ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 487980
Used space (kbytes) : 3884
Available space (kbytes) : 484096
ID : 2006423852
Device/File Name : /dev/raw/raw1
Device/File integrity check succeeded
Device/File Name : /dev/raw/raw2
Device/File integrity check succeeded
Cluster registry integrity check succeeded
Logical corruption check succeeded
mylxd1->crsctl query css votedisk
0. 0 /dev/raw/raw3
1. 0 /dev/raw/raw4
2. 0 /dev/raw/raw5
Located 3 voting disk(s).
Wednesday, August 25, 2010
Database restart on HOST reboot
Create a script to stop/start the database
Execute these as ROOT.
cp {script to stop/start the database to} /etc/init.d/oracle
chmod 755 /etc/init.d/oracle
ln –s /etc/init.d/oracle /etc/rc0.d/K05oracle
ln –s /etc/init.d/oracle /etc/rc3.d/S90oracle
Delete archivelogs using RMAN until date
RMAN> run
{
DELETE archivelog until time "to_date('2010-08-23:10:00:00','YYYY-MM-DD:hh24:mi:ss')";
}
Tuesday, August 24, 2010
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
lxtestbox:/exp/expdp/ $ impdp system/password parfile=imp_from_test.par
Import: Release 10.2.0.4.0 - 64bit Production on Tuesday, 24 August, 2010 9:43:41
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "/exp/expdp/test01.dmp" for read
ORA-27054: NFS file system where the file is created or resides is not mounted with correct options
Additional information: 3
Solution
Mount the file system with the following option
rw,noac,bg,intr,hard,timeo=600,wsize=32768,rsize=32768,nfsvers=3,tcp
Monday, August 23, 2010
RMAN Restore Point in Time Restore (PITR)
run {
allocate channel t1 type disk ;
allocate channel t2 type disk ;
allocate channel t3 type disk ;
allocate channel t4 type disk ;
set until time "to_date('2010-08-23 08:15:00','YYYY-MM-DD HH24:MI:SS')" ;
restore database ;
recover database ;
sql 'alter database open resetlogs' ;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
}
Friday, May 14, 2010
Script to find foreign key constraints
Script to find foreign key constraints
select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name
from all_constraints
where constraint_type='R'
and r_constraint_name in (select constraint_name from all_constraints
where constraint_type in ('P','U') and table_name='&TABLE_NAME')
/
Find Oracle Database Character Set
Character Sets
(Ordinary) character set
The (ordinary) character set for a database can be determined with:
SQL> select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET';
National character set
The national character set for a database can be determined with:
SQL> select value from nls_database_parameters
where parameter = 'NLS_NCHAR_CHARACTERSET';
Monday, April 26, 2010
How to find number of sessions per hour for EACH INSTANCE in a RAC
SELECT
to_char(TRUNC(s.begin_interval_time,'HH24'),'DD-MON-YYYY HH24:MI:SS') snap_begin,
r.instance_number instance,
r.current_utilization sessions
FROM
dba_hist_resource_limit r,
dba_hist_snapshot s
WHERE ( TRUNC(s.begin_interval_time,'HH24'),s.snap_id ) IN
(
--Select the Maximum of the Snapshot IDs within an hour if all of the snapshot IDs
--have the same number of sessions
SELECT TRUNC(sn.begin_interval_time,'HH24'),MAX(rl.snap_id)
FROM dba_hist_resource_limit rl,dba_hist_snapshot sn
WHERE TRUNC(sn.begin_interval_time) >= TRUNC(sysdate-1)
AND rl.snap_id = sn.snap_id
AND rl.resource_name = 'sessions'
AND rl.instance_number = sn.instance_number
AND ( TRUNC(sn.begin_interval_time,'HH24'),rl.CURRENT_UTILIZATION ) IN
(
--Select the Maximum no.of sessions for a given begin interval time
SELECT TRUNC(s.begin_interval_time,'HH24'),MAX(r.CURRENT_UTILIZATION) "no_of_sess"
FROM dba_hist_resource_limit r,dba_hist_snapshot s
WHERE r.snap_id = s.snap_id
AND TRUNC(s.begin_interval_time) >= TRUNC(sysdate-1)
AND r.instance_number=s.instance_number
AND r.resource_name = 'sessions'
GROUP BY TRUNC(s.begin_interval_time,'HH24')
)
GROUP BY TRUNC(sn.begin_interval_time,'HH24'),CURRENT_UTILIZATION
)
AND r.snap_id = s.snap_id
AND r.instance_number = s.instance_number
AND r.resource_name = 'sessions'
ORDER BY snap_begin,instance
How to find number of sessions per hour
SELECT
to_char(TRUNC(s.begin_interval_time,'HH24'),'DD-MON-YYYY HH24:MI:SS') snap_begin,
sum(r.current_utilization) sessions
FROM
dba_hist_resource_limit r,
dba_hist_snapshot s
WHERE ( TRUNC(s.begin_interval_time,'HH24'),s.snap_id ) IN
(
--Select the Maximum of the Snapshot IDs within an hour if more than one snapshot IDs
--have the same number of sessions within that hour , so then picking one of the snapIds
SELECT TRUNC(sn.begin_interval_time,'HH24'),MAX(rl.snap_id)
FROM dba_hist_resource_limit rl,dba_hist_snapshot sn
WHERE TRUNC(sn.begin_interval_time) >= TRUNC(sysdate-1)
AND rl.snap_id = sn.snap_id
AND rl.resource_name = 'sessions'
AND rl.instance_number = sn.instance_number
AND ( TRUNC(sn.begin_interval_time,'HH24'),rl.CURRENT_UTILIZATION ) IN
(
--Select the Maximum no.of sessions for a given begin interval time
-- All the snapshots within a given hour will have the same begin interval time when TRUNC is used
-- for HH24 and we are selecting the Maximum sessions for a given one hour
SELECT TRUNC(s.begin_interval_time,'HH24'),MAX(r.CURRENT_UTILIZATION) "no_of_sess"
FROM dba_hist_resource_limit r,dba_hist_snapshot s
WHERE r.snap_id = s.snap_id
AND TRUNC(s.begin_interval_time) >= TRUNC(sysdate-1)
AND r.instance_number=s.instance_number
AND r.resource_name = 'sessions'
GROUP BY TRUNC(s.begin_interval_time,'HH24')
)
GROUP BY TRUNC(sn.begin_interval_time,'HH24'),CURRENT_UTILIZATION
)
AND r.snap_id = s.snap_id
AND r.instance_number = s.instance_number
AND r.resource_name = 'sessions'
GROUP BY
to_char(TRUNC(s.begin_interval_time,'HH24'),'DD-MON-YYYY HH24:MI:SS')
ORDER BY snap_begin
Thursday, March 25, 2010
Linux GUI
How to find system resource utilization in Linux
$ export DISPLAY=90.30.212.197:0.0
$ gnome-system-monitor
Wednesday, January 6, 2010
Kernel Parameters for RedHat Linux
$ ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096 // SHMMNI
max seg size (kbytes) = 66046570 // SHMMAX
max total shared memory (kbytes) = 66046568 // SHMALL
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 128 // SEMMNI
max semaphores per array = 250 // SEMMSL
max semaphores system wide = 32000 // SEMMNS
max ops per semop call = 100 // SEMOPM
semaphore max value = 32767
------ Messages: Limits --------
max queues system wide = 16 // MSGMNI
max size of message (bytes) = 65536 // MSGMAX
default max size of queue (bytes) = 65536 // MSGMNB
>> Set shmmax to 0.5 * Total Memory (free -b)
>> SHMMAX is the maximum size of a shared memory segment on a Linux system
whereas SHMALL is the maximum allocation of shared memory pages on a system.
>> SHMALL is set to 8 GB by default (8388608 KB = 8 GB). If you have more physical memory than this,
and it is to be used for oracle database, then this parameter should be increased to approximately
80% of the physical memory. For instance, if you have a server with 16 GB of memory to be used primarily
for oracle, then 80% of 16 GB is 12.8 GB divided by 4 KB (the base page size). The ipcs output has converted
SHMALL into kilobytes. The kernel requires this value as a number of pages.
>> The next section "Semaphore Limits" covers the amount of semaphores available to the operating system.
The kernel parameter semaphore consists of 4 tokens, SEMMSL, SEMMNS, SEMOPM and SEMMNI.
SEMMNS is the result of SEMMSL multiplied by SEMMNI.
The database manager requires that the number of arrays (SEMMNI) be increased as necessary.
Typically, SEMMNI should be twice the maximum number of connections allowed (MAXAGENTS) multiplied by the
number of logical partitions on the database server plus the number of local application connections
on the database server.
>> Section "Messages: Limits" covers messages on the system.
MSGMNI affects the number of agents that can be started, MSGMAX affects the size of the message that can be
sent in a queue, and MSGMNB affects the size of the queue.
To modify these kernel parameters, we need to edit the /etc/sysctl.conf file.
for example:
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 67631687680
kernel.sem=250 32000 100 128
kernel.shmmni=4096
kernel.shmall=16511642
Name Description
------ --------------------------------------------------------
SHMMAX Maximum size of shared memory segment (bytes)
SHMMIN Minimum size of shared memory segment (bytes)
SHMALL Total amount of shared memory available (bytes or pages)
SHMSEG Maximum number of shared memory segments per process
SHMMNI Maximum number of shared memory segments system-wide
SEMMNI Maximum number of semaphore identifiers (that is, sets)
SEMMNS Maximum number of semaphores system-wide
SEMMSL Maximum number of semaphores per set
SEMMAP Number of entries in semaphore map
SEMVMX Maximum value of semaphore
Thursday, November 5, 2009
(APEX) & the Embedded PL/SQL Gateway (EPG) in an 11G
After installing Oracle 11g, run the following to configure APEX
Run apxconf.sql from $ORACLE_HOME/apex
When prompted, enter the port for the Oracle XML DB HTTP server. The default port number is 8080.
Unlock the anonymous user
SQL> ALTER USER ANONYMOUS ACCOUNT UNLOCK;
You should be able to log into apex as the admin user from a browser using -> http://machine.domain:port/apex
The machine is the DB host and the port is the one input during configure step.
If you get an error and can't log in, verify the EPG is up by running the following in your browser ->
http://machine.domain:port
If it's up, you should be prompted for a username and password for XDB.
If the EPG is not up, accomplish the following to start it:
1. Log in as SYS as SYSDBA
2. Run the following statement:
3. EXEC DBMS_XDB.SETHTTPPORT(port); ==>> Where port is the plsql gatway port.
4. COMMIT;
For example:
EXEC DBMS_XDB.SETHTTPPORT(8080);
COMMIT;
Monday, November 2, 2009
How to find size of LOB
Select b.table_name,b.Column_name,c.data_type,a.Segment_name,a."size"
from
(Select Segment_name , (bytes/(1024*1024*1024)) "size"
from User_Segments
where (bytes/(1024*1024*1024))>0.5 )a,
(Select Table_name,Column_name,Segment_name
from User_Lobs)b,
(Select table_name,Column_Name,Data_type from User_Tab_Columns
Where Data_Type in ('CLOB','BLOB','LONG','LONG RAW') ) c
Where a.segment_name=b.segment_name
and b.table_name=c.table_name
and b.column_name=c.column_name
Order by c.data_type
/
Monday, October 26, 2009
RMAN Backup on the Standby Database
Running RMAN Backup on the Standby Database
We can put the standby database in good use by running the RMAN backups there along with all the good reasons we have the standby database in place.
. If your Standby database is a Physical Standby database and you are taking backups ONLY on the physical standby database.
. The data file directories on the primary and standby database are identical.
. RMAN recovery catalog is required. Since the standby database has the same DBID as the primary database and is always from the same incarnation, the RMAN datafile backups are interchangeable.
. RMAN will connect to the standby database as target database. The backups taken can be used to restore the Primary Database.
. Primary database should not use Oracle Managed Files (OMF) for this to work. If we are using OMF then the file names of Primary and Standby could differ.
Configuration required on Primary and Standby Database.
. Configure Flash Recovery Area
. Use of SPFILE
Friday, October 23, 2009
Split the file in two
I have a file with 10 lines and want to split the file in two but with even rows in one file and odd rows in one file.
sed -n '2,${p;n;}' stat1.sql > even.sql
sed -n '1,${p;n;}' stat1.sql > odd.sql
Tuesday, October 6, 2009
Update table and commit every n rows
Declare
i integer;
x NUMBER ;
v_min NUMBER ;
v_max NUMBER ;
begin
select max(EMPID) into x from EMPLOYEE ;
v_min :=0 ;
v_max :=25000 ;
loop
update EMPLOYEE set CIO_NAME = 'JOHN' where EMPID >= v_min and EMPID < v_max ;
commit ;
v_min := v_min+25000 ;
v_max := v_min+25000 ;
if v_max > (x+30000) then
commit ;
dbms_output.put_line('All rows updated successfully ....') ;
exit ;
end if ;
end loop ;
Exception When others then
dbms_output.put_line('Error Occured ...') ;
end ;
/
Monday, October 5, 2009
Sequence cache misses were consuming significant database time
Many times looking at the AWR Report, you come across "Sequence cache misses were consuming significant database time" when there is a slow performance on inserts.
Try increasing the cache size of the Sequence and use noorder if you are running a RAC database. Increasing the cache size would help improve the performance of inserts.
More details to follow on this topic ......
Monday, September 28, 2009
Flashback Table to a time in the past
Scenario: Someone deleted some data accidently from a database accidently and now wants to get back the data erroneously deleted.
Solution: You can do flashback table to a particular point in time.
(Flashback Table uses undo segments to retrieve data, so all depends if the data is still there)
Login as schema owner and enable the row movement.
SQL> alter table EMPLOYEE enable row movement;
Get time stamp to which you want to go back and then
SQL> flashback table EMPLOYEE to timestamp to_timestamp('Jan 15 2009 10:00:00','Mon DD YYYY HH24:MI:SS');
Find all files having the string in Linux
To Find all files having the string "SPECIALMAIL"
find . -exec grep -i -l "SPECIALMAIL" {} \;
-i => Ignore Case
-l => List file names only
DataPump Command EXCLUDE/INCLUDE/REMAP_SCHEMA
Export the schema but leave two of the big tables out.
expdp scott/tiger DIRECTORY=DATA_PUMP dumpfile=scott%u.dmp filesize=5G JOB_NAME=SCOTT_J1 SCHEMAS=SCOTT EXCLUDE=TABLE:\"IN \(\'EMPLOYEE\', \'DEPT\'\)\"
You exported from SCOTT schema and now wanted to import some tables into a different schema (SMITH) and into different tablespaces
impdp SMITH/PASSWORD directory=data_pump dumpfile=scott%u.dmp REMAP_SCHEMA=SCOTT:SMITH REMAP_TABLESPACE=SCOTT_DATA:SMITH_DATA REMAP_TABLESPACE=SCOTT_IDX:SMITH_IDX TABLES=TABLE1, TABLE2, TABLE3
'gcs log flush sync' resolution
1)You fired an update statement on Instance-2.
2)However, the request for desired blocks was gone to Instance-1. So Instance-2 was waiting on 'gc cr request'.
3)Instance-1 had the requested blocks but before it ships the blocks to Instance-2, it need to flush the changes from current block to redo logs on disks. Until this is done Instance-2 waits on event - 'gcs log flush sync'.
The cause of this wait event 'gcs log flush sync' is mainly - Redo log IO performance.
To avoid this problem you need to =
1)Improve the Redo log I/o performance.
2) Set undersore parameter "_cr_server_log_flush" =false.
Performance - Isolating Waits in a RAC environment
Performance - Isolating Waits in a RAC environment.
Determine the snap IDs you are interested in
For example, to obtain a list of snap IDs from the previous day, execute the following SQL:
SQL> SELECT snap_id, begin_interval_time FROM dba_hist_snapshot WHERE TRUNC(begin_interval_time) = TRUNC(sysdate-1) ;
Step 1 :
--------
Identify the Wait Class
select wait_class_id, wait_class, count(*) cnt
from dba_hist_active_sess_history
where snap_id between &1 and &2
group by wait_class_id, wait_class
order by 3;
2723168908 Idle 1
3290255840 Configuration 9
3386400367 Commit 90
4108307767 System I/O 149
3875070507 Concurrency 182
1740759767 User I/O 184
1893977003 Other 244
4217450380 Application 365
2000153315 Network 475
[NULL] [NULL] 916
3871361733 Cluster 1844
Step 2
-------
Identify the event_id associated with above wait class ID
select event_id, event, count(*) cnt from dba_hist_active_sess_history
where snap_id between 18231 and 18232 and wait_class_id=3871361733
group by event_id, event
order by 3;
EVENT_ID EVENT COUNT(*)
1742950045 gc current retry 1
3897775868 gc current multi block request 1
512320954 gc cr request 4
661121159 gc cr multi block request 9
2685450749 gc current grant 2-way 11
3201690383 gc cr grant 2-way 18
1457266432 gc current split 27
3046984244 gc cr block 3-way 41
111015833 gc current block 2-way 62
3570184881 gc current block 3-way 62
737661873 gc cr block 2-way 67
2277737081 gc current grant busy 95
1520064534 gc cr block busy 235
2701629120 gc current block busy 396
1478861578 gc buffer busy 815
Step 3
-------
Identify the SQL_ID associated with the above event_id
select 'gc buffer busy' ,sql_id, count(*) cnt from dba_hist_active_sess_history
where snap_id between 18231 and 18232
and event_id in (1478861578)
group by sql_id having count(*) > 55
UNION
select 'gc current block busy',sql_id, count(*) cnt from dba_hist_active_sess_history
where snap_id between 18231 and 18232
and event_id in (2701629120)
group by sql_id having count(*) > 55
UNION
select 'gc cr block busy',sql_id, count(*) cnt from dba_hist_active_sess_history
where snap_id between 18231 and 18232
and event_id in (1520064534)
group by sql_id having count(*) > 55
order by 2 ;
Wait Event SQL ID waits
--------------------------------------------------------------------------------------
gc buffer busy 5qwhj3nru2jtq 765
gc current block busy 5qwhj3nru2jtq 332
Step 4 :
--------
Identify the SQL statement associated with the above SQL ID
select sql_id,sql_text from dba_hist_sqltext where sql_id in ('5qwhj3nru2jtq')
Output:
INSERT INTO Component_attrMap (Component_id, key, value) VALUES (:1, :2, :3)
Step 5 :
--------
Identify the object associated with the above statement
select current_obj#, count(*) cnt from dba_hist_active_sess_history
where snap_id between 18231 and 18232
and event_id in (1478861578,2701629120)and sql_id='5qwhj3nru2jtq'
group by current_obj#
order by 2;
Obj # Count(*)
67818 1
67988 1096
Step 6 :
-------
Identify the Object associated with the above Object ID
select object_id, owner, object_name, subobject_name, object_type from dba_objects
where object_id in (67988);
OBJECT_ID OWNER OBJECT_NAME SUBOBJECT_NAME
--------- ----- ------------- --------------
67988 SCOTT COMP_ID_INDX1 INDEX
In this case creating a REVERSE KEY index provided the required solution.
Friday, September 25, 2009
Copy CRS Home from one node to another
It for some reason your CRS_HOME is messed up on node node and you unable to bring up the 'crs' then you can copy the CRS_HOME from the working node and copy it onto the node having non-working CRS_HOME.
tar the CRS_HOME from working node to non-working node, un-tar it and make the following change.
In the file $CRS_HOME/inventory/ContentsXML/oraclehomeproperties.xml
look for LOCAL_NODE NAME and change it to the node name where you have un-tar'ed the CRS_HOME
CLUSTER_INFO>
LOCAL_NODE NAME="rklx2"/>
NODE_LIST>
NODE NAME="rklx1"/>
NODE NAME="rklx2"/>
Also make sure under /etc/init.d the following files have fully qualified CRS and ORACLE Home values, if not, replace the variables with actual values.
init.cssd
init.evmd
init.crsd
How to Manually remove the OEM Agent
How to Manually remove the OEM Agent
Purpose and Scope: You are trying to de-install the old agent and then re-install the newer version of the Agent and running into various issues.
Best Method:
1) Stop the Agent (all nodes in case of RAC)
2) Go to OEM Grid Control and remove all targets associated with the host/database to be removed, which includes databases, listeners, hosts, agents.
3) Make sure to verify from the OEM Grid Control that the targets you were trying to remove are completely removed. Try looking up from Targets=>All Targets and search for the name and you should NOT see any results.
4) Go to the $AGENT_HOME and remove Agent home from Linux/Unix box.
a) $ rm –rf agent10g
b) $ rm –rf agent10gInventory
c) $ rm –f $TNS_ADMIN/oraInst.agent10g.
If you want to re-install the agent, the re-install of the agent should work without issues but if for some reason the above does not work, try executing the following steps to manually remove the agent.
You can also remove the Agent by following the Metalink Note:436679.1 on
How to Remove an Orphaned Target Using the EMDiag Kit 10.2
The above should do the trick but sometimes it is not completely removed from the repository and when you install the newer version it gives various erros.
The following method should remove it completely
1) Login to oemdb as SYS and -
select * from sysman.mgmt_targets_delete
where delete_complete_time is NULL
order by target_name
This lists all target deletions that did not complete for some reason (normally the delet_complete_time would show the timestamp of when the target was removed.
2) Find all targets that belong to the system you are having issues with
3) Run the following to complete the deletion –
exec mgmt_admin.delete_target('rklx1_rk_crs','cluster');
where ‘'rklx1_rk_crs' is the clustername and also is the “target_name column from the earlier query and “cluster” is the target_type
4) If this doesn’t work then do this –
Log into oemdb and run –
alter index SYSMAN.MGMT_STRING_METRIC_HISTORY_PK rebuild;
5) Then remove it using this procedure –
exec mgmt_admin.delete_target_internal('rklx1_rk_crs','cluster');
For the agent you could try –
exec mgmt_admin.cleanup_agent(’host.domain:3872’);
Wednesday, July 29, 2009
Script to find elapsed time based on a SQL_ID from DBA_HIST Tables
Script to find execution time based on a SQL_ID
SET LINESIZE 120
SET PAGESIZE 1000
COL executions FOR 999,999,999
COL elapsed_time FOR 999,999,999,999
COL avg_ms FOR 999999.99
COL min_ms FOR 999999.99
COL max_ms FOR 999999.99
SELECT
TO_CHAR(TRUNC(snapshot.begin_interval_time + 1/8,'HH24'),'DD-MON-YYYY HH24:MI:SS') || ' EDT' SNAP_BEGIN,
sqlstat.instance_number,
SUM(sqlstat.executions_delta) executions,
MIN(sqlstat.elapsed_time_delta / sqlstat.executions_delta / 1000) min_ms,
MAX(sqlstat.elapsed_time_delta / sqlstat.executions_delta / 1000) max_ms,
SUM(sqlstat.elapsed_time_delta) / SUM(sqlstat.executions_delta) / 1000 avg_Ms
FROM
dba_hist_sqlstat sqlstat,
dba_hist_snapshot snapshot
WHERE
sqlstat.dbid = snapshot.dbid
AND sqlstat.instance_number = snapshot.instance_number
AND sqlstat.snap_id = snapshot.snap_id
AND sqlstat.sql_id = '&1'
AND snapshot.begin_interval_time >= TO_DATE('27-JUL-2009 21:00:00','DD-MON-YYYY HH24:MI:SS')
GROUP
BY TO_CHAR(TRUNC(snapshot.begin_interval_time + 1/8,'HH24'),'DD-MON-YYYY HH24:MI:SS') || ' EDT',
sqlstat.instance_number
ORDER
BY snap_begin
/
Wednesday, July 1, 2009
Hash-Partitioned Reverse-Key Index
Hash Paritioned global indexes provides higher throughput for applications with large numbers of concurrent insertions. In some applications, new insertions into the indexes are towards the right side of the index, usually this happends when you have an index column that is a monotonically increasing sequence number. Hash Partitioned indexes can improve performance in situations where a small number of nonpartitioned index's leaf blocks are experiencing high contention in an OLTP environment. Queries that use with an equality or IN operator in the WHERE clause can benefit significantly from a hash-partitioned global index.
For monotonically increasing key situatins, reverse keying the index will spread the activity, but only across the highest partition. Hash Partitioning will distribute the workload across all the index partitions, but still with contention at each index's right edge, reverse-key hash partitioning will not only distribute the activity across all the partitions, but also spread it within each partition.
Create Index CUSTOMER_IDX1 on CUSTOMER(ZIP_CODE)
global partition by hash(ZIP_CODE)
(partition P1 tablespace TBS_INDEX_1,
partition P2 tablespace TBS_INDEX_2,
partition P3 tablespace TBS_INDEX_3,
partition P4 tablespace TBS_INDEX_4)
REVERSE
/
Friday, April 3, 2009
Wednesday, February 25, 2009
Query to find un-indexed Foreigh Key Constraints
WHERE c.constraint_name = cc.constraint_name AND c.constraint_type = 'R' MINUS SELECT i.table_name, ic.column_name, ic.column_position
FROM user_indexes i, user_ind_columns ic
WHERE i.index_name = ic.index_name )
ORDER BY table_name, column_position ;
Monday, November 24, 2008
Oracle Interconnect RAC
The cluster interconnect is a high bandwidth, low latency communication facility that connects each node to other nodes in the cluster and routes messages among the nodes. It is a key component in building the RAC system.
In case of RAC database, the cluster interconnect is used for the following high-level functions:
Monitoring Health, Status, and Synchronize messages
Transporting lock management or resource coordination messages
Moving the Cache Buffers (data blocks) from node to node.
High performance database computing involves distributing the processing across an array of cluster nodes. It requires that the cluster interconnect provide high-data rates and low-latency communication between node processes.
Here's a few ways to find information about interconnect and troubleshoot any issues...
1. select * from gv$cluster_interconnects ;
2. Using the clusterware command oifcfg:
$ oifcfg getif
eth2 100.100.90.0 global public
eth0 192.168.10.0 global cluster_interconnect
eth1 192.168.11.0 global cluster_interconnect
3. Using oradebug ipc:
sqlplus “/ as sysdba”
SQL> oradebug setmypid
SQL> oradebug ipc Information written to trace file.
The above command would dump a trace to user_dump_dest. The last few lines of the trace would indicate the IP of the cluster interconnect. Below is a sample output.
From the trace file on node1:
SSKGXPT 0×5edf558 flags SSKGXPT_READPENDING socket no 9 IP 192.168.11.1 UDP 18852
From the trace file on node2:
SSKGXPT 0×5edf558 flags SSKGXPT_READPENDING socket no 9 IP 192.168.10.2 UDP 38967
Wednesday, September 3, 2008
Who is Locking my Object ?
SELECT a.sid,a.serial#, a.username,c.os_user_name,a.terminal,c.process,
b.object_id,substr(b.object_name,1,40) object_name
from v$session a, dba_objects b, v$locked_object c
where a.sid = c.session_id
and b.object_id = c.object_id
/
Friday, June 20, 2008
How to find Database Import Speed
SELECT
SUBSTR(sql_text, INSTR(sql_text,'INTO "'),30) table_name
, rows_processed
, ROUND( (sysdate-TO_DATE(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1) minutes
, TRUNC(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60)) rows_per_minute
FROM
sys.v_$sqlarea
WHERE
sql_text like 'INSERT %INTO "%'
AND command_type = 2
AND open_versions > 0;
Wednesday, June 11, 2008
Wednesday, May 7, 2008
How to find "user commits" during a user session
You can find number of "user commits" during a particular user session. Just get the SID of the user for which you want to track the number of commits.
set lines 120
set pages 1000
col name format a25
select a.*,b.* from sys.v_$sesstat a, sys.v_$statname b
where a.STATISTIC#=b.STATISTIC#
and b.name like '%user%'
and a.sid=&input_sid
/
Friday, February 29, 2008
Basic VCS Commands
SERVICE GROUPS AND RESOURCE OPERATIONS
Configuring service groups hagrp –add|-delete|-online|-offline group_name
Modifying resources hares –add|-delete res_name type group
hares –online|-offline res_name –sys system_name
Modifying agents haagent –start|-stop agent_name –sys system_name
BASIC CONFIGURATION OPERATIONS
Service Goups hagrp -modify group_name attribute_name value
hagrp –list group_name
hagrp –value attribute_name
hares -modify res_name attribute_name value
hares -link res_name res_name
Agents haagent -display agent_name –sys system_name
hatype –modify
VCS ENGINE OPERATIONS
Starting had hastart –force|–stale system_name
hasys –force system_name
Stopping had hastop –local|-all|-force|-evacuate
hastop –sys system_name
Adding Users hauser –add user_name
STATUS AND VERIFICATION
Group Status/Verification hagrp -display group_name|–state|–resource group_name
Resources Status/Verification hares -display res_name
hares –list
hares -probe res_name –sys system_name
Agents Status/Verification haagent –list
haagent -display agent_name –sys system_name
ps –ef|grep agent_name
VCS Status hastatus –group
LLT Status/Verification lltconfig –a list
lltstat|lltshow|lltdump
GAB Status/Verification gabconfig –a
gabdiskhb –l
COMMUNICATION
Starting and Stopping LLT lltconfig –c|U
Starting and Stopping GAB gabconfig –c –n #seed number
gabconfig –U
ADMINISTERATION
Administering Group Services hagrp –clear|-flush|-switch group_name –sys system_name
Administering Resources hares –clear|-probe res_name –sys system_name
Administering Agents haagent -list
haagent -display agent_name –sys system_name
Verify Configuration hacf –verify
Monday, January 28, 2008
How to find name of your cluster in RAC environment
$CRS_HOME/bin/cemutlo -n
==>> OR
cd $CRS_HOME/bin
./ocrdump
=> this will create a text file called OCRDUMPFILE
open that file and look for this entry
[SYSTEM.css.clustername]
ORATEXT : crs_cluster
In this case, "crs_cluster" is the cluster name.
Wednesday, December 19, 2007
Foreign Key Constraint Error ORA-02298
ALTER TABLE CUST_STATUS ADD (CONSTRAINT CUST_STATUS_FK FOREIGN KEY (LOGIN) REFERENCES USERS(LOGIN))
*
ERROR at line 1:
ORA-02298: cannot validate (SCOTT.CUST_STATUS_FK) - parent keys not found
SQL> desc cust_status
Name Null? Type
----------------------------------------- -------- ----------------------------
CUSTID NOT NULL NUMBER(8)
TIMESTAMP NOT NULL DATE
STATUS NOT NULL VARCHAR2(35)
LOGIN VARCHAR2(20) ID NUMBER
SQL> desc users
Name Null? Type
----------------------------------------- -------- ----------------------------
LOGIN NOT NULL VARCHAR2(20) PASSWORD VARCHAR2(30)
LAST_NAME VARCHAR2(50)
FIRST_NAME VARCHAR2(50)
EMAIL VARCHAR2(100)
ACTIVE CHAR(1)
To find out which rows are the problem rows,
SQL> select custid,login from cust_status a
where not exists (select 'x' from users where login = a.login);
You can delete the data using...
SQL> delete from cust_status
where login is null or login not in ( select login from users )
Now you should be able to create the FK constraint.
Friday, December 7, 2007
How to test Oracle Apps after a patch
Access the Application Home Page (http://host_name:port)
This verifies Oracle HTTP Server is up and running.
Login to Apps as "SYSADMIN"
If you can get to that page, it verifies JSERV is up and running as this page is served by JServ
Once you are able to login to the Apps, this verifies your connection to the database is working.
Click on Help button on the top right portion, if you can access the help page, it verifies you connection from the front end to the database is working as that page is served by the database.
Click on the Concurrent Manager, if you get to the page where it shows all the jobs, it verifies Forms is up and running. Try submitting a job and see if it runs successfully, it proves Concurrent Manager is up and running.
Thursday, December 6, 2007
DG Failover Steps
Assumptions : Primary Database SID : CHDP1
Standby Database SID : CHDS1
flashback is on
Now the Primary datbase server crashes and no longer accessible.
Step by Step Instructions.
Login to standby database (CHDS1)
SQL> alter database recover managed standby database finish force;
SQL> alter database commit to switchover to primary;
In very urgent situations when you can not wait for some of the logs to be applied.
SQL> alter database activate standby database;
Now at this point in time your standby database (CHDS1) becomes primary databse.
After few hours, your original primary database server (which has CHDP1 database) comes back up and you wanted to make it (CHDP1) a standby database.
Login to CHDS1
SQL> select to_char(standby_became_primary_scn) from v$database;
TO_CHAR(STANDBY_BECAME_PRIMARY_SCN)
--------------------------------------------------
1234567
Login to CHDP1
SQL> startup mount;
SQL> flashback database to scn 1234567;
SQL> alter database convert to physical standby;
SQL> shutdown immediate;
SQL> startup mount;
Wednesday, December 5, 2007
Check Kernel Parameters before installing software
----- start check_OS_linux.sh -----------
echo "Checking kernel parameters..."
/sbin/sysctl -a 2>&1 | grep sem | grep -v error
/sbin/sysctl -a 2>&1 | grep shm | grep -v error
/sbin/sysctl -a 2>&1 | grep file-max | grep -v error
/sbin/sysctl -a 2>&1 | grep ip_local_port_range | grep -v error
/sbin/sysctl -a 2>&1 | grep rmem_ | grep -v error
/sbin/sysctl -a 2>&1 | grep wmem_ | grep -v error
echo "Checking OS components ..."
rpm -q binutils
rpm -q libaio
rpm -q gcc
rpm -q libstdc++
rpm -q libstdc++-devel
rpm -q gcc-c++
rpm -q glibc
rpm -q gnome-libs
rpm -q make
rpm -q pdksh
rpm -q sysstat
----------------- end script check_OS_linux.sh -----------------
To check kernel parameters for Solaris
---------------- start script check_OS_solaris.sh ----------------
/sbin/sysctl -a 2>&1 | grep sem | grep -v error
/sbin/sysctl -a 2>&1 | grep shm | grep -v error
/sbin/sysctl -a 2>&1 | grep file-max | grep -v error
/sbin/sysctl -a 2>&1 | grep ip_local_port_range | grep -v error
/sbin/sysctl -a 2>&1 | grep rmem_ | grep -v error
/sbin/sysctl -a 2>&1 | grep wmem_ | grep -v error
----------------- end script check_OS_solaris.sh ----------------
RMAN Backup types
A backup of a datafile that includes every allocated block in the file being backed up. A full backup of a datafile can be an image copy, in which case every data block is backed up. It can also be stored in a backup set, in which case datafile blocks not in use may be skipped, according to certain rules.
A full backup cannot be part of an incremental backup strategy; that is, it cannot be the parent for a subsequent incremental backup.
Incremental
An incremental backup is either a level 0 backup, which includes every block in the file except blocks compressed out because they have never been used, or a level 1 backup, which includes only those blocks that have been changed since the parent backup was taken.
A level 0 incremental backup is physically identical to a full backup. The only difference is that the level 0 backup is recorded as an incremental backup in the RMAN repository, so it can be used as the parent for a level 1 backup.
Saturday, November 17, 2007
How to start databases in a DG setup
Solution : Start up the primary database
SQL> startup
: startup mount the standby database
SQL> startup mount
Login to Primary node and start dgmgrl
DGMGRL> connect sys/password
DGMGRL> enable configuration;
DGMGRL> enable fast_start failover;
DGMGRL> show configuration;
It should show you the primary database and physical standby database
Thursday, November 1, 2007
Some Important Linux/Unix Commands
How to find bit level in Unix
$ isainfo -kv
In Linux
$ uname -a
gives you OS, version and bit level.
Find out KDE Desktop version:
konqueror --version
Find out Gnome Desktop version:
gnome-panel --version
Find out Mozilla browser version:
mozilla --version
Find out Firefox browser version:
firefox --version
Find out current Language:
set | egrep '^(LANG|LC_)'
Find out disk space usage:
df -h
Find/Estimate file space usage:
du -h
Find out version of Linux glibc:
ls -l /lib/libc-*.so /lib/libc.so*
Find out user limits:
ulimit -a
Find out installed device drivers (modules)
lsmod
Find out information about an X server:
xdpyinfo
It can find out:
• Name of display:
• Version number
• Vendor name (such as The XFree86 Project)
• Vendor release number
• And XFree86 version number
Find out information about Linux CPU
cat /proc/cpuinfo
Find out information about Linux Memory
cat /proc/meminfo
OR
free -m
OR
free -g
Find out user shell name:
ps -p $$ | tail -1 | awk '{ print $4 }'
Dump Linux kernel variables
/sbin/sysctl -a
Find out running Linux kernel version:
uname -mrs
uname -a
cat /proc/version
Dump or display memory information and swap information:
free -m
Network card and IP address information:
ifconfig -a
ifconfig -a|less
Debian / Ubuntu Linux network configuration file (all interface eth0,eth1,…ethN)
more /etc/network/interfaces
Redhat / CentOS / Fedora Linux network configuration file (eth0)
more /etc/sysconfig/network-scripts/ifcfg-eth0
Note replace eth1 for 2nd network card and so on.
Display routing information
route -n
route
Display list of all open ports
netstat -tulpn
View login related logs
tail -f /var/log/secure
vi /var/log/secure
grep 'something' /var/log/secure
View mail server related logs
tail -f /var/log/maillog
vi /var/log/maillog
grep 'something' /var/log/maillog
Find how long the system has been running
uname
w
Show who is logged on and what they are doing
w
who
Display list of tasks
top
Display all running process
ps aux
ps aux | grep process-name
Display list of all installed software on Redhat / CentOS / Fedora
rpm -qa
rpm -qa | grep 'software-name'
rpm -qa | less
Display list of all installed software on Debian / Ubuntu
dpkg --list
Once information collected it can be easily send as an email to help desk. You can use all above command to gathers information about a remote Linux system over secure ssh session (see related functions that gathers up information about a Linux and FreeBSD system). Best part is all above commands runs in non privileged