Support

Configuring ROracle on RStudio Connect

Follow

 

Preface

This article assumes Oracle Instant Client Basic & SDK, and ROracle, are already installed. For assistance installing ROracle, visit this page.

As an alternative to ROracle, you may wish to consider using the DBI R package and the RStudio Commercial Drivers. For more information, see https://db.rstudio.com/databases/oracle/.

If you are using RStudio Server Pro, RStudio Connect, or Shiny Server Pro, then you can download and use RStudio Professional Drivers at no additional charge, available here:  https://www.rstudio.com/products/drivers/download-commercial/ 

 

Configuring ROracle on RStudio Connect

The final steps of the ROracle Installation involve setting several paths in the environment to include LD_LIBRARY_PATHOCI_LIB, and ORACLE_HOME.

The LD_LIBRARY_PATH must be set prior to the R process executing.  Using R startup files such as Renviron.site and Rprofile.site will not suffice, since the R process has already started.  The ideal way to set this value is to use a Program Supervisor script:  http://docs.rstudio.com/connect/admin/process-management.html#program-supervisors 

As an example, here is a configuration that uses a custom script to prepare a custom execution environment before finally running R.  

Add the following to: /etc/rstudio-connect/rstudio-connect.gcfg

[Applications]
Supervisor = /opt/scripts/environment.sh


Then, the contents of example environment.sh could be something like:

#!/bin/bash

echo arguments: "$@"
echo

export LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib:$LD_LIBRARY_PATH"
export OCI_LIB="/scratch/instantclient_11_2"
export ORACLE_HOME="/path/to/oracle/home/"

exec "$@"

 

Note:  In this example, /opt/scripts/ was used to store the script to avoid any directories masked by the sandbox.  The following locations are masked during R execution:

  • The Server.DataDir directory, containing all variable data used by RStudio Connect.
  • The SQLite.Dir directory, which can optionally be placed outside the data directory.
  • Configuration directories, including /etc/rstudio-connect.
  • The Server.TempDir/connect-workspaces directory, which contains temporary directories, one per R process.

http://docs.rstudio.com/connect/admin/process-management.html#process-management-sandboxing 

Comments