事情是这样的.
本人是oracle 初学者
oracle 11g装在了虚拟机(redhat 5.4)上. 实体机也是linux系统.我在虚拟机上
用sqlplus / as sysdba 命令是正常登陆的.实体机上用sqldeveloper 连接虚拟机的数据库, 也是正常的.
但是在实体机上执行sqlplus 远程登陆时会出现ora-12514 错误
sqlplus hr/[email protected]:1521/orclgateman@TFPC Programs $ sqlplus hr/[email protected]:1521/orclSQL*Plus: Release 12.1.0.1.0 Production on Sat Oct 5 22:14:09 2013Copyright (c) 1982, 2013, Oracle.  All rights reserved.ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Enter user-name: ^C
gateman@TFPC Programs $
这个语句就算在虚拟机上执行都会报同样的错误.
网上查找了很久都找不到解决方法. 有大神能帮忙看看吗? 谢谢下面我会把 listener.ora tnsname.ora 都贴出来:listener.ora
[oracle@TPRHEL admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/project/11.2.0/db_home1/oracle/network/admin/listener.ora
# Generated by Oracle configuration tools.LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
  )SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl_dbn)
      (ORACLE_HOME = /u01/app/oracle/project/11.2.0/db_home1/oracle)
      (SID_NAME = orcl)
    )
  )ADR_BASE_LISTENER = /u01/app/oracle/project[oracle@TPRHEL admin]$ tnsname.ora
[oracle@TPRHEL admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/project/11.2.0/db_home1/oracle/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.localdomain)
    )
  )[oracle@TPRHEL admin]$ 
lsnrctl 监听状态
[oracle@TPRHEL admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-OCT-2013 22:15:39Copyright (c) 1991, 2009, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                05-OCT-2013 22:04:39
Uptime                    0 days 0 hr. 11 min. 2 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/project/11.2.0/db_home1/oracle/network/admin/listener.ora
Listener Log File         /u01/app/oracle/project/diag/tnslsnr/TPRHEL/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "orcl.localdomain" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.localdomain" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl_dbn" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@TPRHEL admin]$ lsnrctl serviceLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-OCT-2013 22:16:07Copyright (c) 1991, 2009, Oracle.  All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl.localdomain" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:2 refused:0 state:ready
         LOCAL SERVER
Service "orclXDB.localdomain" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER <machine: TPRHEL, pid: 3088>
         (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=65294))
Service "orcl_dbn" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully
[oracle@TPRHEL admin]$ 十分感谢..远程连接数据库虚拟机oracle 11g

解决方案 »

  1.   

    我也遇到了类似的问题,不能远程登录,在服务器上用这种写法:sqlplus hr/[email protected]:1521/orcl 不能登录报的错是 ORA-12541: TNS: 无监听程序把 192.168.1.105 改成 127.0.0.1 反而可以正常登录。是不是11g的某些功能被限制了?
      

  2.   

    我也遇到类似的问题,本机的ip是10.0.0.16,系统是64位的win7,oracle是64位11g,命令行使用sqlplus 用户名/密码@服务器  登陆没有问题,但是在测试tnsping 的时候出问题了,通过其他电脑连接也出问题ora-12541C:\Users\Administrator>tnsping 127.0.0.1TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 08-10月-
    2013 09:22:49Copyright (c) 1997, 2010, Oracle.  All rights reserved.已使用的参数文件:
    d:\app\zhongya\product\11.2.0\dbhome_1\network\admin\sqlnet.ora已使用 EZCONNECT 适配器来解析别名
    尝试连接 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST
    =127.0.0.1)(PORT=1521)))
    OK (0 毫秒)C:\Users\Administrator>tnsping 10.0.0.16TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 08-10月-
    2013 09:23:01Copyright (c) 1997, 2010, Oracle.  All rights reserved.已使用的参数文件:
    d:\app\zhongya\product\11.2.0\dbhome_1\network\admin\sqlnet.ora已使用 EZCONNECT 适配器来解析别名
    尝试连接 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST
    =10.0.0.16)(PORT=1521