![](/img/trans.png)
[英]Ruby Rails: passing session info in a thread to a Oracle db connection
[英]Ruby on Rails Oracle DB connection
我的主數據庫是本地mysql數據庫,但是我偶爾希望直接在我的應用程序代碼中連接到Oracle數據庫。
oracle數據庫托管在另一台RHEL服務器上。
我嘗試安裝ruby-OCI8 gem不成功(錯誤:無法構建gem本機擴展。)
我想知道oracle數據庫是否必須在本地才能使用此gem,或者是否有更好的方法來實現。
gem install ruby-oci8
Building native extensions. This could take a while...
ERROR: Error installing ruby-oci8:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking for load library path...
LD_LIBRARY_PATH...
checking /opt/instantclient... yes
/opt/instantclient/libclntsh.so.11.1 looks like an instant client.
checking for cc... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-instant-client
--without-instant-client
./oraconf.rb:562:in `check_cc': RuntimeError (RuntimeError)
from ./oraconf.rb:549:in `init'
from ./oraconf.rb:1001:in `initialize'
from ./oraconf.rb:343:in `new'
from ./oraconf.rb:343:in `get'
from extconf.rb:18
ng
---------------------------------------------------
Error Message:
C compiler doesn't work correctly.
Backtrace:
./oraconf.rb:562:in `check_cc'
./oraconf.rb:549:in `init'
./oraconf.rb:1001:in `initialize'
./oraconf.rb:343:in `new'
./oraconf.rb:343:in `get'
extconf.rb:18
---------------------------------------------------
See:
* http://ruby-oci8.rubyforge.org/en/HowToInstall.html
* http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html
我檢查了mkmf.log文件:
"gcc -o conftest -I. -I/usr/lib64/ruby/1.8/x86_64-linux -I. -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fs tack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing -fPIC conftest.c -L. -L/usr/lib64 -L. -rdynamic -Wl,-export-dynamic -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc"
/usr/bin/ld: skipping incompatible /usr/lib/libruby-static.a when searching for -lruby-static
/usr/bin/ld: cannot find -lruby-static
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: int main() { return 0; }
8 /* end */
您可以按如下所示安裝ruby-oci8 gem,
LD_LIBRARY_PATH = / local / home / soundar / instantclient_11_2 gem install ruby-oci8
注意:LD_LIBRARY_PATH是由Oracle Instant Client目錄路徑設置的環境變量
看看這篇博客文章是否可以幫助您完成OCI gem的安裝http://jessehu.wordpress.com/2008/07/03/ruby-oci8-gem-available-2/
首先,您需要安裝Oracle Instant Client-選擇相應的Linux 32位或64位二進制文件。 為了安全起見,請在所有Ruby和Oracle項目中使用舊版本10.2.0.4。 安裝基本,SDK和SQL * Plus程序包。
然后,在LD_LIBRARY_PATH環境變量中包括Oracle Instant Client安裝目錄,以便Oracle Instant Client動態庫位於加載路徑中。
然后嘗試安裝ruby-oci8 gem。
然后安裝activerecord-oracle_enhanced-adapter gem,以便能夠從ActiveRecord訪問Oracle數據庫。
我已經發布了有關如何在Mac OS X上安裝ruby-oci8的說明 -大多數內容也適用於Linux(Mac上的DYLD_LIBRARY_PATH對應於Linux上的LD_LIBRARY_PATH)。
此外,我還創建了用於在Linux上自動安裝Oracle客戶端的Sprinkle配方 -也許這不是開始的最佳方法,但是如果您要構建自動化的服務器安裝腳本,則可以查看一下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.