Oracle 12c无法使用sqlplus连接到数据库

时间:2018-08-09 08:01:47

标签: database oracle database-connection sqlplus oracle12c

我刚刚在本地计算机和SQL Developer中安装了Oracle数据库12c,并且尝试从命令提示符启动sqlplus时出现以下错误:

get-help about_scopes

事实是,如果我跑步:

C:\WINDOWS\system32>sqlplus

SQL*Plus: Release 12.2.0.1.0 Production on Thu Aug 9 09:44:14 2018

Copyright (c) 1982, 2017, Oracle.  All rights reserved.

Enter user-name: system
Enter password:
ERROR:
ORA-12560: TNS:protocol adapter error

然后我可以成功连接:s

好的,这是我的相关文件和输出,请您尝试帮助我。

Oracle Admin安装路径:

sqlplus system/<pass>@localhost:1521/orcl.carver-as.com as sysdba

Oracle客户端安装路径:

c:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\network\admin\

c:\ oracle \ dperezd \ virtual \ product \ 12.2.0 \ dbhome_1 \ network \ admin \ listener.ora文件:

c:\oracle\client\dperezd\product\12.2.0\client_1\Network\Admin\

Sid: orcl

tnsping orcl

TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 09-AGO-2018 09:46:01

Copyright (c) 1997, 2016, Oracle.  All rights reserved.

Archivos de parßmetros utilizados:
c:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\network\admin\sqlnet.ora


Adaptador TNSNAMES utilizado para resolver el alias
Intentando contactar con (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.carver-as.com)))
Realizado correctamente (0 mseg)

C:\WINDOWS\system32>lsnrctl status

LSNRCTL for 64-bit Windows: Version 12.2.0.1.0 - Production on 09-AGO-2018 09:53:23

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

Conectßndose a (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DPEREZD.carver-as.com)(PORT=1521)))
ESTADO del LISTENER
------------------------
Alias                     LISTENER
Versi¾n                   TNSLSNR for 64-bit Windows: Version 12.2.0.1.0 - Production
Fecha de Inicio       09-AGO-2018 09:35:29
Tiempo Actividad   0 dÝas 0 hr. 17 min. 56 seg.
Nivel de Rastreo        off
Seguridad               ON: Local OS Authentication
SNMP                      OFF
Parßmetros del Listener   C:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\network\admin\listener.ora
Log del Listener          C:\oracle\dperezd\virtual\diag\tnslsnr\DPEREZD\listener\alert\log.xml
Recibiendo Resumen de Puntos Finales...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DPEREZD.carver-as.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=DPEREZD.carver-as.com)(PORT=5500))(Security=(my_wallet_directory=C:\ORACLE\DPEREZD\VIRTUAL\admin\orcl\xdb_wallet))(Presentation=HTTP)(Session=RAW))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Resumen de Servicios...
El servicio "CLRExtProc" tiene 1 instancia(s).
  La instancia "CLRExtProc", con estado UNKNOWN, tiene 1 manejador(es) para este servicio...
El servicio "orcl.carver-as.com" tiene 1 instancia(s).
  La instancia "orcl", con estado READY, tiene 1 manejador(es) para este servicio...
El servicio "orclXDB.carver-as.com" tiene 1 instancia(s).
  La instancia "orcl", con estado READY, tiene 1 manejador(es) para este servicio...
El comando ha terminado correctamente

C:\WINDOWS\system32>lsnrctl service

LSNRCTL for 64-bit Windows: Version 12.2.0.1.0 - Production on 09-AGO-2018 09:53:53

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

Conectßndose a (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DPEREZD.carver-as.com)(PORT=1521)))
Resumen de Servicios...
El servicio "CLRExtProc" tiene 1 instancia(s).
  La instancia "CLRExtProc", con estado UNKNOWN, tiene 1 manejador(es) para este servicio...
    Manejador(es):
      "DEDICATED" establecido:0 rechazado:0
         LOCAL SERVER
El servicio "orcl.carver-as.com" tiene 1 instancia(s).
  La instancia "orcl", con estado READY, tiene 1 manejador(es) para este servicio...
    Manejador(es):
      "DEDICATED" establecido:2 rechazado:0 estado:ready
         LOCAL SERVER
El servicio "orclXDB.carver-as.com" tiene 1 instancia(s).
  La instancia "orcl", con estado READY, tiene 1 manejador(es) para este servicio...
    Manejador(es):
      "D000" establecidos:0 rechazados:0 actuales:0 mßximo:1022 estado:ready
         DISPATCHER <machine: DPEREZD, pid: 12252>
         (ADDRESS=(PROTOCOL=tcp)(HOST=DPEREZD.carver-as.com)(PORT=1825))
El comando ha terminado correctamente

c:\ oracle \ dperezd \ virtual \ product \ 12.2.0 \ dbhome_1 \ network \ admin \ tsnames.ora:

# listener.ora Network Configuration File: C:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oracle\dperezd\virtual\product\12.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:C:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\bin\oraclr12.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = DPEREZD.carver-as.com)(PORT = 1521))
    )
  )

c:\ oracle \ dperezd \ virtual \ product \ 12.2.0 \ dbhome_1 \ network \ admin \ sqlnet.ora:

# tnsnames.ora Network Configuration File: C:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.carver-as.com)
    )
  )

我已经了解到设置TNS_ADMIN环境变量可能会有所帮助,所以在Windows中,我做到了:

# sqlnet.ora Network Configuration File: C:\oracle\dperezd\virtual\product\12.2.0\dbhome_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to 
# install "Software Only", this file wont exist and without the native 
# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

无济于事,问题仍然存在。

好的,我希望这些信息对任何人都有帮助。

这真的很奇怪,因为该服务已启动并且正在运行,并且ping正常,并且带有完整参数集的sqlplus可以连接,但是单独使用sqlplus不管我做什么。

谢谢。

2 个答案:

答案 0 :(得分:1)

在大多数情况下,您在本地安装上获得TNS:protocol adapter error的原因是变量ORACLE_SID的设置不正确。

例如,在我的本地安装中:

我的实际变量

CMD> set ora
ORACLE_HOME=C:\app\database_12\product\12.1.0\dbhome_1
ORACLE_SID=PRDDB

测试连接

CMD> sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Gio Ago 9 16:35:49 2018

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

Immettere il nome utente: /as sysdba

Connesso a:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> exit
Disconnesso da Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

更改ORACLE_SID

CMD> set ORACLE_SID=TEST

CMD>set ora
ORACLE_HOME=C:\app\database_12\product\12.1.0\dbhome_1
ORACLE_SID=TEST

测试连接

CMD> sqlplus

SQL*Plus: Release 12.1.0.2.0 Production on Gio Ago 9 16:36:17 2018

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

Immettere il nome utente: /as sysdba
ERROR:
ORA-12560: TNS: errore dell'adattatore del protocollo


Immettere il nome utente:

您可以检查的另一件事是PATH变量,并确保在客户回家之前已设置ORACLE_HOME

希望这会有所帮助。

答案 1 :(得分:0)

让我们这样做:
1.打开Oracle Net Configuration Assistant
2.在“本地网络服务名称配置”中选择单选按钮选项,然后单击“下一步”
3.在“重新配置”中选择单选按钮选项,然后单击下一步
4.选择要重新配置的网络服务名称,ORACLR_CONNECTION_DATA或ORCL,然后单击“下一步”
5.输入您的服务名称,如果您已安装的oracle的服务名称为ORCL,则将ORCL写入字段,然后单击下一步
6.选择要使用的协议,例如,选择TCP,然后单击“下一步”
7.输入您的Oracle数据库引擎(服务)安装所在的主机名,例如,安装在台式机或笔记本上的主机名,
   然后以localhost身份填写,并填写您的端口号(选择“使用Standar端口号1521”选项),如果使用其他端口,则填写端口号
然后单击下一步。
8.选择是,执行测试,
  如有必要,请更改用户登录
然后点击下一步
9.如果没有,请配置另一个网络服务名称,选择“否”,然后单击下一步
10.单击完成

如果要用于从MS Visual Studio在.net框架上进行连接,则应下载,提取并安装ODTwithODAC183.zip和BuildTools_Full.exe。