Setup ruby (oci8, sequel) for Oracle on ubuntu 14.04

Download and install Oracle instant client

  • go to
  • choose your environment
    • be aware that not all environments are update, for instance “Linux AMD64” is not, whereas “Linux X86-64” is
  • accept the license agreement
  • download the necessary rpm files (not the zip archives) (you may be prompted to login with your Oracle account)
    • Instant Client Package – Basic
      • oracle-instantclient12.1-basic-
    • Instant Client Package – SQL*Plus
      • oracle-instantclient12.1-sqlplus-
    • Instant Client Package – SDK
      • oracle-instantclient12.1-devel-
  • install alien to be able to install the rpm’s
    • sudo apt-get install alien
  • install the rpms using alien
    • sudo alien -i oracle-instantclient12.1-basic-
    • sudo alien -i oracle-instantclient12.1-sqlplus-
    • sudo alien -i oracle-instantclient12.1-devel-

Make libraries available

  • sudo touch /etc/ && sudo vi /etc/
  • add the following
    • /usr/lib/oracle/12.1/client64/lib
  • sudo ldconfig

Make headers available

As the original ubuntu guide indicates, some libraries expect the headers to reside below the main oracle home directory.

  • sudo ln -s /usr/include/oracle/12.1/client64 /usr/lib/oracle/12.1/client64/include


  • sudo touch /etc/profile.d/ && sudo vi /etc/profile.d/
  • add the following lines
    • export ORACLE_HOME=/usr/lib/oracle/12.1/client64
    • export PATH=$PATH:$ORACLE_HOME/bin

SSH tunnel into your oracle box

Probably you don’t want to expose the necessary ports on your oracle box to the outside (not even to your development box) . So just quick recap of how to tunnel the needed port using ssh.

  • ssh -L 1521:localhost:1521 your_oracle_box

Install necessary gems

  • gem install ruby-oci8
  • gem install sequel

You may also want to install other gems like activerecord-oracle_enhanced-adapter.

Test the whole setup

Run the following in irb to check, if everything works as expected. This expects that there is a schema some with a table named table.

require "oci8"
require "sequel"

DB ="your_sid", user: "your_user”, password: "your_password", host: "localhost", port: 1521)

puts DB["select * from some.table"].count


Setup ruby (oci8, sequel) for Oracle on ubuntu 14.04