Ubuntu Server 64bits 如何安装 ruby-oci8
sudo apt-get install libaio-dev unzip?
转到Oracle网站下载适用于Linux64位的即时客户端基本和SDK。
下载您已创建的Oracle文件夹中的文件,并将它们解压缩:
cd /opt/oracleunzip oracle-basic-11.zipunzip oracle-sdk-11.zipcd instantclient_11_2/sudo ln -s libclntsh.so.11.1 libclntsh.so
?
export LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2?
sudo env LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 /usr/bin/gem install ruby-oci8
?
require 'rubygems'require 'oci8'tnsnames = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host_name_or_ip)(PORT = 1521)) (CONNECT_DATA = (SID = SID)))'conn = OCI8.new('user', 'password', tnsnames)cursor = conn.exec('SELECT sysdate FROM dual')while r = cursor.fetch()puts r.join(',')endcursor.closeconn.logoff
?ruby sql.rb
?
require ‘rubygems’?
或创建一个系统变量,它会自动使用RubyGems:
RUBYOPT=”rubygems”
export RUBYOPT
?
/var/lib/gems/1.8/gems/ruby-oci8-2.0.4/lib/oci8lib_18.so: libclntsh.so.11.1: cannot open shared object file: No such file or directory – /var/lib/gems/1.8/gems/ruby-oci8-2.0.4/lib/oci8lib_18.so (LoadError)原因:没有配置LD_LIBRARY_PATH变量是。
?
?
?
?
?
?