OCIEnvNlsCreate() failed again

So I’ve downloaded and installed Fedora 12 for the work laptop for awhile now. Previously it was Linux Mint 7/8, but I haven’t actually used the machine yet, as I encountered that darned OCIEnvNlsCreate() error message again. Same setup, just Oracle Express 10 on Linux, except the distro is Fedora this time.

So I was looking for a place to set environment variables — Apache’s SetEnv directive DOES NOT work — and there is no equivalent of Debian’s /etc/apache2/envvars in Fedora, at least I’m told. The weird thing is, plenty of people have encountered the problem before, but never found the solution — or didn’t bother to post the solution online.

I finally found the solution in an Oracle-hosted article about Oracle, PHP and Linux. It’s not really well-described, so I thought to post my solution here instead. Insert the call to oracle_env.sh somewhere in /etc/init.d/httpd. I put mine above the start() function definition:

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

oracle_env.sh file should contain something similar to the following:

export NLS_LANG
export PATH

Once you’re done, save the file (you need to be root) and then restart httpd:

sudo /etc/init.d/httpd restart

#oracle, #red-hat

Using ‘grep’ with Subversion

I use ‘grep’ alot, but it false positives when searching in a Subversion working copy. So I’m using the ‘-r’ flag to recursive search for the phrase ‘quick brown fox’:

$ grep -r 'quick brown fox' *
app/controllers/users_controller.php: quick brown fox
app/controllers/.svn/text-base/users_controller.php.svn-base: quick brown fox

This is only a minor annoyance if there are just two entries, but often that’s not the case. The solution is to add the ‘–exclude-dir=.svn’ flag. But the extra characters causes unnecessary fatigue on my fingers, so I’ve added an alias to my .bashrc file:

alias grep='grep --exclude-dir=.svn'

For maximum mileage, combine this with ‘-ir’:

alias grep='grep -ir --exclude-dir=.svn'

#linux, #subversion

On progress

Opened up a terminal window in Linux Mint today; here’s what it told me:

( Steady movement is more important than )
( speed, much of the time. So long as    )
( there is a regular progression of      )
( stimuli to get your mental hooks into, )
( there is room for lateral movement.    )
( Once this begins, its rate is a matter )
( of discretion.                         )
(                                        )
( -- Corwin, Prince of Amber             )
kzhiwei@woteba ~ $

Creating a branch in Subversion

Beginning at the root of your repository:

svn mkdir branches/wayne
cd branches/wayne
svn merge http://your.subversion.server/projectName/trunk
svn ci -m 'Issuing "svn merge http://your.subversion.server/projectName/trunk".'


Changing hostname

Should you update /etc/hostname — I did — be sure to update the default tnsnames.ora and listener.ora.

Mine were found in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin.

Otherwise you’ll get an ORA-12541 message.

#linux, #oracle

OCIEnvNlsCreate() failed

Wanted to work on an Oracle project from home last weekend, but I received this message:

Warning (2): ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system – please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories [CORE/cake/libs/model/datasources/dbo/dbo_oracle.php, line 171]

A little bit of system background here. I’m using Linux Mint 8, running oracle-xe oci8 was compiled via pecl, with one notable difference from my previous guide. I did not use instantclient (i.e. instantclient,/usr/lib/oracle/11.1/client/lib), so the phpinfo output for the oci8 section was quite different.

It looked like:

OCI8 Support enabled
Version 1.4.1
Revision $Revision: 293235 $
Active Persistent Connections 0
Active Connections 0
Compile-time ORACLE_HOME /usr/lib/oracle/xe/app/oracle/product/10.2.0/server
Libraries Used -Wl,-rpath,/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -lclntsh
Temporary Lob support enabled
Collections support enabled

I did some searching. I figured it was something to do with environment variables, as my colleague had helped me to resolve the problem previously. I’d forgotten the fix, so this post will serve as a reminder, if needed.

Now ORACLE_HOME and LD_LIBRARY_PATH were defined via my .bashrc, which consists of just one line:

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

Some people suggested using Apache’s SetEnv — which I tried — but the error did not go away. That same colleague suggested this morning I use the envvars file in Ubuntu instead, which helped to resolve my problem, at least:

Adding these two lines solves my problem:

export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:

Seriously, my journey with Oracle has always been a rocky one. I wonder why this product is so… inaccessible.

#apache, #oracle, #ubuntu