7 Postinstallation Tasks for Oracle R Enterprise

This chapter explains how to establish and verify a working environment for Oracle R Enterprise after the software is installed. This chapter contains these topics:

7.1 Creating a Database User for Oracle R Enterprise

After you install Oracle R Enterprise client and server, you must create and configure a database user for Oracle R Enterprise. You can do this by running a script that is supplied with Oracle R Enterprise Server.

The following topics provide instructions for creating an Oracle R Enterprise user:

7.1.1 Executing the demo_user Script

The demo_user script validates the Oracle R Enterprise Server environment and either creates a new user or enables an existing user for Oracle R Enterprise.

To create or modify a database user for Oracle R Enterprise:

  1. Verify that your operating system user ID is a member of the OSDBA group (dba on Linux and UNIX; ora_dba on Windows). See Section 4.2.3.1 for details about OSDBA.

  2. Navigate to the Oracle R Enterprise server directory:

    cd download_directory/server
    
  3. Run the demo_user script:

    -- Linux or UNIX
    ./demo_user.sh
    
    -- Windows
    demo_user.bat
    
  4. The script validates your environment as shown:

    Checking ORACLE_HOME ......... Pass
    Checking ORACLE_SID .......... Pass
    Checking sqlplus ............. Pass
    Checking ORACLE instance ..... Pass
    Checking ORE ................. Pass
    
  5. If the environment is valid, the script displays the value of ORACLE_HOME and ORACLE_SID.

  6. The script displays the following:

    Do you wish to create an ORE user? [yes]
    

    Type yes or press Enter to create a new user for Oracle R Enterprise.

    Type no if you want to modify an existing user.

  7. To create a new user, specify a user name and password. The default user name is rquser.

    • Provide the permanent tablespace for the user. The default is USERS.

    • Provide the temporary tablespace for the user. The default is TEMP.

    To modify an existing user, type the user name.

7.1.2 Granting Privileges to an Oracle R Enterprise User

Oracle R Enterprise users require a basic set of database privileges. Some users may require additional privileges, depending on the tasks they need to perform and the data they need to access.

To grant the basic privileges to RQUSER, start SQL*Plus as sysdba and execute these GRANT statements:

sqlplus /  AS SYSDBA
GRANT CREATE TABLE TO RQUSER;
GRANT CREATE PROCEDURE TO RQUSER;
GRANT CREATE VIEW TO RQUSER;
GRANT CREATE MINING MODEL TO RQUSER;

7.1.3 Granting the RQADMIN Role

The Oracle R Enterprise server installation creates a database role called RQADMIN. A user with the RQADMIN role can create and drop R scripts in the database R script repository for use with embedded R execution.

To grant RQADMIN to RQUSER, start SQL*Plus as sysdba and execute this GRANT statement:

sqlplus / AS SYSDBA
GRANT RQADMIN to RQUSER;

Note:

Use caution when granting the RQADMIN role. Only users that require Oracle R Enterprise administrative privileges should have this role.

7.2 Connecting Oracle R Enterprise Client to Oracle R Enterprise Server

To connect Oracle R Enterprise client to the database, start R using the ORE script:

% ORE
R> library(ORE)

The following examples connect as user RQUSER with password RQUSERpsw:

  • For a remote database, specify the Oracle Database service identifier (SID), the host name, and the port for the connection.

    ore.connect(user="RQUSER", sid="orcl", host="SVR3", password="RQUSERpsw",
                   port=1521, all=TRUE)
    

    Note:

    To avoid specifying the password and other connection details in embedded R scripts, you can use Oracle Wallet. See "Creating an Oracle Wallet for an Oracle R Enterprise Connection".
  • For a local database, specify the connection as follows:

    ore.connect("RQUSER", password="RQUSERpsw", conn_string="", all=TRUE)
    

7.3 Validating Basic Oracle R Enterprise Functionality

After connecting as described in Section 7.2, you can test some of the basic functionality of Oracle R Enterprise with these commands:

## Is the ORE client connected to the ORE server?
## The output of this command should be TRUE.
ore.is.connected()

## List the available database tables 
ore.ls()

## Push an R dataframe to a database table
cars <- ore.push(cars)
head(cars)

## Run embedded R
ore.doEval(function() { 123 })

7.4 Running the Oracle R Enterprise Example Scripts

You can further verify the success of the installation by running the Oracle R Enterprise demo scripts. If a script runs to completion without errors, then the example is successful.

The example scripts are located in $ORACLE_HOME/R/library/ORE/demo.

This R command provides a list of available examples:

demo(package="ORE")

These commands run two of the examples. The aggregate script tests the use of an R function on data that is resident in database memory; the row_apply script tests embedded R execution.

demo("aggregate", package="ORE")
demo("row_apply", package="ORE")

This command exits from R.

q()