Determine the environment variables for a running Oracle instance in Solaris and Linux

One of the important steps in troubleshooting Oracle problem is to find out whether environment variables are set correctly. For a running instance, we can use the following methods to determine the environment variables.

1. Find the process id , PID, of the Oracle process
ps -ef |grep smon

2. Get the environment variables of the Oracle process

In Solaris,
pargs -e | grep ORACLE

In Linux,
cat /proc//environ

Example in Solaris
root# ps -ef |grep -i smon |grep -v grep|awk '{print $2}'|xargs pargs -e
2362:   ora_smon_TESTDB
envp[0]: SKGP_HIDDEN_ARGS=
envp[1]: ORACLE_SPAWNED_PROCESS=1
envp[2]: _=/usr/bin/perl
envp[3]: PATH=
envp[4]: LOGNAME=oracle
envp[5]: SHELL=/usr/bin/sh
envp[6]: HOME=/home/oracle
envp[7]: PWD=/home/oracle
envp[8]: TZ=Hongkong
envp[9]: ORAENV_ASK=NO
envp[10]: ORACLE_HOME=/u01/app/oracle/product/11.1.0.7
envp[11]: LD_LIBRARY_PATH=/u01/app/oracle/product/11.1.0.7/lib
envp[12]: LD_LIBRARY_PATH_64=/u01/app/oracle/product/11.1.0.7/lib
envp[13]: LIBPATH=/u01/app/oracle/product/11.1.0.7/lib
envp[14]: TNS_ADMIN=/u01/app/oracle/product/11.1.0.7/network/admin
envp[15]: ORACLE_SID=TESTDB
envp[16]: ORA_NLS10=/u01/app/oracle/product/11.1.0.7/nls/u01/app
envp[17]: DSM_DIR=/opt/tivoli/tsm/client/ba/bin
envp[18]: DSM_CONFIG=/opt/tivoli/tsm/client/ba/bin/dsm.opt
envp[19]: DSM_LOG=/u01/app/oracle/TESTDB/backup/u01/appbase
envp[20]: NLS_LANG=AMERICAN_AMERICA.AL32UTF8
envp[21]: ORA_NET2_DESC=11,14


Example in Linux
[root@test1 ~]# cat /proc/`ps -ef |grep -i smon |grep -v grep|awk '{print $2}'`/environ | tr '\0' '\n'
HOSTNAME=test1
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=192.168.1.200 60578 22
SSH_TTY=/dev/pts/5
USER=oracle
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
ORACLE_SID=testdb2
MAIL=/var/spool/mail/oracle
PATH=
INPUTRC=/etc/inputrc
PWD=/u01/app/oracle/oradata
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/home/oracle
LOGNAME=oracle
CVS_RSH=ssh
SSH_CONNECTION=192.168.1.200 60578 192.168.1.101 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
G_BROKEN_FILENAMES=1
_=/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus
OLDPWD=/home/oracle
ORA_NET2_DESC=9,12
ORACLE_SPAWNED_PROCESS=1
SKGP_SPAWN_DIAG_PRE_FORK_TS=1305737174
SKGP_SPAWN_DIAG_POST_FORK_TS=1305737174
SKGP_HIDDEN_ARGS=
0
SKGP_SPAWN_DIAG_PRE_EXEC_TS=1305737174

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

Space is not freed after removing the file in Unix

This situation usually occurs when a file is deleted while it is still opened by some other processes. This is because when open a file opened by a process, the reference count of the file will increment by 1. Removing the file only remove the directory point to that file and it does not remove the underlying file opened by the process.

Only until the offending processes close the file, either explicitly close the file with close() or manually kill the process, the reference to the file returns to zero and space occupied by the file is freed. A common example is Oracle writing to a trace files and these trace files grows to be large. When a DBA try to free the space by removing the trace files, he may found df command does not reflect the correct result. Under most circumstances, the most easiest way to free the space from the trace files is bounce the Oracle instance.

Below is an example performed 0n Solaris 10 to demonstrate how the space allocated to a file is not freed after removing the file. 

First we check the disk usage of the tmp diretory.
testsvr$ df -h|grep -i /tmp
swap                    78G   488K    78G     1%    /tmp

We run dd command to create a file named testfile in /tmp in the background. Since we are creating a 30GB file, it takes some time complete and the background process will keep the file open.
testsvr$ nohup dd if=/dev/zero of=/tmp/testfile bs=1048576 count=307200 &
[3]     17460
testsvr$ Sending output to nohup.out
testsvr$ ls -al /tmp/testfile
-rw-r--r--   1 oracle   dba      1144528896 May 18 23:42 /tmp/testfile
testsvr$ df -h|grep -i /tmp
swap                    78G   1.9G    77G     3%    /tmp

Here we can see that the dd command is still running and the size of the /tmp/testfile is growing
testsvr$ ps -ef |grep dd
  oracle 17841 12384   0 23:42:15 pts/7       0:00 grep dd
  oracle 17460 12384   2 23:42:00 pts/7       0:15 dd if=/dev/zero of=/tmp/testfile bs=1048576 count=307200

Then we delete the file.
testsvr$ rm /tmp/testfile
testsvr$
testsvr$ ls -al /tmp/testfile
/tmp/testfile: No such file or directory

We spotted the process id 17460 is opening a file with no named filename linked to it.
testsvr$ find /proc/*/fd -type f -links 0 \! -size 0 -ls

   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/1328/fd/5
427559811 6944224 --w-------   0 oracle   dba      7110885376 May 18 23:42 /proc/17460/fd/4
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25269/fd/5
   31    8 --w-------   0 oracle   dba          1418 Apr 16 11:03 /proc/25280/fd/2
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25280/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25286/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25297/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25310/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25322/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25326/fd/5
  102    8 --w-------   0 oracle   dba          5015 May 13 14:25 /proc/25332/fd/2
 
testsvr$ df -h|grep -i /tmp
swap                    78G    10G    68G    14%    /tmp

Then we kill the process 17460.
testsvr$ kill -9 17460
testsvr$ find /proc/*/fd -type f -links 0 \! -size 0 -ls

   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/1328/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25269/fd/5
   31    8 --w-------   0 oracle   dba          1418 Apr 16 11:03 /proc/25280/fd/2
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25280/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25286/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25297/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25310/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25322/fd/5
   67    8 --w-------   0 oracle   dba           639 Dec  9 05:16 /proc/25326/fd/5
  102    8 --w-------   0 oracle   dba          5015 May 13 14:25 /proc/25332/fd/2

After killing the dd command process, the space allocated to file /tmp/testfile is freed.
testsvr$  df -h |grep -i /tmp
swap                    84G   488K    84G     1%    /tmp

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati