B.3 About R Package Installation for Oracle Machine Learning for R
Embedded R execution with OML4R allows the use of CRAN or other third-party R packages in user-defined R functions ran on the Oracle Database server.
The steps for installing and configuring packages for use with OML4R are the same as for open source R. The database-side R engine just needs to know where to find the R packages.
The OML4R installation is performed by the user oracle, which typically does not have write permission to the default site-wide library, /usr/lib64/R/library
. On Linux and UNIX platforms, the OML4R Server installation provides the ORE
script ran from the operating system shell to install R packages and to start R. The ORE
script is a wrapper for the default R script, a shell wrapper for the R executable. It can be used to start R, run batch scripts, and build or install R packages. Unlike the default R script, the ORE
script installs packages to a location writable by the oracle user and accessible by all OML4R users: $ORACLE_HOME/R/library
.
To install a package on the database server so that any R user can use it and for use in embedded R execution, an Oracle DBA would typically download the package source from CRAN using wget
. If the package depends on any packages that are not in the R distribution in use, download the sources for those packages, also.
For a single Oracle Database instance, replace the R script with ORE
to install the packages in the same location as the OML4R packages.
$ wget https://cran.r-project.org/src/contrib/arules_1.1-9.tar.gz $ ORE CMD INSTALL arules_1.1-9.tar.gz
Behind the scenes, the ORE
script performs the equivalent of setting R_LIBS_USER
to the value of $ORACLE_HOME/R/library
, and all R packages installed with the ORE
script are installed to this location. For installing a package on multiple database servers, such as those in an Oracle Real Application Clusters (Oracle RAC) or a multinode Oracle Exadata Database Machine environment, use the ORE
script in conjunction with the Exadata Distributed Command Line Interface (DCLI) utility.
$ dcli -g nodes -l oracle ORE CMD INSTALL arules_1.1-9.tar.gz
The DCLI -g flag designates a file containing a list of nodes to install on, and the -l flag specifies the user id to use when executing the commands.
If you are using an OML4R client, install the package in the same way as any R package, bearing in mind that you must install the same version of the package on both the client and server machines to avoid incompatibilities.
Parent topic: R Package Installation Tips