# Mongrel\_Cluster unable to access OCI8 library

**URL:** <https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948>\
**Category:** Mongrel\
**Created:** [October 1, 2008, 2:25pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948 "2008-10-01T14:25:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 1, 2008, 2:25pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/1 "2008-10-01T14:25:24Z")

</div>

Hi,

I’m able to run a ROR application in a Red Hat Enterprise Linux 4.4  
environment, as long as I start my mongrel\_cluster via the command line:

[chris@localhost ~]$ mongrel\_cluster\_ctl start

I take a look at the two mongrel\_rails processes that were just created:

[chris@localhost log]$ ps -ef | grep mongrel  
chris 4781 1 5 05:55 ? 00:00:02 /usr/local/bin/ruby  
/usr/local/bin/mongrel\_rails start -d -e production -a 0.0.0.0 -c  
/home/chris/kitry/FDS\_Server --user chris --group chris -p 4001 -P  
log/mongrel.4001.pid -l log/mongrel.4001.log  
chris 4784 1 5 05:55 ? 00:00:02 /usr/local/bin/ruby  
/usr/local/bin/mongrel\_rails start -d -e production -a 0.0.0.0 -c  
/home/chris/kitry/FDS\_Server --user chris --group chris -p 4002 -P  
log/mongrel.4002.pid -l log/mongrel.4002.log

* * *

Now, if I turn my mongrel\_cluster into a service, which starts up at  
boot time, my two mongrel\_rails processes look identical, EXCEPT for the  
PRIORITY LEVEL (5 by hand, 0 as a service):

[chris@localhost ~]$ ps -ef | grep mongrel  
chris 2759 1 0 06:04 ? 00:00:02 /usr/local/bin/ruby  
/usr/local/bin/mongrel\_rails start -d -e production -a 0.0.0.0 -c  
/home/chris/kitry/FDS\_Server --user chris --group chris -p 4001 -P  
log/mongrel.4001.pid -l log/mongrel.4001.log  
chris 2762 1 0 06:04 ? 00:00:02 /usr/local/bin/ruby  
/usr/local/bin/mongrel\_rails start -d -e production -a 0.0.0.0 -c  
/home/chris/kitry/FDS\_Server --user chris --group chris -p 4002 -P  
log/mongrel.4002.pid -l log/mongrel.4002.log

Unfortunately, this time, my application logs the following error  
message:

LoadError (Oracle/OCI libraries could not be loaded: libclntsh.so.11.1:  
cannot open shared object file: No such file or directory -  
/usr/local/lib/ruby/site\_ruby/1.8/i686-linux/oci8lib.so):  
…  
…

What could be causing the processes to correctly read the library file  
in the first situation, but not in the second? Both are run by the same  
user, in the same group. Maybe my “ps -ef” command is insufficient for  
identifying all differences between the processes; I’m neither a Linux  
nor a ROR expert…

Thanks,

Chris.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 1, 2008, 3:55pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/2 "2008-10-01T15:55:14Z")

</div>

Just a quick thought Chris. Whenever I’ve seen this happen it’s been  
because the process starting the mongrel does not have the required  
Oracle environment variables set. In my case this includes  
LD\_LIBRARY\_PATH, which points to the Oracle libraries the error  
message refers to. A quick comparison between your environment vars  
and the boot-time process environment vars would be useful.

regards

Greg

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 1, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/3 "2008-10-01T16:20:58Z")

</div>

Hi Greg,

Yes indeed, I set LD\_LIBRARY\_PATH in user “chris”'s .bashrc file:

export  
LD\_LIBRARY\_PATH=$LD\_LIBRARY\_PATH:/usr/lib/oracle/11.1.0.1/client/lib

But since the processes run as the same user, I thought it would be OK.

Where should I set this variable instead, and by the way, how do I list  
the boot-time environment variables? As you can see, I’m not much of a  
Linux guru…

I appreciate your help,

Chris.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 1, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/4 "2008-10-01T23:24:56Z")

</div>

.bashrc runs for interactive shells only.

To see your full set of interactive env vars enter:

env

or

env | sort

You could view and set env vars in the script that is called at boot  
time to start the mongrels.

Inside that script you can examine the process’s environment variables  
(echo $LD\_LIBRARY\_PATH to the log) and set them using the same syntax  
as in the .bashrc.

I expect you will also have to set some other Oracle-related env vars

- grep for ORACLE amongst your env vars to see what you are using  
interactively.

All this should be pretty straightforward to your Oracle DBA if you  
have one around.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 2, 2008, 4:30am UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/5 "2008-10-02T04:30:57Z")

</div>

One thing I have done with success when using daemon tools to manage  
my mongrels is to put the Oracle environment variables in a wrapper  
script that then calls the mongrel start command.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 2, 2008, 5:11am UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/6 "2008-10-02T05:11:17Z")

</div>

On Wed, Oct 01, 2008 at 07:27:31PM -0700, Cynthia K. wrote:

> One thing I have done with success when using daemon tools to manage  
> my mongrels is to put the Oracle environment variables in a wrapper  
> script that then calls the mongrel start command.

You could also use envdir: [http://cr.yp.to/daemontools/envdir.html](http://cr.yp.to/daemontools/envdir.html)

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 2, 2008, 3:38pm UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/7 "2008-10-02T15:38:38Z")

</div>

Thank you all for your help. I ended up setting my LD\_LIBRARY\_PATH in a  
new file called /etc/profile.d/oracle\_libs.sh, and that solved my  
problem.

Setting the environment variable inside the mongrel\_rails script also  
worked, but the solution above allows me to use SQL\*Plus as well.

Cheers,

Chris.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 3, 2008, 8:27am UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/8 "2008-10-03T08:27:02Z")

</div>

Actually, I’ve had to do both… So my problem was actually solved by  
adding LD\_LIBRARY\_PATH to the mongrel\_rails script.

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [October 2, 2008, 4:54am UTC](https://www.ruby-forum.com/t/mongrel-cluster-unable-to-access-oci8-library/149948/9 "2008-10-02T04:54:56Z")

</div>

When I run as user, my .bashrc has the following line:

source  
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle\_env.sh

At the server, my mongrel\_rails script sets the ORACLE\_HOME variable  
(zealots, beware, this hack is really ugly):

more /usr/local/bin/mongrel\_rails  
#!/usr/local/bin/ruby

# 

# This file was generated by RubyGems.

# 

# The application ‘mongrel’ is installed as part of a gem, and

# this file is here to facilitate running it.

# 

require ‘rubygems’

version = “\>= 0”

ENV[‘ORACLE\_HOME’] =  
‘/usr/lib/oracle/xe/app/oracle/product/10.2.0/server’

if ARGV.first =~ /^_(.\*)_$/ and Gem::Version.correct? $1 then  
version = $1  
ARGV.shift  
end

gem ‘mongrel’, version  
load ‘mongrel\_rails’

# EOF

Ugly but works nicely 🙂

Cheers,

filipe

On Thu, 2 Oct 2008, Greg Clarke wrote:

> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > * * *
> > 
> > Mongrel-users mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://rubyforge.org/mailman/listinfo/mongrel-users](http://rubyforge.org/mailman/listinfo/mongrel-users)
> 
> * * *
> 
> Mongrel-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://rubyforge.org/mailman/listinfo/mongrel-users](http://rubyforge.org/mailman/listinfo/mongrel-users)

filipe {  
@ [icewall.org](http://icewall.org)  
GPG 1024D/A6BA423E  
[http://filipe.icewall.org/](http://filipe.icewall.org/)  
}
