1

我在我的 linux 机器上安装了 Oracle Database 12.1.0.2。第一次一切正常,但是当我重新启动机器时,我无法连接到数据库并抛出此错误

ORA-12514: TNS:listener 当前不知道连接描述符中请求的服务

我的listerner.ora 文件如下:

LISTERNER=
(DESCRIPTON_LIST=
  (DESCRIPTION=
   (ADDRESS = (PROTOCOL = TCP)(HOST=oracle.localdomain)(PORT=1521))
   (ADDRESS= (PROTOCOL = IPC)(KEY=EXTPROC1521))
  )
 )
 SID_LIST_LISTENER=
  (SID_LIST=
      (SID_DESC=
           (SID_NAME=orcl)
           (ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1)
           (PROGRAM = /u01/app/oracle/product/12.1.0.2/db_1/bin/dg4odbc)
       )
   )
  DEFAULT_SERVICE_LISTERNER=(orcl.localdomain)

我的 tnsnames.ora 文件如下:

orcl=
 (DESCRIPTION=
    (ADDRESS=(PROTOCOL = TCP)(HOST=oracle.localdomain)(PORT=1521))
    (CONNECT_DATA=
      (SERVER = DEDICATED)
      (SERVICE_NAME=orcl.localdomain)
     )
   )

请帮助我解决这个问题超过 2 周。

tnsping orcl 命令给出以下输出:

TNS Ping Utility ffor Linux: Version 12.1.0.2.0 - Production on 01-DEC-2015       15:21:46
Copyright (c) 1997, 2014, Oracle. All Rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0.2/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION=
    (ADDRESS=(PROTOCOL = TCP)(HOST=oracle.localdomain)(PORT=1521))
    (CONNECT_DATA=
      (SERVER = DEDICATED)
      (SERVICE_NAME=orcl.localdomain)
     )
   )
OK (0msec)

lsnrctl status 命令给出以下输出:

[oracle@oracle ~]$ lsnrctl status

 LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 01-DEC-2015 15:38:50

 Copyright (c) 1991, 2014, Oracle.  All rights reserved.

 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.localdomain)    (PORT=1521)))
 STATUS of the LISTENER
 ------------------------
 Alias                     LISTENER
 Version                  TNSLSNR for Linux: Version 12.1.0.2.0 -Production
Start Date                01-DEC-2015 14:08:29
Uptime                    0 days 1 hr. 30 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           orcl.localdomain
Listener Parameter File   
/u01/app/oracle/product/12.1.0.2 /db_1/network/admin/listener.ora
Listener Log File         
/u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
4

1 回答 1

1

根据我们在评论中的对话,您现在可以在本地连接。您只需要启动数据库。让我详细解释一下:

要在本地连接到数据库,您不需要侦听器。您只需要它来接收远程连接

要在本地连接,您只需要ORACLE_HOMEORACLE_SID环境变量的组合。

export ORACLE_HOME=path of ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
sqlplus / as sysdba

现在,您已连接到一个空闲实例。您需要启动数据库

startup;

顺便说一句,请记住,tnsping是非常原始的。它只验证主机端口,没有别的。它不验证service_nameSID。它不确定数据库实例和数据库服务的可用性。请在此处查看比利的回复。

于 2015-12-01T11:09:10.690 回答