当我们使用sqlplus本地登录oracle数据库时,设置的环境变量ORACLE_HOME和oracle启动时的环境变量ORACLE_HOME不一致时,会出现连接报错。
那么有什么办法可以看到oracle当时启动时的环境变量设置呢?总结一下:
Solaris:使用pargs –e
oracle@/proc/5032>uname -a
SunOS pcsweb-a 5.10 Generic_139556-08 i86pc i386 i86pc
oracle@/oracle>ps -ef|grep smon
oracle 2217410 21:21:43 ?55348:14 ora_smon_PCSWEB
oracle503210 13:39:21 ?0:04 ora_smon_PRECARD
oracle 29615 241030 15:25:26 pts/40:00 grep smon
oracle@/oracle>pargs -e 5032
5032:ora_smon_PRECARD
envp[0]: SKGP_HIDDEN_ARGS=
envp[1]: ORACLE_SPAWNED_PROCESS=1
envp[2]: _=/oracle/product/10.2.0/bin/sqlplus
envp[3]: TMPDIR=/oracle/tmp
envp[4]: LANG=zh
envp[5]: TEMP=/oracle/tmp
envp[6]: HZ=
envp[7]: PATH=
envp[8]: NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
envp[9]: ORACLE_BASE=/oracle
envp[10]: LOGNAME=oracle
envp[11]: LIBPATH=/oracle/product/10.2.0/lib:/oracle/product/10.2.0/network/lib:
envp[12]: MAIL=/var/mail/oracle
envp[13]: ORACLE_SID=PRECARD
envp[14]: PS1=$LOGNAME@$PWD>
envp[15]: DISPLAY=localhost:0.0
envp[16]: SHELL=/bin/ksh
envp[17]: ORACLE_TERM=vt100
envp[18]: HOME=/oracle
envp[19]: LD_LIBRARY_PATH=/oracle/product/10.2.0/lib:/oracle/product/10.2.0/network/lib:
envp[20]: TERM=vt100
envp[21]: ORACLE_HOME=/oracle/product/10.2.0
envp[22]: PWD=/oracle/admin/PRECARD/pfile
envp[23]: TZ=PRC
envp[24]: ORA_NET2_DESC=10,13
AIX:使用ps eww
oracle@ibmvs_a@/oracle $ uname -a
AIX ibmvs_a 3 5 0001571DD600
oracle@ibmvs_a@/oracle $ ps -ef|grep smon
oracle31133610Mar 02-4:13 ora_smon_MS
oracle24613610Mar 02-4:08 ora_smon_PS
oracle42645610Mar 21-2:57 ora_smon_BOCPCS
oracle50021810Mar 16-3:00 ora_smon_BOCT
oracle 114319610Apr 01-3:12 ora_smon_HT
oracle 20279267869240 15:25:50pts/00:00 grep smon
oracle@ibmvs_a@/oracle $ ps eww 311336
PIDTTY STATTIME COMMAND
311336- A4:13 ora_smon_MS _=/oracle/product/10.2.0/bin/sqlplus TMPDIR=/tmp LANG=en_US LOGIN=oracle NLS_CHARACTERSET=zhs16gbk SSH_TTY=/dev/pts/2 PATH= NLS_LANG=AMERICAN_AMERICA.ZHS16GBK ORACLE_BASE=/oracle LC__FASTMSG=true SSH_AUTH_SOCK=/tmp/ssh-WLRn258456/agent.258456 COBPATH=/opt/lib/cobol:/linc/ROC17:/linc/ADHOC17:/linc/LINC17 LOGNAME=oracle MAIL=/usr/spool/mail/oracle LINCII_BIND_DIR=/tmp COBDIR=/opt/lib/cobol ORACLE_SID=MS LOCPATH=/usr/lib/nls/loc USER=oracle AUTHSTATE=compat SHELL=/usr/bin/ksh DMDIR=/etc/objrepos HOME=/oracle SSH_CONNECTION=192.168.70.122 2339 192.168.100.193 22 SSH_CLIENT=192.168.70.122 2339 22 TERM=vt100 MAILMSG=[YOU HAVE NEW MAIL] ORACLE_HOME=/oracle/product/10.2.0 LINCIIDIR=/linc PWD=/oracle/product/10.2.0/dbs TZ=BEIST-8 A__z=! LOGNAME ORA_NET2_DESC=8,11 ORACLE_SPAWNED_PROCESS=1 SKGP_HIDDEN_ARGS= NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat LIBPATH=/oracle/product/10.2.0/lib32:/oracle/product/10.2.0/network/lib:/opt/lib/cobol/lib LD_LIBRARY_PATH=/oracle/product/10.2.0/lib32:/oracle/product/10.2.0/network/lib:/opt/lib/cobol/lib
使用ps eww可以看到进程启动时的环境变量,不过都在一行显示,看起来很不方便。
可以使用如下命令查看:
oracle@ibmvs_a@/oracle $ ps eww 311336|tr -s " " "\n"|grep ORACLE_HOME
ORACLE_HOME=/oracle/product/10.2.0
LINUX:使用strings -a /proc//environ
oracle@mail@/oracle $ uname -a
Linux mail 2.6.18-128.el5 #1 SMP Wed Dec 17 11:42:39 EST 2008 i686 i686 i386 GNU/Linux
oracle@mail@/oracle $ ps -ef|grep smon
oracle333610 Apr11 ?00:01:56 ora_smon_secdb
oracle19524 194920 15:24 pts/200:00:00 grep smon
oracle@mail@/oracle $ls -l/proc/3336/
total 0
dr-xr-xr-x 2 oracle dba 0 Jun 16 15:25 attr
-r-------- 1 oracle dba 0 Jun 16 15:25 auxv
-r--r--r-- 1 oracle dba 0 Jun 16 11:17 cmdline
-rw-r--r-- 1 oracle dba 0 Jun 16 15:25 coredump_filter
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 cpuset
lrwxrwxrwx 1 oracle dba 0 Jun 16 15:25 cwd -> /oracle/product/10.2.0/dbs
-r-------- 1 oracle dba 0 Jun 16 15:25 environ
lrwxrwxrwx 1 oracle dba 0 Jun 16 15:25 exe -> /oracle/product/10.2.0/bin/oracle
dr-x------ 2 oracle dba 0 Jun 16 15:25 fd
-r-------- 1 oracle dba 0 Jun 16 15:25 limits
-rw-r--r-- 1 oracle dba 0 Jun 16 15:25 loginuid
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 maps
-rw------- 1 oracle dba 0 Jun 16 15:25 mem
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 mounts
-r-------- 1 oracle dba 0 Jun 16 15:25 mountstats
-rw-r--r-- 1 oracle dba 0 Jun 16 15:25 oom_adj
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 oom_score
lrwxrwxrwx 1 oracle dba 0 Jun 16 15:25 root -> /
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 schedstat
-r-------- 1 oracle dba 0 Jun 16 15:25 smaps
-r--r--r-- 1 oracle dba 0 Jun 16 10:57 stat
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 statm
-r--r--r-- 1 oracle dba 0 Jun 16 15:24 status
dr-xr-xr-x 3 oracle dba 0 Jun 16 15:25 task
-r--r--r-- 1 oracle dba 0 Jun 16 15:25 wchan
oracle@mail@/oracle $ strings -a /proc/3336/environ
_=/oracle/product/10.2.0/bin/sqlplus
CVS_RSH=ssh
G_BROKEN_FILENAMES=1
HISTSIZE=1000
HOME=/oracle
HOSTNAME=mail
INPUTRC=/etc/inputrc
LANG=en_US
LD_LIBRARY_PATH=/oracle/product/10.2.0/lib32:/oracle/product/10.2.0/network/lib:
LESSOPEN=|/usr/bin/lesspipe.sh %s
LIBPATH=/oracle/product/10.2.0/lib32:/oracle/product/10.2.0/network/lib:
LOGNAME=oracle
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
MAIL=/var/spool/mail/oracle
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
ORACLE_HOME=/oracle/product/10.2.0
ORACLE_SID=secdb
PATH=
PWD=/oracle
SHELL=/bin/ksh
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
TERM=vt100
USER=oracle
ORA_NET2_DESC=8,11
ORACLE_SPAWNED_PROCESS=1
SKGP_HIDDEN_ARGS=
oracle@mail@/oracle $strings -a /proc/3336/environ|grep ORACLE_HOME
ORACLE_HOME=/oracle/product/10.2.0