Install perl module dbd oracle linux

Установка DBI, DBD::Oracle на Oracle Linux

Есть ОС Oracle Linux 7.6 , БД Oracle 11.2.0.4 , 2 пользователя в системе: orcl и root .
Моя машина крутится на virtual box . Я ее запускаю и с ОС своего ПК подключаюсь к ней по SSH .(все попытки проводятся на клонах машины).

Клиент заходит по адресу, например, 192.168.0.1/ , выбирает нужный отчет, вводит дату и жмет кнопочку ПОКАЗАТЬ.
В это время запускается Perl скрипт, подключается к БД и выводит результат в браузере. Но возникает ошибка:

install driver DBD::Oracle failed can't locate Oracle.so for libclntsh.so.11.1. 
  1. Проверил, что sqlplus работает: sqlplus system/123456@test; select * from m; и Apache 192.168.56.101/
  2. Установка cpan (под root ) yum -y install cpan
  3. Настройка httpd.conf . Тут только есть один нюанс: от какого пользователя запускать сервис Apache . По умолчанию пользователь и группа apache Пробовал менять на orcl или root и Apache не перезагружается ( systemctl restart httpd )
  4. Установка модулей (все под юзером orcl ):

Дал полные права 0777 на папку /usr , иначе модули не ставятся:

cpan install DBI get DBD::Oracle cd /home/orcl/.cpan/build/DBD-. perl Makefile.PL make make test 

(И тут почти у всех тестов предупреждение unable to connect to oracle )
Я написал:

export ORACLE_USERID=system/123456@test make test 

(И тут все тесты ОК кроме одного t/plsql25t )

Источник

Installation of the DBD::Oracle perl module with Oracle instantclient under linux

This document describe a simple and general way to make the perl module DBD::Oracle running up on any recent linux distribution ( x86 architecture).

The traditional DBD::Orcale building process rely on the installation of a full Oracle Developpement environment. The problem is that the Oracle Developper Suite can only be installed on the RedHat ES/AS 3 or the UnitedLinux 1.0 distributions and that this environment is very heavy, too much for what we need.

Hopefully, Oracle has recently released a lighter package containing their client driver for linux. This package is called instantclient and we will rely on it to set up the DBD::Oracle module.

This method have been successfully tested with the 10.1.0.3 release of Oracle Instant client 10g
and with the linux distributions: Debian 3.1 (Sarge) and RedHat AS3.

Читайте также:  Skype for business linux client

Schema situant DBD::Oracle

2) Prerequisities

  • An x86 computer under linux (tested with 2.4 and 2.6 kernel)
  • A running perl environment ( tested with perl 5.8.4 )
  • An internet connexion and a metalink account at Oracle

3) Oracle driver (instantclient) installation

In order to install theese packages on a ReadHat or any other rpm based distribution (Suze, Mandrake. ), open a console as root and enter:

With a distribution that doesn’t manage rpm packages, use the rpm2cpio tool:

# cd /
# rpm2cpio chemin/paquet.rpm | cpio -idmv

Update: As of the 12 October 2005, oracle ship a .zip file for the instantclient distribution.
There is no problem with that but .zip archives don’t support the symbolic links. In order to permit the linker (ld) to found the instant client libraries, after unpacking the instantclient from the .zip file, you must create the symbolic links by yourself.

For exemple, to set the 10.1 version to the default version to link with:

# ln -s libclntsh.so.10.1 libclntsh.so
# ln -s libocci.so.10.1 libocci.so

4) Compilation and installation of the DBD::Oracle module

4.1) Get the module source with CPAN:

Open a console as root, and enter:

cpan> get DBD::Oracle
cpan> quit

Now, CPAN should have fetch the latest DBD::Oracle source release ( at the date of writing this document, this is the 1.16 release ) in the /root/.cpan/build directory ( depending of your CPAN configuration, but in all cases, CPAN print on the console where it have unpacked the source )

4.2) Copy and adaptation of Makefile-instantclient

When building the module by the classical way, the automatic build and install script ( Makefile.PL ) try to determine the location of the Oracle C interface files (.h) as well as the libraries needed by the DBD::Oracle module.
However, as we don’t have this complete Oracle developpement environement, the classical script can’t cope with our instantclient and we fail. So we will use another ( simplistic ) script to buid the module.

Download and copy this file : Makefile-instantclient.PL in the /root/.cpan/build/DBD-Oracle-x.xx directory ( or the analog directory depending on your CPAN configuration)

Copy this file : oracle-instantclient-config into the /usr/bin directory.

Note: You can, according to your preferences ( or constraints ) put this script in another directory ( like /usr/local/bin, /opt/oracle_instantclient/bin, etc. In this case, be sure that the directory in which you put the script appear in the PATH environment variable.

Set proper acces rights:
# chmod 755 /usr/bin/oracle-installclient-config

If you don’t have installed the instantclient in the default emplacement ( default prefix is /usr/ ) you must edit le the oracle-instantclient-config file to set the prefix variable ( at line 4 ) so that it reflect the prefix you have used.

4.3) Compilation

From the /root/.cpan/DBD-Oracle-x.xx directory, enter :

$ perl Makefile-instantclient.PL
$ make

Some tips in case of errors:

— If the compilator (gcc) vous dit say that it can’t found headers (.h),

enter:
$ oracle-instantclient-config —cflags

Читайте также:  Классификация операционной системы linux

and check that the instantclient header files are located in the returned directory ( after the -I parameter)

— If the linker (ld) complains about missing libraries (*.so.*),

enter:
$ oracle-instantclient-config —libs

and check that the instantclient libraries are located in the returned directory ( after the -L parameter)

4.4) Installation

If everything goes well, your DBD::Oracle module should be ready !

5) Test

$oracle_server=»server»;
$oracle_listener=»listener»;
$oracle_sid=»SID»;
$oracle_port=»PORT»;
$oracle_user=»user»;
$oracle_password=»password»;
$oracle_testing_table=»TABLE»;

my $dbh = DBI->connect(«dbi:Oracle:host=$oracle_server;port=$oracle_port;sid=$oracle_sid»,
$oracle_user, $oracle_password)
or die «Impossible de se connecter à la base Oracle : » . DBI->errstr;

my $sth = $dbh->prepare(«SELECT * FROM $oracle_testing_table»)
or die «Impossible de preparer la requette: » . $dbh->errstr;

$sth->execute()
or die «Impossible d’exécuter la requette: » . $sth->errstr;

while ( my @data = $sth->fetchrow_array() )
my $firstname = $data[1];
my $id = $data[2];
print «\t$id: $firstname $lastname\n»;
>

if ($sth->rows == 0)
print «Table vide\n»;
>

Références:

Thanks to:

Pawel Grygiel for the update concerning the .zip archive that don’t support symbolic links.

Jean-Christophe Duberga, jeanchristophe.duber >AT< free.fr - CRI - Université Bordeaux2

Источник

Installation of the DBD::Oracle perl module with Oracle instantclient under linux

This document describe a simple and general way to make the perl module DBD::Oracle running up on any recent linux distribution ( x86 architecture).

The traditional DBD::Orcale building process rely on the installation of a full Oracle Developpement environment. The problem is that the Oracle Developper Suite can only be installed on the RedHat ES/AS 3 or the UnitedLinux 1.0 distributions and that this environment is very heavy, too much for what we need.

Hopefully, Oracle has recently released a lighter package containing their client driver for linux. This package is called instantclient and we will rely on it to set up the DBD::Oracle module.

This method have been successfully tested with the 10.1.0.3 release of Oracle Instant client 10g
and with the linux distributions: Debian 3.1 (Sarge) and RedHat AS3.

Schema situant DBD::Oracle

2) Prerequisities

  • An x86 computer under linux (tested with 2.4 and 2.6 kernel)
  • A running perl environment ( tested with perl 5.8.4 )
  • An internet connexion and a metalink account at Oracle

3) Oracle driver (instantclient) installation

In order to install theese packages on a ReadHat or any other rpm based distribution (Suze, Mandrake. ), open a console as root and enter:

With a distribution that doesn’t manage rpm packages, use the rpm2cpio tool:

# cd /
# rpm2cpio chemin/paquet.rpm | cpio -idmv

Update: As of the 12 October 2005, oracle ship a .zip file for the instantclient distribution.
There is no problem with that but .zip archives don’t support the symbolic links. In order to permit the linker (ld) to found the instant client libraries, after unpacking the instantclient from the .zip file, you must create the symbolic links by yourself.

For exemple, to set the 10.1 version to the default version to link with:

# ln -s libclntsh.so.10.1 libclntsh.so
# ln -s libocci.so.10.1 libocci.so

Читайте также:  Linux kernel no reboot

4) Compilation and installation of the DBD::Oracle module

4.1) Get the module source with CPAN:

Open a console as root, and enter:

cpan> get DBD::Oracle
cpan> quit

Now, CPAN should have fetch the latest DBD::Oracle source release ( at the date of writing this document, this is the 1.16 release ) in the /root/.cpan/build directory ( depending of your CPAN configuration, but in all cases, CPAN print on the console where it have unpacked the source )

4.2) Copy and adaptation of Makefile-instantclient

When building the module by the classical way, the automatic build and install script ( Makefile.PL ) try to determine the location of the Oracle C interface files (.h) as well as the libraries needed by the DBD::Oracle module.
However, as we don’t have this complete Oracle developpement environement, the classical script can’t cope with our instantclient and we fail. So we will use another ( simplistic ) script to buid the module.

Download and copy this file : Makefile-instantclient.PL in the /root/.cpan/build/DBD-Oracle-x.xx directory ( or the analog directory depending on your CPAN configuration)

Copy this file : oracle-instantclient-config into the /usr/bin directory.

Note: You can, according to your preferences ( or constraints ) put this script in another directory ( like /usr/local/bin, /opt/oracle_instantclient/bin, etc. In this case, be sure that the directory in which you put the script appear in the PATH environment variable.

Set proper acces rights:
# chmod 755 /usr/bin/oracle-installclient-config

If you don’t have installed the instantclient in the default emplacement ( default prefix is /usr/ ) you must edit le the oracle-instantclient-config file to set the prefix variable ( at line 4 ) so that it reflect the prefix you have used.

4.3) Compilation

From the /root/.cpan/DBD-Oracle-x.xx directory, enter :

$ perl Makefile-instantclient.PL
$ make

Some tips in case of errors:

— If the compilator (gcc) vous dit say that it can’t found headers (.h),

enter:
$ oracle-instantclient-config —cflags

and check that the instantclient header files are located in the returned directory ( after the -I parameter)

— If the linker (ld) complains about missing libraries (*.so.*),

enter:
$ oracle-instantclient-config —libs

and check that the instantclient libraries are located in the returned directory ( after the -L parameter)

4.4) Installation

If everything goes well, your DBD::Oracle module should be ready !

5) Test

$oracle_server=»server»;
$oracle_listener=»listener»;
$oracle_sid=»SID»;
$oracle_port=»PORT»;
$oracle_user=»user»;
$oracle_password=»password»;
$oracle_testing_table=»TABLE»;

my $dbh = DBI->connect(«dbi:Oracle:host=$oracle_server;port=$oracle_port;sid=$oracle_sid»,
$oracle_user, $oracle_password)
or die «Impossible de se connecter à la base Oracle : » . DBI->errstr;

my $sth = $dbh->prepare(«SELECT * FROM $oracle_testing_table»)
or die «Impossible de preparer la requette: » . $dbh->errstr;

$sth->execute()
or die «Impossible d’exécuter la requette: » . $sth->errstr;

while ( my @data = $sth->fetchrow_array() )
my $firstname = $data[1];
my $id = $data[2];
print «\t$id: $firstname $lastname\n»;
>

if ($sth->rows == 0)
print «Table vide\n»;
>

Références:

Thanks to:

Pawel Grygiel for the update concerning the .zip archive that don’t support symbolic links.

Jean-Christophe Duberga, jeanchristophe.duber >AT< free.fr - CRI - Université Bordeaux2

Источник

Оцените статью
Adblock
detector