Chinaunix首页 | 论坛 | 博客
  • 博客访问: 217997
  • 博文数量: 57
  • 博客积分: 1376
  • 博客等级: 中尉
  • 技术积分: 658
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-09 09:51
文章分类

全部博文(57)

文章存档

2012年(1)

2011年(56)

分类: Oracle

2011-08-17 13:40:14

我在CentOS 5.5装的Oracle 10g RAC,2节点。
正常的用sqlplus连入时,会出现这样的情况:
  1. [oracle@rac1 ~]$ export ORACLE_SID=myrac1
  2. [oracle@rac1 ~]$
  3. [oracle@rac1 ~]$ sqlplus / as sysdba

  4. SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 17 11:09:35 2011

  5. Copyright (c) 1982, 2005, Oracle. All rights reserved.

  6. Connected to an idle instance.

  7. SQL>
  8. SQL>
  9. SQL> exit

然而,如果我通过tns的方式连接:
  1. [oracle@rac1 ~]$ sqlplus system/oracle@myrac1

  2. SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 17 11:09:50 2011

  3. Copyright (c) 1982, 2005, Oracle. All rights reserved.


  4. Connected to:
  5. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
  6. With the Partitioning, Real Application Clusters, OLAP and Data Mining options

  7. SQL>
  8. SQL> select inst_id, instance_name, status from gv$instance;

  9.    INST_ID INSTANCE_NAME STATUS
  10. ---------- ---------------- ------------
  11.          1 myrac1 OPEN
  12.          2 myrac2 OPEN

结果却能正确显示出我两个节点实例的正确状态。

各个节点resource的状态都是ONLINE的:

  1. [oracle@rac1 ~]$ crs_stat -t
  2. Name Type Target State Host
  3. ------------------------------------------------------------
  4. ora.myrac.db application ONLINE ONLINE rac1
  5. ora....c1.inst application ONLINE ONLINE rac1
  6. ora....c2.inst application ONLINE ONLINE rac2
  7. ora....SM1.asm application ONLINE ONLINE rac1
  8. ora....C1.lsnr application ONLINE ONLINE rac1
  9. ora.rac1.gsd application ONLINE ONLINE rac1
  10. ora.rac1.ons application ONLINE ONLINE rac1
  11. ora.rac1.vip application ONLINE ONLINE rac1
  12. ora....SM2.asm application ONLINE ONLINE rac2
  13. ora....C2.lsnr application ONLINE ONLINE rac2
  14. ora.rac2.gsd application ONLINE ONLINE rac2
  15. ora.rac2.ons application ONLINE ONLINE rac2
  16. ora.rac2.vip application ONLINE ONLINE rac2

最后,google了下,发现了这篇文章:

问题其实在于环境变量中, ORACLE_HOME里多带了斜杠造成的。
  1. [oracle@rac1 ~]$ env
  2. ORA_CRS_HOME=/opt/oracle//product/crs/
  3. HOSTNAME=rac1
  4. TERM=vt100
  5. SHELL=/bin/bash
  6. HISTSIZE=1000
  7. TMPDIR=/tmp
  8. SSH_CLIENT=192.168.0.98 3141 22
  9. ORACLE_OWNER=oracle
  10. SSH_TTY=/dev/pts/1
  11. USER=oracle
  12. LD_LIBRARY_PATH=/opt/oracle//product/10.2.0/db1/lib:
  13. 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:
  14. ORACLE_SID=myrac1
  15. ORACLE_BASE=/opt/oracle/
  16. MAIL=/var/spool/mail/oracle
  17. PATH=/opt/oracle//product/10.2.0/db1/bin:/opt/oracle//product/crs//bin:/opt/oracle//product/10.2.0/db1/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
  18. INPUTRC=/etc/inputrc
  19. PWD=/home/oracle
  20. LANG=en_US.UTF-8
  21. SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
  22. SHLVL=1
  23. HOME=/home/oracle
  24. TMP=/tmp
  25. LOGNAME=oracle
  26. CVS_RSH=ssh
  27. SSH_CONNECTION=192.168.0.98 3141 192.168.0.31 22
  28. LESSOPEN=|/usr/bin/lesspipe.sh %s
  29. ORACLE_HOME=/opt/oracle//product/10.2.0/db1
  30. G_BROKEN_FILENAMES=1
  31. _=/bin/env

正是由于这个原因,产生了上面的问题:
以下是测试:
  1. [oracle@rac1 ~]$ export ORACLE_HOME=$ORACLE_BASE//product/10.2.0/db1
  2. [oracle@rac1 ~]$ echo $ORACLE_HOME
  3. /opt/oracle//product/10.2.0/db1
  4. [oracle@rac1 ~]$
  5. [oracle@rac1 ~]$
  6. [oracle@rac1 ~]$
  7. [oracle@rac1 ~]$ export ORACLE_SID=myrac1
  8. [oracle@rac1 ~]$
  9. [oracle@rac1 ~]$ sqlplus / as sysdba

  10. SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 17 13:04:46 2011

  11. Copyright (c) 1982, 2005, Oracle. All rights reserved.

  12. Connected to an idle instance.

  13. SQL>
  14. SQL>
  15. SQL>
  16. SQL> exit
  17. Disconnected
  18. [oracle@rac1 ~]$
  19. [oracle@rac1 ~]$
  20. [oracle@rac1 ~]$ export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db1
  21. [oracle@rac1 ~]$
  22. [oracle@rac1 ~]$
  23. [oracle@rac1 ~]$ echo $ORACLE_HOME
  24. /opt/oracle/product/10.2.0/db1
  25. [oracle@rac1 ~]$
  26. [oracle@rac1 ~]$
  27. [oracle@rac1 ~]$
  28. [oracle@rac1 ~]$
  29. [oracle@rac1 ~]$ export ORACLE_SID=myrac1
  30. [oracle@rac1 ~]$ sqlplus / as sysdba

  31. SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 17 13:05:27 2011

  32. Copyright (c) 1982, 2005, Oracle. All rights reserved.


  33. Connected to:
  34. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
  35. With the Partitioning, Real Application Clusters, OLAP and Data Mining options

  36. SQL> select instance_name, status from gv$instance;

  37. INSTANCE_NAME STATUS
  38. ---------------- ------------
  39. myrac1 OPEN
  40. myrac2 OPEN

  41. SQL>

原来,认为多几个斜线对结果应该不会造成什么影响:
  1. [oracle@rac1 ~]$ pwd
  2. /home/oracle

  3. [oracle@rac1 ~]$ cd /opt/////////oracle
  4. [oracle@rac1 oracle]$ pwd
  5. /opt/oracle
  6. [oracle@rac1 oracle]$

但是,应该是oracle进程在认环境不变量时,还是比较认死理。。。认为路径就是那个,多一个少一个斜杠不行。

这个问题比较有意思,一直猜想是bug,结果却是个小问题造成的。。。又长见识了。。。
阅读(1508) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~