How To: Setup DBD::Oracle in Ubuntu

Posted: September 11, 2010 in FOSS, How-to

This how-to outlines the setup of Perl-Oracle connectivity under Ubuntu.

  • Install DBI (DBI module should be installed before installing DBD::Oracle)

root@cratlk1:~# perl -MCPAN -e shell

cpan shell — CPAN exploration and modules installation (v1.9402)
Enter ‘h’ for help.

cpan[1]> m DBI
CPAN: Storable loaded ok (v2.21)
Going to read ‘/home/sajithr/.cpan/Metadata’
Database was generated on Tue, 24 Aug 2010 07:47:51 GMT
Module id = DBI
DESCRIPTION  Generic Database Interface (see DBD modules)
CPAN_USERID  TIMB (Tim Bunce <Tim.Bunce@pobox.com>)
CPAN_VERSION 1.613
CPAN_FILE    T/TI/TIMB/DBI-1.613.tar.gz
UPLOAD_DATE  2010-07-25
DSLIP_STATUS MmcOp (mature,mailing-list,C,object-oriented,Standard-Perl)
MANPAGE      DBI – Database independent interface for Perl
INST_FILE    /usr/local/lib/perl/5.10.1/DBI.pm
INST_VERSION 1.613

(If it’s not installed, install DBI)

  • Download DBD::Oracle

cpan[2]> get DBD::Oracle

  • Install libaio, libaio-dev (for Oracle instant-client)

root@cratlk1:~# sudo aptitude install libaio libaio-dev

  • Download and install oracle-instant-client-basic and oracle-instant-client-devel

root@cratlk1:~# alien –scripts oracle-instantclient11.2-*.rpm
root@cratlk1:~# sudo dpkg -i *.deb

  • Set Oracle environment variables

root@cratlk1:~# cat >> ~/.bashrc <<EOF
ORACLE_HOME=/usr/lib/oracle/11.2/client
PATH=$PATH:$ORACLE_HOME/bin
LD_LIBRARY_PATH=$ORACLE_HOME/lib
EOF

root@cratlk1:~# . ~/.bashrc

  • (Optional) Setup TNS (make test will fail without this)

root@cratlk1:~# mkdir -p $ORACLE_HOME/network/admin
root@cratlk1:~# touch $ORACLE_HOME/network/admin/tnsnames.ora

  • Install DBD::Oracle

root@cratlk1:~# cd .cpan/build/DBD-Oracle-1.24-f77eUj/
root@cratlk1:~# perl Make.PL
root@cratlk1:~# make
(Optional, see the note above) root@cratlk1:~# make test
root@cratlk1:~# make install

sajithr@cratlk1:~$ perl -MCPAN -e shell
Terminal does not support AddHistory.cpan shell — CPAN exploration and modules installation (v1.9402)
Enter ‘h’ for help.cpan[1]> m DBI
CPAN: Storable loaded ok (v2.21)
Going to read ‘/home/sajithr/.cpan/Metadata’
Database was generated on Tue, 24 Aug 2010 07:47:51 GMT
Module id = DBI
DESCRIPTION  Generic Database Interface (see DBD modules)
CPAN_USERID  TIMB (Tim Bunce <Tim.Bunce@pobox.com>)
CPAN_VERSION 1.613
CPAN_FILE    T/TI/TIMB/DBI-1.613.tar.gz
UPLOAD_DATE  2010-07-25
DSLIP_STATUS MmcOp (mature,mailing-list,C,object-oriented,Standard-Perl)
MANPAGE      DBI – Database independent interface for Perl
INST_FILE    /usr/local/lib/perl/5.10.1/DBI.pm
INST_VERSION 1.613

Advertisements
Comments
  1. […] How to set up DBD:Oracle in Ubuntu engl. Anleitung […]

  2. Adam Felson says:

    If you run x86-amd64, get the oracle instantclient downloads from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
    Otherwise, DBD::Oracle will complain that the ORACLE_HOME doesn’t point to an oracle install and that LD_LIBRARY_PATH== ”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s