Oracle-11g-R2
嘗試將 Windows SQL*Plus 客戶端連接到 Oracle 11g Linux 伺服器時出現錯誤 ORA-12560
我在我的 mac 上的 Centos VM 上安裝了 11g。我已經在伺服器上執行了所有東西。我已經包含了我在 cenos 上執行的以下命令。
$lsnrctl 狀態
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 23-JUN-2014 14:49:41 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hayer)(PORT=1522))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 23-JUN-2014 14:03:58 Uptime 0 days 0 hr. 45 min. 42 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/hayer/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hayer)(PORT=1522))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
我的 tnsnames.ora 文件如下:
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = hayer)(PORT = 1522)) ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = hayer)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) (SID = orcl) ) ) ~ ~ ~ ~
在 Centos 伺服器上,我也可以使用 sqlplus 登錄。我將 windows 上的 tnsnames.ora 更改為與伺服器相同。我在 windows 主機文件中添加了 oracle 主機資訊,我可以在埠 1522 上 ping oracle 主機和 telnet 主機。
我已禁用服務 iptables,因此 centos 上不存在任何類型的防火牆。
但我仍然在 Windows 客戶端上收到以下錯誤:
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 23 14:51:31 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Enter user-name: system as sysdba Enter password: ERROR: ORA-12560: TNS:protocol adapter error Enter user-name: system as sysdba Enter password: ERROR: ORA-12560: TNS:protocol adapter error
在您的 Windows 客戶端上,您需要指定 TNS 別名
@ORCL
,否則它假定您正在嘗試連接到在您的 Windows 客戶端上執行的本地數據庫,而該數據庫沒有。此外,system as sysdba
通常不使用,甚至不確定這是否有意義。SYS as sysdba
並且只是簡單system
地使用。Enter user-name: system@ORCL Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning option
如果您沒有
tnsnames.ora
在 Windows 客戶端上進行設置,您仍然可以通過 EZCONNECT 字元串@"hayer:1522/orcl"
而不是設置 tnsnames 進行連接(是的,需要引號)。Enter user-name: system@"hayer:1522/orcl" Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning option