Install Oracle Instant Client and DBD Oracle perl modules in Linux (Redhat, Centos, Debian,Ubuntu). 1


Introduction.

There are many plugins for Nagios for the purpose of monitoring Oracle, from simple tnsping to monitor listener response to various possibilities to monitor the status of tablespaces, instances, disks,…

When we address the need to use Oracle plugins we will always find two possibilities: locally execution (in Oracle server) by a nagios client/agent (NRPE, NSClient + +,…) or execution from the Nagios server itself. If we opt for latter, it’s required to install an Oracle client on the Nagios server, ideally Oracle Instant Client which is lighter than the full client. Besides this, most plugins are written in Perl, so you need the Perl modules needed for these to work. In this post we are going to talk about the installation and configuration of Oracle Instant Client and usually required Perl modules. Although focused for distributions Redhat / CentOS also mention how to install on Debian type Linux.

 

Install

We are going yo test with Oracle Instant Client 12. Software client can be downloaded from Oracle. If you have not an Oracle account, you need register one before. We must download packages “basic”, “sqlplus” and “devel”. For Oracle client 12 in Redhat / Centos there are RPM packages available. For Debian / Ubuntu we can convert packages from rpm format to deb format with “alien” tool.

Example packages version to download:

oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64
oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64
oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm

 

To install RMPs en Redhat / Centos:

yum localinstall oracle* --nogpgcheck

Libaio package will be installed by dependences.

To install in Debian / Ubuntu we must install dependencies before and convert packages to rpm format:

apt-get install libaio-dev libaio1
alien --scripts *.rpm
dpkg -i *.deb

This basic packages install create next directories:

/usr/lib/oracle/12.1/client64/bin (sqlplus)
/usr/lib/oracle/12.1/client64/lib (basic)
/usr/share/oracle/12.1 (devel)

Configure and test Oracle Instant client.

Tnsnames.ora

After install packages we must create tnsnames.ora file to connect remote systems using Oracle tnsnames services. We must create a directory in standard oracle path:

mkdir /usr/lib/oracle/12.1/client64/network/admin -p

and create or copy from Oracle server your tnsnames into.

Environment variables

We need add in user home “.bash_profile” the correct environment variables. Next are the classical and requires variables.

export PATH=$PATH:$HOME/bin:/usr/lib/oracle/12.1/client64/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/12.1/client64/lib
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin

Login with user and test connect to Oracle server with sqlplus:

#sqlplus user@tnsnames_service

Install perl libraries for Oracle DBD.

We need now install and compile necessary perl libraries for use from perl scripts to connect to Oracle. Are needed libraries: DBI.pm and DBD::Oracle

We can install DBI.pm from Operating System packages (prefered) or with CPAN.

Redhat / Centos

yum install perl-DBI

Debian / Ubuntu:

apt-get install libdbi-perl

Or with CPAN:

cpan> install DBI.pm

Install DBD::Oracle. Problem is this library. It’s necessary download library source package and compile. This perl library need use installed oracle libraries. Correct steps are:

1.- Oracle client or instant client installed and tested with tnsnames (environment variables configured). CPAN is going to use this environment variables to find and oracle modules to compile perl library.

2.- CPAN installed (yum install cpan)

3. With CPAN we must download DBD module

cpan> get DBD::Oracle

Downloaded modules must be in home user in “.cpan/build/DBD-Oracle-v.vv-xxxx”

4. From this directory compile and install:

perl Makefile.PL
make
make install

 

Make must find oracle libraries and compile and install correctly.

At this point is interesting to add library paths to /etc/ld.so.conf.d. Example paths:

/usr/local/lib64/perl5/auto/DBD
/usr/lib/oracle/12.1/client64/lib

We can now test nagios perl plugins for Oracle or another perl script to connect to Oracle. Try with this script copied from http://www.idevelopment.info/

Or download from here 

Download full article: 


Leave a comment

Your email address will not be published. Required fields are marked *

*

One thought on “Install Oracle Instant Client and DBD Oracle perl modules in Linux (Redhat, Centos, Debian,Ubuntu).