`
yangzb
  • 浏览: 3492041 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Installing ruby-oci8 on Ubuntu

    博客分类:
  • Ruby
阅读更多

osted by 2muchtea under LD_LIBRARY_PATH, Oracle, Ubuntu, instantclient, oci, ruby, ruby-oci8, sqlplus | Tags: build-essential, instantclient, ldd, LD_LIBRARY_PATH, libaio, libsqlplus.so, mkmf, mkmf.log, oci, ORA-12154, Oracle, ruby, ruby-oci8, sqlplus, strace, TNS_ADMIN, Ubuntu

Having fixed the problem with the KVM switch on my machine I proceed to get my Ruby scripts working on Ubuntu. Installing Ruby and getting Rails is a breeze. The problem starts when I need to install ruby-oci8 . You cannot get this by doing a gem install….need to download the tar.gz file and run the setup. I try to use tar -xvf ruby-oci8-1.0.0.tar.gz but it fails. (some problem with the header of the file). I then use gzip and tar commands separately and it works.

To install ruby-oci8 you can either do this

make
make install

or do this

ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

When I try them, both fail. Looking at the error I see that I need to configure ORACLE_HOME (in case of Oracle) or need to configure LD_LIBRARY_PATH (in case of Oracle Instant Client). I know that I don’t have them on my machine so I proceed to get the Oracle Instant Client . I read some blogs (see References) and find that I need the basic.zip and sdk.zip packages. I download them and unzip them at this location /opt/oracle/instantclient (need to sudo). Having done that I set my LD_LIBRARY_PATH to /opt/oracle/instantclient.

LD_LIBRARY_PATH=/opt/oracle/instantclient
export LD_LIBRARY_PATH

I then proceed to create two symlinks

ln -s libclntsh.so.11.1 libclntsh.so
ln -s libocci.so.11.1 libocci.so

Note : In the above case, the names would depend on the version of the instant client that you have.

I go back to try out the ruby-oci8 setup and it fails again. Back to square one and I seem to have run out of ideas. A friend suggests me to check if the instant client works properly by installing sqlplus and connecting to the database. I go ahead with that (I would need sqlplus anyways).
I get the sqlplus.zip file from here . Unzip it to the location /opt/oracle/instantclient. I now go ahead and set the environment variables through the command line. (I have the LD_LIBRARY_PATH set already) and add my tnsnames.ora file to the same location.

PATH=$PATH:/opt/oracle/instantclient
SQLPATH=/opt/oracle/instantclient
export SQLPATH
TNS_ADMIN=/opt/oracle/instantclient
export TNS_ADMIN

I try this command at the command line now. (where the username , password and tnsnames have appropriate variables)

sqlplus username/password@tnsname

I get this now:

sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

What the !! Now what is this supposed to be?? I read more and run these commands:

ldd sqlplus
strace sqlplus

The first command gives me a list of library dependencies that sqlplus requires and the second command (strace) gives me a trace of system calls and signals. (see man pages of the command for details). Both indicate that a library (libaio) is missing. I run the following command :

sudo apt-get install libaio-dev

Now when I try to run sqlplus I get this error:

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Dec 21 12:57:36 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.


ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

At least I am close. Hmmm…problem with the tnsnames. Soon, I find that I had set TNSADMIN instead of TNS_ADMIN. sqlplus runs once i correct that. So, I can now connect to the database and am sure that the instantclient is installed correctly. Back to ruby-oci8 now.
Running the setup gives me the same problem. This time however I notice that the instantclient is recognized but there is this error (I guess the instantclient was not the problem after all …doh !!)

checking for cc... ---------------------------------------------------
error messages:
Permission denied - mkmf.log
---------------------------------------------------

I see that mkmf.log exists in the oci8 dir structure and has root privileges. So, I need to run the setup as root. But since all the environment variables are set on my login the setup complains that it does not see LD_LIBRARY_PATH. I go ahead and add all environment variables to /etc/profile. For global environment variables in Ubuntu see this . I restart my shell and run the following.

sudo -i
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Success. oci8 now installs without complaints. I try my ruby scripts and everything looks good. The fruit of persistence is definitely sweet.

UPDATES: I was helping a friend install oci8 on his machine when we faced some more hurdles. Adding them here:

1. mkmf not found: You will need the development version of Ruby. sudo apt-get install ruby1.8-dev
2. Make sure you install 32 bit versions and not 64 bit ones.
3. If you see this error : “libsqlplus.so: cannot open shared object file:” , you are missing the instantclient path. Somehow adding the path in /etc/profile did not get picked up in our case. We had to add it in the .bashrc file. Make sure you open a new terminal after the changes.
4. If you have problems running ruby setup, install etc (see the last step above), check to see if you have the build-essential package installed: sudo apt-get install build-essential

References:

http://ubuntuforums.org/archive/index.php/t-92528.html

http://roqet.org/oracle_instantclient.html

http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html

http://craiccomputing.blogspot.com/2007/01/using-oracle-as-backend-to-rails.html

http://ubuntuforums.org/archive/index.php/t-535311.html

http://rubyforge.org/forum/forum.php?thread_id=13948&forum_id=1078

https://help.ubuntu.com/community/EnvironmentVariables

Technorati Tags: ruby-oci8 , sqlplus , LD_LIBRARY_PATH , libaio , TNS_ADMIN , strace , ldd , Ubuntu , ruby , oci , mkmf.log , Oracle

分享到:
评论

相关推荐

    anaconda安装 - Installing Anaconda on Ubuntu

    ### 安装Anaconda在Ubuntu上的详细步骤及关键知识点 #### 一、Anaconda简介 Anaconda是一款非常受欢迎的数据科学平台,它集成了Python或R语言环境中的许多库和工具,便于用户进行数据处理、科学计算、机器学习等...

    vissim4.3安装出现问题解决方案.doc

    Vissim是一款广泛应用于交通模拟和分析的软件,版本4.3在安装过程中可能会遇到一些问题,特别是"installing plug-ins, please wait"这一步骤可能导致安装停滞。这个问题通常是由于系统环境、软件冲突或者安全软件...

    Installing-Mumax-and-Gnuplot-in-Windows-10-Step-by-Step

    知识点8:安装 Gnuplot Gnuplot 是一个开源的科学计算图形库,旨在帮助开发者更好地开发科学计算应用程序。安装 Gnuplot 的步骤如下: 1. 打开 Gnuplot 官方网站,下载 Gnuplot 安装程序。 2. 安装 Gnuplot,按照...

    TUTORIAL FOR INSTALLING MINIX-386

    TUTORIAL FOR INSTALLING MINIX-386 MINIX 升级到 MINIX-386的经典 John Nall写的关于如何使用Bruce Evans的补丁程序将MINIX 1.5.10版升级到MINIX-386的说明。

    Ubuntu Pocket Guide and Reference: A concise companion for day-to-day Ubuntu use

    - **Installation**: The book starts with a detailed guide on installing Ubuntu on your computer, covering various scenarios and hardware configurations. - **Hardware Configuration**: After ...

    ruby安装升级及命令自行编译安装非APTGET方式安装升级的办法

    Ubuntu用户通常会依赖于包管理工具`apt-get`来安装Ruby,这种方式虽然简单便捷,但在某些情况下可能无法满足定制化的需求。本文将详细介绍如何通过手动编译的方式安装Ruby,并提供一种灵活的升级策略。 #### 手动...

    ruby-1.9.1-p376-i386-mswin32.zip

    The Windows platform has several options for installing Ruby. The first option is simply installing the compiled binaries. The second option is to use the one-click installer. If you’re unsure about ...

    Installing Quantum ESPRESSO (serial) on Linux-UBUNTU [TUTORIAL] [720p].mp4

    quantum espresso 视频可以认真学习 进行入门,非常不错的材料 给大家进行分享,值得拥有

    Installing Activ Test on Your PC

    1. **操作系统**:本文档基于Windows 7系统编写,但其他版本的Windows系统(如Windows 8、Windows 10等)也可以参考此文档进行操作。 2. **互联网连接**:由于Activ Test的评估测试需要在线进行,因此您需要具备宽带...

    Installing mini-xml along with a sample code

    Mini-XML supports reading of UTF-8 and UTF-16 and writing of UTF-8 encoded XML files and strings. Data is stored in a linked-list tree structure, preserving the XML data hierarchy, and arbitrary ...

    Installing-Studio-v6-1-Plugins

    ### 标题解读:“Installing-Studio-v6-1-Plugins” 标题“Installing-Studio-v6-1-Plugins”清晰地指出了本文的主题:安装 Zend Studio 的 v6.1 版本作为插件。这暗示了该过程是在一个已经存在的 Eclipse 集成开发...

    ruby selenium-client-1.2.18.gem

    8. Set the CLASSPATH C:\Ruby192\bin – This is done by adding System Variables 9. Go to Cmd Prompt –> c:\Ruby192\bin>gem install selenium-client-1.2.18.gem Once you install selenium-client you should...

    Installing STLinux on Ubuntu

    ### 安装STLinux在Ubuntu上的关键步骤与挑战 #### 概览 本文将深入探讨在Ubuntu上安装STLinux的全过程,重点解析由于包管理系统的差异而带来的挑战及其解决方案。对于那些希望在Ubuntu环境中利用STLinux强大功能的...

    Microsoft Windows 2000 Scripting Guide - Installing Software on a Remote Computer

    Microsoft Windows 2000 Scripting Guide - Installing Software on a Remote Computer

    xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch2-win32

    《ESP32开发环境搭建——基于xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch2-win32的详细指南》 ESP32是一款高度集成的微控制器,广泛应用于物联网(IoT)、智能家居、智能硬件等领域,因其强大的性能和丰富的外设接口...

    installing samba on ubuntu

    面是我在Ubuntu6.06 LTS 下源码编译安装samba主要安装过程,本人第一次用Ubuntu,刚装上去时候,没有gcc编译环境。郁闷了半天。找出这一过程发了不少的时间。可能还有些不妥,不过我经过这样的安装达到了向windows共享...

    edx-readthedocs-io-edx-installing-configuring-and-running-en-latest.pdf

    1. Open edX平台简介:文档中提到的“Installing, Configuring, and Running the Open edX Platform”是一个运行手册,该手册对如何安装、配置和运行Open edX平台提供了详尽的指导。Open edX平台支持各种在线教育...

    ruby on rails安装环境.txt

    标题与描述均提到了“ruby on rails安装环境”,这表明文档主要关注的是如何在特定的环境中设置Ruby on Rails。Ruby on Rails(常简称为Rails)是一种用于开发Web应用程序的开源框架,采用Ruby语言编写,遵循MVC...

    deploy-TBS-on-vSphere7

    下载Harbor注册表的SSL根证书(请参见下图),然后将其移至要运行安装程序的工作站上的/tmp/harbor.crt 请遵循文档- Prerequisites部分请遵循文档-利用此处提供的一些示例进行Installing部分-$ docker login ...

    Development-Kit

    ERROR: Error installing ruby-debug-base: The 'linecache' native gem requires installed build tools. Please update your PATH to include build tools or download the DevKit from '...

Global site tag (gtag.js) - Google Analytics