我在我的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更改为与server相同.我在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客户端上运行的本地数据库,而该客户端没有.此外,系统通常不使用sysdba,甚至不确定是否有意义.使用SYS作为sysdba和普通系统.
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
如果您的Windows客户端上没有设置tnsnames.ora,您仍然可以通过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