This article discusses how to compile DBD::Oracle for Oracle client 11.2 x86-64 on Linux (Fedora 12 to be precise). I recommend not to mess around with your distribution’s perl, that’s why I will base it on ActivePerl 5.10 from Activestate.com. If you (and you system administrator don’t mind mangling your distribution’s perl you might skip the first bit and continue straight with the section DBD::Oracle.
This is particularly useful for installations on nagios servers to enable monitoring of Oracle databases directly through perl’s DBD::Oracle without those ugly “sqlplus -S….<<EOF” constructs I see far too often.
I downloaded active perl straight from their website, it’s version 126.96.36.1996 for glibc 2.3.3-291086. Download and unzip the file:
gunzip -cd ActivePerl-188.8.131.526-x86_64-linux-glibc-2.3.3-291086.tar.gz | tar xvf - cd ActivePerl* sudo ./install.sh
I installed the distribution into /opt/ActivePerl-5.10, the default, and also generated the HTML documentation. Don’t forget to change your environment variables, such as PATH before using the new perl
Download DBD::Oracle, version 1.23 was current at the time of this writing:
wget http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.23.tar.gz cd DBD-Oracle-1.23 . oraenv # will set your LD_LIBRARY_PATH, $ORACLE_HOME and other variables needed. export PATH=/opt/ActivePerl-5.10/bin:$PATH
From then on everything should be pretty smooth sailing:
perl Makefile.pl Using DBI 1.607 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /opt/ActivePerl-5.10/lib/auto/DBI/ Argument "6.55_02" isn't numeric in numeric ge (>=) at Makefile.PL line 61. Configuring DBD::Oracle for perl 5.010001 on linux (x86_64-linux-thread-multi) Remember to actually *READ* the README file! Especially if you have any problems. Installing on a linux, Ver#2.6 Using Oracle in /u01/app/martin/product/11.2.0/client_1 DEFINE _SQLPLUS_RELEASE = "1102000100" (CHAR) Oracle version 184.108.40.206 (11.2) Found /u01/app/martin/product/11.2.0/client_1/rdbms/lib/ins_rdbms.mk Using /u01/app/martin/product/11.2.0/client_1/rdbms/lib/ins_rdbms.mk ...
I was a bit surprised to see the following warning during the execution of the perl Makefile.pl command. I decided
WARNING: Oracle /u01/app/martin/product/11.2.0/client_1/rdbms/lib/ins_rdbms.mk doesn’t define a ‘build’ rule.
WARNING: I will now try to guess how to build and link DBD::Oracle for you.
This kind of guess work is very error prone and Oracle-version sensitive.
It is possible that it won’t be supported in future versions of DBD::Oracle.
*PLEASE* notify dbi-users about exactly _why_ you had to build it this way.
I guess that’s owed at the relatively new Oracle client version. Execute make to build the module.
You should also test the build before proceeding. This proved to be a bit more tricky, you need to set some environment variables first. These are:
- export PATH=/opt/ActivePerl-5.10/bin:$PATH
- export ORACLE_DSN=”dbi:Oracle:<valid tnsnames.ora entry>”
- export ORACLE_USERID=username/password
Don’t forget ORACLE_HOME and LD_LIBRARY_PATH etc, easiest done through a quick “source oraenv” in your session. With that set you can issue a “make test”. Edit Makefile line 1005 and set TEST_VERBOSE to 1 if you want more output from the tests which is useful for troubleshooting.
Finally, issue the “sudo make install” to install the DBD::Oracle package into your new perl distribution.
You’re done, congratulations!