【问题标题】:Oracle VM and Rails: OCIError: ORA-12537: TNS:connection closedOracle VM 和 Rails:OCIError:ORA-12537:TNS:连接已关闭
【发布时间】:2014-04-12 23:10:14
【问题描述】:

我有一个使用 oracle 作为数据库的 rails 应用程序。

我曾经在我的旧机器上使用 oracle virtualbox 和 Oracle Developer Day 工具包运行它。 oracle提供的包包括Oracle数据库11g 现在我有一台新笔记本电脑,需要重新安装一切,一切顺利,但现在 oracle pack 'OTN dev day' 使用 oracle 数据库 12g。

在以完全相同的方式设置完所有内容后,我在通过 oci8 测试我的连接时遇到了这个错误:

1.9.3-p327 :001 > require 'oci8'
 => false
1.9.3-p327 :002 > c= OCI8.new('me', 'mypassword', '//localhost:1521/orcl')
OCIError: ORA-12537: TNS:connection closed
        from oci8.c:267:in oci8lib_191.bundle
        from (irb):2:in `new'
        from (irb):2
        from /Users/stephanethomas/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.14/lib/rails/commands/console.rb:47:in `start'
        from /Users/stephanethomas/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.14/lib/rails/commands/console.rb:8:in `start'
        from /Users/stephanethomas/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.14/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

在我的虚拟机中,如果我检查侦听器,一切正常:

LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 09-MAR-2014 20:26:17

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date                09-MAR-2014 19:56:48
Uptime                    0 days 0 hr. 29 min. 28 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/12.1.0/dbhome_1/log/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=80))(PROTOCOL_STACK=(PRESENTATION=HTTP)(SESSION=RAW)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=21))(PROTOCOL_STACK=(PRESENTATION=FTP)(SESSION=RAW)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
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...
Service "pdb1" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

12和11之间有什么重大变化吗?还是我在安装时遗漏了什么?

提前致谢!

【问题讨论】:

    标签: ruby-on-rails oracle oracle11g oracle12c


    【解决方案1】:

    通常对于 ora-12537,您应该会收到一堆错误消息。前面的错误信息更重要,看起来 ruby​​ 抑制了它们(不好)。

    您是否禁用了机器上的防火墙?

    否则发布 listener.ora、sqlnet.ora 和 protocol.ora 文件。

    【讨论】:

      【解决方案2】:

      原来我的 VM 配置错误,并且我的侦听器没有正确定义。 如果它发生在你身上,这是我修复它的方法:

      在虚拟盒子应用首选项 > 网络中。单击仅主机网络。 添加一个,保持所有默认。

      如下设置网络:

      Adapter 1: 
        - Bridge Adapter
        - en0: Wi-Fi
        - Premicious mode: deny
      Adapter @:
        - Host-only Adapter
        - vboxnet0
        - Allow All
      

      在服务器上,使用一行命令检查连接:

      $> sqlplus system/oracle@orcl
      

      安装完下面的gem之后,应该可以使用abe来连接了 以下:

      OCI8.new('me', 'mypassword', '//localhost:1521/orcl')
      

      另外,一段时间后服务器大小会避免启动数据库,阻止迁移或使服务器重新启动出现错误,如果您遇到这种情况,请尝试进入服务器上的以下目录:@ 987654324@ 并寻找一个非常大(10G)的.tmp文件,将其销毁并重新启动服务器。

      【讨论】:

        猜你喜欢
        • 2017-06-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-04
        • 2021-12-10
        • 2015-11-17
        • 2013-11-01
        • 2016-07-18
        相关资源
        最近更新 更多