2013-10-31 158 views
1

我正在安裝Oracle Instant Client:基本,SDK和SQL * Plus軟件包v 10.2.0.5。如何在centOS上安裝ruby-oci8?

mkdir /opt 
mkdir /opt/oracle 
cd /opt/oracle 
unzip path/to/instantclient-basic-OS-VERSION.zip 
unzip path/to/instantclient-sdk-OS-VERSION.zip 
unzip path/to/instantclient-sqlplus-OS-VERSION.zip 

之後,我設置vim ~/.oracle_client

export ORACLE_HOME=/opt/oracle/ 
    export TNS_ADMIN=/admin/network/ 
    export LD_LIBRARY_PATH="/opt/oracle/instantclient_10_2/" 

回聲 「源〜/ .oracle_client」 >>〜/ .bash_profile中 源〜/ .bash_profile中

創建的tnsnames.ora和測試連接sqlplus opsvod/agatb137 @ FESTEST

SQL*Plus: Release 10.2.0.5.0 - Production on Thu Oct 31 14:55:17 2013 

Copyright (c) 1982, 2010, Oracle. All Rights Reserved. 


Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

SQL> 

但是whan it ry安裝gem install ruby-oci8 -v '2.1.5'我有錯誤:

Building native extensions. This could take a while... 
ERROR: Error installing ruby-oci8: 
     ERROR: Failed to build gem native extension. 

    /usr/local/bin/ruby extconf.rb 
checking for load library path... 
    LD_LIBRARY_PATH... 
    checking /opt/oracle/instantclient_10_2/... skip: /opt/oracle/instantclient_10_2/libclntsh.so.10.1 is for i386 cpu. 
    checking ld.so.conf... skip: /opt/oracle/instantclient_10_2/libclntsh.so.10.1 is for i386 cpu. 
no 
checking for cc... ok 
checking for gcc... yes 
checking for LP64... yes 
checking for sys/types.h... yes 
checking for ruby header... ok 
Get the version of Oracle from SQL*Plus... *** 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 
     --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/local/bin/ruby 
     --with-instant-client 
     --without-instant-client 
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version': RuntimeError (RuntimeError) 
     from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize' 
     from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new' 
     from /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get' 
     from extconf.rb:18:in `<main>' 
--------------------------------------------------- 
Error Message: 
    cannot get Oracle version from sqlplus 
Backtrace: 
    /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:760:in `get_version' 
    /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:709:in `initialize' 
    /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `new' 
    /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/oraconf.rb:320:in `get' 
    extconf.rb:18:in `<main>' 
--------------------------------------------------- 
See: 
* http://ruby-oci8.rubyforge.org/en/HowToInstall.html 
* http://ruby-oci8.rubyforge.org/en/ReportInstallProblem.html 



Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5 for inspection. 
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/ruby-oci8-2.1.5/ext/oci8/gem_make.out 

如何解決這個問題?

回答

1

我們不安裝寶石對我們的Oracle的部署,而是從源代碼編譯:

  1. 確保ORACLE_HOME指向甲骨文完整的客戶端或Oracle instaclient
  2. 確保$內ORACLE_HOME/lib目錄libclntsh.so存在的符號鏈接libclntsh.so.11.1
  3. 變成紅寶石oci8-2.1.x目錄並運行
    1. 紅寶石的setup.rb配置
    2. 紅寶石的setup.rb設置
    3. 紅寶石的setup.rb安裝
  4. 只安裝在安裝紅寶石OCI8適配器的ActiveRecord-oracle_enhanced適配器。
0

skip: /opt/oracle/instantclient_10_2/libclntsh.so.10.1 is for i386 cpu.

即時客戶端是32位的。

checking for LP64... yes

紅寶石是64位。

即時客戶端的位數必須與紅寶石的相同。 您需要64位即時客戶端才能使用64位ruby。

0

如果你任何機會試圖在Fedora 27上安裝這種寶石,面臨着一個非常類似的錯誤信息,儘量做到:

dnf install rpm-build

這個固定我的錯誤(發現here) 。