Home >Database >Mysql Tutorial >Oracle环境变量引发“Connected to an idle instance.”错误

Oracle环境变量引发“Connected to an idle instance.”错误

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:55:251780browse

在Oracle数据库系统中,用户如果要以特权用户身份(SYSDBA/SYSOPER)登录Oracle数据库可以有两种身份验证的方法: 即使用与操

问题现象:
[root@db1 ~]# id root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
//Oralce用户权限属于dba组,可以以OS身份登陆数据库中。
 
[root@db1 ~]# id Oracle
uid=110(oracle) gid=110(oinstall) groups=110(oinstall),111(dba)
//root用户权限属于dba组,不能OS身份登陆数据库。 
 
[oracle@db1 ~]$ sqlplus sys@zddb1 as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Fri May 29 10:18:17 2009
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Enter password:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> show parameter instance_name
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      zddb1
SQL>

 
[oracle@db1 ~]$ ps -ef |grep ora_
oracle   11821     1  0 09:52 ?        00:00:00 ora_q002_zddb1
oracle   17047     1  0 May27 ?        00:00:13 ora_j002_zddb1
oracle   17935     1  0 May28 ?        00:00:01 ora_j001_zddb1
oracle   18755     1  0 May28 ?        00:00:00 ora_pz98_zddb1
oracle   20089     1  0 May27 ?        00:00:01 ora_pmon_zddb1
oracle   20091     1  0 May27 ?        00:00:00 ora_diag_zddb1
oracle   20093     1  0 May27 ?        00:00:00 ora_psp0_zddb1
oracle   20095     1  0 May27 ?        00:00:03 ora_lmon_zddb1
oracle   20097     1  0 May27 ?        00:00:09 ora_lmd0_zddb1
oracle   20100     1  0 May27 ?        00:00:11 ora_lms0_zddb1
oracle   20104     1  0 May27 ?        00:00:13 ora_lms1_zddb1
oracle   20108     1  0 May27 ?        00:00:00 ora_mman_zddb1
oracle   20110     1  0 May27 ?        00:00:04 ora_dbw0_zddb1
oracle   20112     1  0 May27 ?        00:00:06 ora_lgwr_zddb1
oracle   20114     1  0 May27 ?        00:00:16 ora_ckpt_zddb1
oracle   20116     1  0 May27 ?        00:00:05 ora_smon_zddb1
oracle   20118     1  0 May27 ?        00:00:00 ora_reco_zddb1
oracle   20120     1  0 May27 ?        00:00:41 ora_cjq0_zddb1
oracle   20122     1  0 May27 ?        00:00:10 ora_mmon_zddb1
oracle   20124     1  0 May27 ?        00:00:11 ora_mmnl_zddb1
oracle   20126     1  0 May27 ?        00:00:00 ora_d000_zddb1
oracle   20128     1  0 May27 ?        00:00:00 ora_s000_zddb1
oracle   20137     1  0 May27 ?        00:00:09 ora_lck0_zddb1
oracle   20201     1  0 May27 ?        00:00:00 ora_arc0_zddb1
oracle   20203     1  0 May27 ?        00:00:01 ora_arc1_zddb1
oracle   20229     1  0 May27 ?        00:00:22 ora_pz99_zddb1
oracle   20265     1  0 May27 ?        00:00:00 ora_qmnc_zddb1
oracle   20301     1  0 May27 ?        00:00:47 ora_j000_zddb1
oracle   20404     1  0 May27 ?        00:00:06 ora_q000_zddb1
oracle   24015 23925  0 10:19 pts/5    00:00:00 grep ora_
[oracle@db1 ~]$
//数据库运行正常,,通过Listeners能够正常连接。
 
 
[root@db1 ~]# export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1/
[root@db1 ~]# export ORACLE_SID=zddb1
[root@db1 ~]# sqlplus
-bash: sqlplus: command not found
[root@db1 ~]# /u01/app/oracle/product/10.2.0/db_1/bin/sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.4.0 - Production on Fri May 29 09:58:12 2009
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
ERROR:
ORA-01031: insufficient privileges

Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
//root用户连接结果正常
 
[root@db1 ~]# su - oracle
[oracle@db1 ~]$ export ORACLE_SID=zddb1
[oracle@db1 ~]$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1/
[oracle@db1 ~]$ /u01/app/oracle/product/10.2.0/db_1/bin/sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.4.0 - Production on Fri May 29 09:59:03 2009
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Connected to an idle instance.
SQL>
//Oracle用户连接结果异常 

 
问题分析:
   在Oracle数据库系统中,用户如果要以特权用户身份(SYSDBA/SYSOPER)登录Oracle数据库可以有两种身份验证的方法: 即使用与操作系统集成的身份验证或使用Oracle数据库的密码文件进行身份验证。因root用户因不在dba组,显示权限不足,结果是正常的,但Oracle用户应该可以使用sysdba的身份登陆到数据库中,但却显示:“Connected to an idle instance. ” ,即不能登陆到数据库中。但从操作系统中查看,使用网络连接方式,却可以连接。排除了tnsnames.ora配置错误,问题比较奇怪。

   通过网友的提醒发现环境变量设置出现问题

[oracle@db1 ~]$ cat .bash_profile
# .bash_profile# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/app/oracle/
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1
export ORACLE_SID=zddb1export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:$PATH:$HOME/bin

处理过程和结果:
   在ORACLE_BASE环境变量后面多了"/",会不会是此问题引起?重新设置此变量为“export ORACLE_BASE=/u01/app/oracle”,删除了“/”,登陆数据库,连接正常。
 
   希望此文能对大家有所帮助。

   感谢网友海浪的提醒。

疑问:
  问题虽然解决了,但不明白这个“/”符号为什么会影响到数据库的连接呢,是由于他找不到数据库初始化参数? 还是数据库bug呢?

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn