ITPub博客

首页 > 数据库 > Oracle > sqlplus无法登录Oracle实例

sqlplus无法登录Oracle实例

原创 Oracle 作者:中奖1000万 时间:2017-06-17 21:33:40 1 删除 编辑
今天登录数据库的时候遇到无法连接到数据库实例的问题,具体如下:
[oracle@yq ~]$
[oracle@yq ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon May 22 04:22:14 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected.
SQL>
SQL>
SQL>
SQL> exit
Disconnected
查看一下后台进程都正常的
[oracle@yq ~]$ ps -ef|grep ora_
oracle    9505     1  0 03:23 ?        00:00:00 ora_pmon_orcl
oracle    9507     1  0 03:23 ?        00:00:05 ora_psp0_orcl
oracle    9509     1  0 03:23 ?        00:00:04 ora_vktm_orcl
oracle    9513     1  0 03:23 ?        00:00:00 ora_gen0_orcl
oracle    9515     1  0 03:23 ?        00:00:00 ora_diag_orcl
oracle    9517     1  0 03:23 ?        00:00:00 ora_dbrm_orcl
oracle    9519     1  0 03:23 ?        00:00:02 ora_dia0_orcl
oracle    9521     1  0 03:23 ?        00:00:00 ora_mman_orcl
oracle    9523     1  0 03:23 ?        00:00:00 ora_dbw0_orcl
oracle    9525     1  0 03:23 ?        00:00:00 ora_lgwr_orcl
oracle    9527     1  0 03:23 ?        00:00:01 ora_ckpt_orcl
oracle    9529     1  0 03:23 ?        00:00:00 ora_smon_orcl
oracle    9531     1  0 03:23 ?        00:00:00 ora_reco_orcl
oracle    9533     1  0 03:23 ?        00:00:00 ora_mmon_orcl
oracle    9535     1  0 03:23 ?        00:00:01 ora_mmnl_orcl
oracle    9537     1  0 03:23 ?        00:00:00 ora_d000_orcl
oracle    9539     1  0 03:23 ?        00:00:00 ora_s000_orcl
oracle   10176     1  0 03:50 ?        00:00:00 ora_nss2_orcl
oracle   10178     1  0 03:50 ?        00:00:00 ora_arc0_orcl
oracle   10180     1  0 03:50 ?        00:00:00 ora_arc1_orcl
oracle   10182     1  0 03:50 ?        00:00:00 ora_arc2_orcl
oracle   10184     1  0 03:50 ?        00:00:00 ora_arc3_orcl
oracle   10487     1  0 04:15 ?        00:00:00 ora_mrp0_orcl
oracle   10675 10645  0 04:22 pts/3    00:00:00 grep ora_
[oracle@yq ~]$
因为之前也遇到过这个问题,是环境变量导致的,所以检查了环境变量。
[oracle@yq ~]$
[oracle@yq ~]$ echo $ORACLE_SID
orcl
[oracle@yq ~]$ echo $ORACLE_BASE
/oracle/app/oracle
[oracle@yq ~]$ echo $ORACLE_HOME
/oracle/app/oracle/product/11.2.0/dbhome_1
很显然,环境变量木有问题。那么问题到底出在什么地方呢?
先检查监听,监听正常。
[oracle@yq01 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 22-MAY-2017 04:36:24
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.109)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                22-MAY-2017 03:23:30
Uptime                    0 days 1 hr. 12 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/diag/tnslsnr/yq01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.109)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_sty" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
 
 再次尝试登录一下,还是无法登录。
[oracle@yq ~]$
[oracle@yq ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon May 22 04:22:52 2017
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected.
SQL>
SQL> exit
Disconnected
[oracle@yq ~]$
既然Oracle的环境变量没有问题,那么我就怀疑是操作系统层面的问题了。
检查一下主机名称
[oracle@yq ~]$ hostname
yq
[oracle@yq ~]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=yq01
发现问题,主机名称与network里面的不一致,有没有可能就是这个问题?
这时候我就需要查看一下监听文件里面配置的信息了。
[oracle@yq01 ~]$ cat /oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
stener.ora Network Configuration File: /oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME =/oracle/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = ORCL)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.109)(PORT = 1521))
    )
)
检查主机hosts配置
[oracle@yq01 ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.109   yq01
好吧,发现问题了,先解决问题。
修改主机名称和hosts里面的配置一致
[root@yq ~]# hostname yq01
修改后断开连接重连后查看
[root@yq01 ~]# hostname
yq01
[root@yq01 ~]#
再次登录数据库,成功。
[root@yq01 ~]# su - oracle
[oracle@yq01 ~]$
[oracle@yq01 ~]$
[oracle@yq01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Mon May 22 04:28:10 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
SQL>
SQL>
问题总结:使用sqlplus连接数据库时,是通过监听去连接的,我这里的监听找不到正确的监听地址,所以无法登录数据库实例。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31467250/viewspace-2140896/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2017-06-09

  • 博文量
    25
  • 访问量
    40575