Saturday, May 19, 2012

Install & Configure Perl DBD for Oracle 11.2 on Redhat Linux

Steps 1: Install Oracle 11.2 server/client on the host

You can download oracle from

Steps 2: Install Perl on the host.

Check if perl is already installed on the host:
# perl -v
Most hosts have perl already installed.
You can download and install perl from

Step 3: Download PERL DBD-Oracle 

Download link:

Step 4: unzip and untar the download DBD-Oracle

[oracle@host1 tmp]$ gunzip DBD-Oracle-1.44.tar.gz
[oracle@host1 tmp]$ tar -xvf DBD-Oracle-1.44.tar

Step 5: Create file oci.conf 

Create file oci.conf at /etc/ as root with the location of Oracle LD_LIBRARY_PATH

For this example:

[root@host1 ~]$ more /etc/

Run ldconfig to update

[root@host1]# ldconfig -v

What is ldconfig (from the man pages)
"DESCRIPTION: ldconfig  creates  the  necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/, and in the trusted directories (/lib and /usr/lib).  The cache is used by the run-time linker, or  ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated."
For more details:

Step 6: Install DBD-Oracle

Go to the directory where u untared the downloaded DBD-Oracle
Note: Make sure u have completed Step 5

[root@host1 DBD-Oracle-1.44]# perl Makefile.PL -V 11.2.0
[root@host1 DBD-Oracle-1.44]# make install

This should complete the DBD-Oracle installation!!!!!

Step 7: Test the install

Login back as Oracle user:
Create a script ( with the text below:



use DBI;
use DBD::Oracle;

my $dbh = DBI->connect("dbi:Oracle:host=$host;port=$listener_port;sid=$oracle_sid",$ora_user, $ora_password)
  or die "Error Connecting to Oracle : " . DBI->errstr;

my $stm = $dbh->prepare("SELECT username,created FROM $db_table")
  or die "Database Error: " . $dbh->errstr;

  or die "Database Error: " . $sth->errstr;

while (( $username,$created ) = $stm->fetchrow_array() )
print "\n";
print " Username: $username\n";
print " Created Date: $created\n";
print "\n";




xxx said...

Hey, thank you for putting this together! It helped me a lot to install my dev environment with Perl and Oracle in RHEL6!

Jhmnieuwenhuis said...

Excellent guide!!

Jhmnieuwenhuis said...

Very good guide, thanks!!

Anonymous said...

thank for great toturial :)