OracleR

ROracle sur Linux x86-64 avec un client 12c

J’ai récemment rencontré un problème lors de l’installation de ROracle 1.2-1 sur une machine Ubuntu avec un client 12c:

raphael@raphael-Alienware-14:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
raphael@raphael-Alienware-14:~$ 
raphael@raphael-Alienware-14:~$ uname -a
Linux raphael-Alienware-14 3.13.0-66-generic #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
raphael@raphael-Alienware-14:~$

Mise en place du client Oracle

Un Instant Client a été préalablement mis en place. Pour cela, les packages suivants ont été téléchargés:

  • Instant Client Package – Basic
  • Instant Client Package – SDK

Ils ont été décompressés dans le répertoire « /home/raphael/Oracle/instantclient_12_1 ». Les variables ORACLE_HOME, LD_LIBRARY_PATH et OCI_LIB ont ensuite été valorisées:

raphael@raphael-Alienware-14:~$ echo $ORACLE_HOME
/home/raphael/Oracle/instantclient_12_1
raphael@raphael-Alienware-14:~$ echo $OCI_LIB
/home/raphael/Oracle/instantclient_12_1
raphael@raphael-Alienware-14:~$ echo $LD_LIBRARY_PATH 
/home/raphael/Oracle/instantclient_12_1
raphael@raphael-Alienware-14:~$

Installation du package DBI

raphael@raphael-Alienware-14:~$ wget https://cran.r-project.org/src/contrib/DBI_0.3.1.tar.gz
--2015-10-24 22:45:39-- https://cran.r-project.org/src/contrib/DBI_0.3.1.tar.gz
Résolution de cran.r-project.org (cran.r-project.org)... 137.208.57.37
Connexion vers cran.r-project.org (cran.r-project.org)|137.208.57.37|:443... connecté.
requête HTTP transmise, en attente de la réponse... 200 OK
Taille : 30106 (29K) [application/x-gzip]
Enregistre : «DBI_0.3.1.tar.gz.1»

100%[===================================================================================>] 30 106 --.-K/s ds 0,1s 

2015-10-24 22:45:39 (235 KB/s) - «DBI_0.3.1.tar.gz.1» enregistré [30106/30106]

raphael@raphael-Alienware-14:~$ R CMD INSTALL DBI_0.3.1.tar.gz 
* installing to library ‘/home/raphael/R/x86_64-pc-linux-gnu-library/3.0’
* installing *source* package ‘DBI’ ...
** package ‘DBI’ correctement décompressé et sommes MD5 vérifiées
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (DBI)
raphael@raphael-Alienware-14:~$

Installation de ROracle

L’installation échoue en raison de l’absence d’un répertoire:

raphael@raphael-Alienware-14:~$ wget https://cran.r-project.org/src/contrib/ROracle_1.2-1.tar.gz
--2015-10-24 22:46:22-- https://cran.r-project.org/src/contrib/ROracle_1.2-1.tar.gz
Résolution de cran.r-project.org (cran.r-project.org)... 137.208.57.37
Connexion vers cran.r-project.org (cran.r-project.org)|137.208.57.37|:443... connecté.
requête HTTP transmise, en attente de la réponse... 200 OK
Taille : 299072 (292K) [application/x-gzip]
Enregistre : «ROracle_1.2-1.tar.gz»

100%[===================================================================================>] 299 072 178KB/s ds 1,6s 

2015-10-24 22:46:24 (178 KB/s) - «ROracle_1.2-1.tar.gz» enregistré [299072/299072]

raphael@raphael-Alienware-14:~$ R CMD INSTALL ROracle_1.2-1.tar.gz 
* installing to library ‘/home/raphael/R/x86_64-pc-linux-gnu-library/3.0’
* installing *source* package ‘ROracle’ ...
** package ‘ROracle’ correctement décompressé et sommes MD5 vérifiées
configure: error: "/home/raphael/Oracle/instantclient_12_1/rdbms/public" directory does not exist
ERROR: configuration failed for package ‘ROracle’
* removing ‘/home/raphael/R/x86_64-pc-linux-gnu-library/3.0/ROracle’
raphael@raphael-Alienware-14:~$

Il apparaît que la valorisation de la variable d’environnement OCI_INC permet de solutionner le problème:

raphael@raphael-Alienware-14:~$ 
raphael@raphael-Alienware-14:~$ export OCI_INC=/home/raphael/Oracle/instantclient_12_1/sdk/include
raphael@raphael-Alienware-14:~$ 
raphael@raphael-Alienware-14:~$ R CMD INSTALL ROracle_1.2-1.tar.gz 
* installing to library ‘/home/raphael/R/x86_64-pc-linux-gnu-library/3.0’
* installing *source* package ‘ROracle’ ...
** package ‘ROracle’ correctement décompressé et sommes MD5 vérifiées
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/home/raphael/Oracle/instantclient_12_1/sdk/include -fpic -O3 -pipe -g -c rodbi.c -o rodbi.o
rodbi.c: In function ‘rodbiResBind’:
rodbi.c:2293:11: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘sb8’ [-Wformat=]
 sprintf(err_buf, RODBI_ERR_BIND_VAL_TOOBIG, bndsz);
 ^
rodbi.c:2336:9: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type ‘sb8’ [-Wformat=]
 sprintf(err_buf, RODBI_ERR_BIND_VAL_TOOBIG, bndsz);
 ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/home/raphael/Oracle/instantclient_12_1/sdk/include -fpic -O3 -pipe -g -c rooci.c -o rooci.o
gcc -std=gnu99 -shared -o ROracle.so rodbi.o rooci.o -L/home/raphael/Oracle/instantclient_12_1 -lclntsh -L/usr/lib/R/lib -lR
installing to /home/raphael/R/x86_64-pc-linux-gnu-library/3.0/ROracle/libs
** R
** inst
** preparing package for lazy loading
Creating a generic function for ‘summary’ from package ‘base’ in package ‘ROracle’
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ROracle)
raphael@raphael-Alienware-14:~$

Néanmoins selon le guide d’installation, le positionnement de cette variable ne devrait pas être nécessaire dans la mesure ou les headers du clients sont stockés dans leur localisation par défaut:

« Both methods assume that Basic and SDK packages were unzipped into the same directory and Oracle Client headers are located under $OCI_LIB/sdk/include. If this is not the case, then set either the OCI_INC environment variable or the –with-oci-inc configure option appropriately. »

Test de connectivité

raphael@raphael-Alienware-14:~$ R

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.

R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.

Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.

> library(ROracle)
Le chargement a nécessité le package : DBI
> ora = Oracle()
> cnx = dbConnect(ora, username="rafa", password="rafa", dbname="192.168.1.22:1521/PDB_ODM")
> summary(cnx)
User name: rafa 
Connect string: 192.168.1.22:1521/PDB_ODM 
Server version: 12.1.0.2.0 
Server type: Oracle RDBMS 
Results processed: 0 
OCI prefetch: FALSE 
Bulk read: 1000 
Bulk write: 1000 
Statement cache size: 0 
Open results: 0 
> dbDisconnect(cnx)
[1] TRUE
>

 

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *