Oracleを実行しているサーバーがあります.IPは192.168.1.50です。レールアプリをOracleに接続できません
私のLinuxのボックスで、私はこのOracleサーバーに接続する必要があります。私は、Oracleインスタント・クライアントをインストールし、それに応じて環境変数を設定します。
OCI_INCLUDE_DIR = /ホーム/ LUC/instantclient_11_2/SDK /含ま
LD_LIBRARY_PATH = /ホーム/ LUC/instantclient_11_2
DYLD_LIBRARY_PATH = /ホーム/ LUC/instantclient_11_2/
OCI_LIB_DIR = /ホーム/ LUC/instantclient_11_2
ORACLE_HOME = /ホーム/ LUC/instantclient_11_2
私はまた、適切な宝石をインストールしました:
ruby-oci8 (2.1.0)
を210
私は私のモデルを定義し、すくいデシベルを実行したら:私のdatabase.ymlのは
rake aborted!
ORA-12154: TNS:could not resolve the connect identifier specified
oci8.c:360:in oci8lib_191.so
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/ruby-oci8-2.1.0/lib/oci8/oci8.rb:123:in `initialize'
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:319:in `new'
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:319:in `new_connection'
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:429:in `initialize'
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in `new'
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in `initialize'
/home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in `new'
....
:接続SQLPLUS
development:
adapter: oracle_enhanced
host: 192.168.1.50:1521/orcl
username: USER
password: PASS
しかし完璧に動作します:
私は、次のエラーメッセージが表示されました移行sqlplus USER/[email protected]:1521/orcl
SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 21 17:34:26 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
このconfには何かがありますか?
UPDATE
私は、コマンドラインからテストしているとの接続が正常に動作している:
ルビー-rubygems -e「 'OCI8' を必要とします。OCI8.new( 'USER'、 'PASS' 。 '192.168.1.50/ORCL')のexec( 'ユーザーからの選択*')ん| R |はr.join( '')置く; IRBから終わり」
=> OK
同じことを:
ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced", :database => "//192.168.1.50/orcl",:username => "USER",:password => "PASS")
=> OK
しかし、まだ私のレールアプリからは機能しません。
development:
adapter: oracle_enhanced
database: //192.168.1.50:1521/orcl
username: USER
password: PASS
私は両方定義されていたが、ホストを削除すると問題が解決しました。 – tamersalama