Main Content
Installing Oracle Adapters on Red Hat Linux
This is a brain dump of my experience installing Oracle Adapters on Red Hat Linux Enterprise Edition with Rails3, though it should be pretty close to other Unix/Linux installations.
See Also: Installing Oracle/SQLplus on Linux (nearly) everything worked for RHL-EE
See Also: Oracle for Rails (part II of above article)
See Also: Oracle's documentation on Oracle for Rails
See Also: Platform Specific Issues with ruby-oci8
For reference, this page contains most of the instructions we'll follow.
We are going to download three oracle client libraries to the linux box
Go directly to Oracle for the client libraries:
http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
Here is the exact version of the "instant client" Instant Client for Linux x86-64
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
Download all three of these files to the linux box:
I had to download the three above files to my windows box instead of using wget, since Oracle makes you login to download. Once downloaded, I unzippped the files on the linux box itself, using: unzip <filename> (They will all unzip into the same directory)
I followed the instructions here which have you setup some path variables and sym links on your linux machine, and places most of the install files into /opt/oracle/
Once complete, I tried to run the sqlplus app with "sqlplus -h", but got an error:
here are the settings I put in ~/.bash_profile
Notice the entry for LD_LIBRARY_PATH - this wasn't included in the earlier tutorial, but solves the "cannot open shared object file" error. (the LD_LIBRARY_PATH fix was noted here)
Now if you try sqlplus -h you should get a lot of help info. This means that the sqlplus install went well, and we can try to install the oracle-ruby library. But, I suppose we can test sqlplus right quick:
which gives me an error:
after some googling I added this to my ~/.bash_profile
now, I get two errors:
ok, looks like we need to create a tnsnames.ora file in: /opt/oracle/instantclient_11_2/network/admin/
and then this will work:
in /home/some_directory/oraclelibs/
at this point, I got an error
ok, so I need to patch this up so that we can build the gem. Technically speaking, you can instal the ruby-oci8 gem one of two ways.
To install ruby-oci8 you can either do this:
or do this:
either results in the "cannot get Oracle version from sqlplus" error, so... back to patching. Some troubleshooting says to check both $ORACLE_HOME and $LD_LIBRARY_PATH
ok, then troubleshooting says to check the symlinks and ensure they are:
after further googling I hit RubyForge.org and post a question. It seems that I had the 32bit oracle client libraries running against 64bit Ruby (note that OS doesn't matter, the version of Ruby does). So, I swap out my 32bit client libs for 64bit client libs and now I can run this to success:
So, now I can try to build to ruby-oci8 lib:
which gives me the system day from the DB server:
Let's do one more test, and ensure that the ruby-oci8 gem is available from irb. From the console/terminal do:
If you see "true" returned, all is well (and it should be after the select date test) Now we can download the ActiveRecord Adapter
Creating a Sample Rails app using ActiveRecord against Oracle:
The following instructions are Rails3 specific, though it's very similar for Rails2.3.x cd to your rails apps working directory.
Notice that we are using oracle_enhanced, a slightly better ActiveRecord adapter than the standard oracle AR lib. Next, let's edit /oracle_test/Gemfile. You'll need to add the following line somewhere in the Gemfile:
Now, you can hit the command-line/terminal/console and start rails with:
Which starts your server. Then click on "about your app env" link. You should see goodness like this:
Good luck, and happy Oracle Railin'
See Also: Installing Oracle/SQLplus on Linux (nearly) everything worked for RHL-EE
See Also: Oracle for Rails (part II of above article)
See Also: Oracle's documentation on Oracle for Rails
See Also: Platform Specific Issues with ruby-oci8
Download the Oracle Client Libraries
For reference, this page contains most of the instructions we'll follow.
We are going to download three oracle client libraries to the linux box
- Instant Client Package – Basic
- Instant Client Package -- SQL*Plus
- Instant Client Package -- SDK
Go directly to Oracle for the client libraries:
http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
Here is the exact version of the "instant client" Instant Client for Linux x86-64
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
Download all three of these files to the linux box:
- oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip
- oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.x86_64.zip
- oracle-instantclient11.2-sdk-11.2.0.1.0-1.x86_64.zip
I had to download the three above files to my windows box instead of using wget, since Oracle makes you login to download. Once downloaded, I unzippped the files on the linux box itself, using: unzip <filename> (They will all unzip into the same directory)
I followed the instructions here which have you setup some path variables and sym links on your linux machine, and places most of the install files into /opt/oracle/
Once complete, I tried to run the sqlplus app with "sqlplus -h", but got an error:
here are the settings I put in ~/.bash_profile
Notice the entry for LD_LIBRARY_PATH - this wasn't included in the earlier tutorial, but solves the "cannot open shared object file" error. (the LD_LIBRARY_PATH fix was noted here)
Now if you try sqlplus -h you should get a lot of help info. This means that the sqlplus install went well, and we can try to install the oracle-ruby library. But, I suppose we can test sqlplus right quick:
which gives me an error:
after some googling I added this to my ~/.bash_profile
now, I get two errors:
ok, looks like we need to create a tnsnames.ora file in: /opt/oracle/instantclient_11_2/network/admin/
and then this will work:
Installing the ruby-oci8 library
in /home/some_directory/oraclelibs/
at this point, I got an error
ok, so I need to patch this up so that we can build the gem. Technically speaking, you can instal the ruby-oci8 gem one of two ways.
To install ruby-oci8 you can either do this:
or do this:
either results in the "cannot get Oracle version from sqlplus" error, so... back to patching. Some troubleshooting says to check both $ORACLE_HOME and $LD_LIBRARY_PATH
ok, then troubleshooting says to check the symlinks and ensure they are:
after further googling I hit RubyForge.org and post a question. It seems that I had the 32bit oracle client libraries running against 64bit Ruby (note that OS doesn't matter, the version of Ruby does). So, I swap out my 32bit client libs for 64bit client libs and now I can run this to success:
So, now I can try to build to ruby-oci8 lib:
which gives me the system day from the DB server:
Let's do one more test, and ensure that the ruby-oci8 gem is available from irb. From the console/terminal do:
If you see "true" returned, all is well (and it should be after the select date test) Now we can download the ActiveRecord Adapter
Download the active record gem
Creating a Sample Rails app using ActiveRecord against Oracle:
The following instructions are Rails3 specific, though it's very similar for Rails2.3.x cd to your rails apps working directory.
Notice that we are using oracle_enhanced, a slightly better ActiveRecord adapter than the standard oracle AR lib. Next, let's edit /oracle_test/Gemfile. You'll need to add the following line somewhere in the Gemfile:
Now, you can hit the command-line/terminal/console and start rails with:
Which starts your server. Then click on "about your app env" link. You should see goodness like this:
Good luck, and happy Oracle Railin'
Posted by: Julius G.
5 months ago...
This is just what im looking for.. thank you very much for this guide..
This is just what im looking for.. thank you very much for this guide..

Leave a Reply