[20170112]为什么提示不一样.txt

[20170112]为什么提示不一样.txt

--问题链接:http://www.itpub.net/thread-2074643-1-1.html
--自己也测试看看:

1.环境:
SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> startup nomount
ORACLE instance started.
Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes

--本机执行sqlplus sys as sysdba,执行如下:
SYS@book> select * from v$database;
select * from v$database
              *
ERROR at line 1:
ORA-01507: database not mounted

--使用tnsname连接:
$ rlsql sys@book as sysdba
SYS@78> select * from v$database ;
select * from v$database
              *
ERROR at line 1:
ORA-01507: database not mounted

--//很明显我没有这个问题.
--//另外如果使用远程机器连接在nomount状态下要配置静态监听.

2.我再仔细看连接,发现一个细节:
sqlplus sys/a***@hw as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 4 23:52:11 2017
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.

--//版本11.2.0.1,提示的是Connected to an idle instance.,也就是实例没用启动.相当于在我的机器上执行如下:
$ export ORACLE_SID=book1
$ rlsql
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 12 09:37:33 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SYS@book1> select * from v$database ;
select * from v$database
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

3.看到这里问题明白了,一定是ORALCE_HOME定义里面有多余的斜线存在.

--我以前提到11.2.0.4没有斜线的问题,链接:
http://blog.itpub.net/267265/viewspace-2055052/
http://blog.itpub.net/267265/viewspace-1443469/
http://blog.itpub.net/267265/viewspace-1797866/

--//我找来一台11.2.0.3的环境测试看看:

$ echo $ORACLE_HOME
/u01/app/oracle11g/product/11.2.0/db_2
$ export ORACLE_HOME=/u01/app/oracle11g/product/11.2.0/db_2/

$ rlsql
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 12 09:43:34 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ export ORACLE_HOME=/u01/app/oracle11g/product/11.2.0/db_2
$ rlsql
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 12 09:44:32 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
--//正常!!关闭数据库,模拟问题:
SYS@test> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@test> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

--//开始模拟问题,先设置环境变量加入斜线,然后启动数据库:
$ export ORACLE_HOME=/u01/app/oracle11g/product/11.2.0/db_2/

$ rlsql
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 12 10:22:40 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.

SYS@test> startup nomount
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size                  2228784 bytes
Variable Size             989859280 bytes
Database Buffers          603979776 bytes
Redo Buffers                7344128 bytes
--启动到nomount状态.

$ rlsql sys@40 as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 12 10:24:51 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Enter password:
Connected to an idle instance.

SYS@40> select * from v$database ;
select * from v$database
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

$ rlsql
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 12 10:25:15 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@test> select * from v$database ;
select * from v$database
              *
ERROR at line 1:
ORA-01507: database not mounted

--OK,模拟出来,问题一定出在你环境变量的定义,多余讨厌的斜线.

请使用浏览器的分享功能分享到微信等