【问题标题】:Oracle TNS error with Ruby on Rails Rake commandRuby on Rails Rake 命令的 Oracle TNS 错误
【发布时间】:2016-04-21 10:29:42
【问题描述】:

我正在尝试使用 Ruby on Rails Rake 命令迁移到 Oracle 数据库。我的database.yml 文件包含以下内容:

development:
    adapter: oracle
    database: album_development
    sid: orc1          
    username: system
    password: root

在我的电脑上我设置了ORACLE_SID=orcl.

当我运行 Rake,migrate 时,我收到以下错误:

rake aborted!
The driver encountered an error: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

您能否告诉我是否需要修改我的listener.ora 文件才能使其正常工作?我的listener.ora文件如下:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = Lenovo-PC)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

lsnrctl Status 命令的输出如下:

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.2.0 - Production
Start Date                21-APR-2016 11:14:15
Uptime                    0 days 0 hr. 7 min. 43 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\listener.ora
Listener Log File         C:\oraclexe\app\oracle\diag\tnslsnr\Lenovo-PC\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lenovo-PC)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lenovo-PC)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

任何人都可以帮助/提出建议吗?

【问题讨论】:

  • 您是否尝试过连接到 xe 而不是 orcl 例如 sid: xe
  • 是的,我用 sid: xe 试过了,也不行
  • 错别字 orc1 \ orcl ???
  • orc1 或 orcl 都不起作用

标签: ruby-on-rails oracle rake tns


【解决方案1】:

首先您可以使用TNSPING 命令检查数据库是否可以访问

例如:TNSPING xe

你可能使用了 one 而不是 L sid: orc1 应该是 sid: orcl 吗?

【讨论】:

  • 凯文,感谢您的回复。我跑了命令,结果如下;适用于 32 位 Windows 的 TNS Ping 实用程序:版本 11.2.0.2.0 - 生产日期为 2016 年 4 月 21 日 13:04:16 版权所有 (c) 1997, 2010, Oracle。版权所有。使用的参数文件:C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\sqlnet.ora 使用 TNSNAMES 适配器解析别名 Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)( HOST = Lenovo-PC)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE))) OK (10 ms)
  • 如果您将 database.yml 更改为指向 xe 而不是 orcl 是否有效?
【解决方案2】:

凯文,

感谢您的帮助。我将我的database.yml 更改为:

development:

  adapter: oracle
  database: xe
  username: system
  password: root

这允许我连接到数据库。我现在有另一个问题,但我想我可以解决这个问题。亲切的问候,肖恩

【讨论】:

    猜你喜欢
    • 2013-02-13
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 2013-03-21
    • 2011-04-29
    • 2013-12-28
    • 1970-01-01
    相关资源
    最近更新 更多