远程教学支持系统
 
STUDENT
 
FACULTY
 
SCHOOL
 
SUPPORT
 
PUBLIC
 
SIGNUP
DAILY QUIZ
 
     
  B U L L E T I N    B O A R D

Intall ROracle Package for Windows and Mac OS

(Subject: R Programming/Authored by: Liping Liu on 10/8/2023 4:00:00 AM)/Views: 10793
Blog    News    Post   

Since ROracle package comes as a source code, its installation requires compilation. The installation is further complicated due to requiring Oracle client. Also, for Mac OS, fix_oralib.rb has been obsolete since Oracle Instant client 12.1 for OS X was released, we will get many errors related to loading dylib files from Oracle client:

  1. OCI Libraries not found
  2. Library not loaded: @rpath/libclntsh.dylib.12.1 Referenced from: /Library/Frameworks/R.frameworks/...
  3. Other errors with Xcode

There is no single correct instruction on how to get the package installed on latest Mac OS systems such as Yosemite and El Capitan. The following documents working instructions for both Windows and Mac OS.

A Shortcut Procedure to Install ROracle for Windows (Updated on 10/8/2023)

If you want a customized installation, please follow the procedure below that I proposed on 6/21/2022. Otherwise, this is a much simpler procedure to install ROracle:

  1. Install the current version of R-core, such as R 4.3.
  2. Install R Studio from https://www.rstudio.com/products/rstudio/download/#download
  3. Install Rtools from https://cran.r-project.org/bin/windows/Rtools/ (make sure to download the version that matches your R version and choose default settings during the installation)
  4. Download the archive file from your ecourse.org account and extract the folder "instantclient" to C drive so that your Oracle 22c client will be in c:\instantclient. Extract other two files, environmentVars.bat and ROracle_1.3-2.tar.gz to your desktop
  5. Right mouse click on environmentVars.bat file and choose run it as Administrator. This will change your registry items for required environment variables.
  6. Now open R or RStudio and run the following four commands and make sure you navigate to the desktop and choose ROracle_1.3-2.tar.gz to continue:

        install.packages("DBI")

        library(DBI)

        install.packages(file.choose(), repos=NULL, type="source")

        library(ROracle)

 

Custom Installation of ROracle for Windows (Updated on 6/21/2022)

The installation for Windows is eventless, but make sure you follow the step carefully:

Install Instant Client

  1. Download Oracle Instant Client 64-bit for Windows, including basic Package, sql*plus package, and SDK package from https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
  2. Unzip all the basic package zip files to a folder, say c:\instantclient, and then unzip sql*plus and SDK packages into the same folder. Create a folder called Network inside c:\instantclient. In the end, the c:\instantclient folder should look like the following after unzipping the three compressed files 

Setup OCI_LIB64 and Path Environment Variables

Follow the instruction at https://www.ecourse.org/news.asp?which=5822 on how to setup Windows environment variables.
  1. Go to Control Panel -> System -> Advanced System Settings -> Environment Variables, and add C:\instantclient to the PATH variable
  2. Add a new environment variable OCI_LIB64 that has the value as c:\instantclient
  3. Logout Windows and re-login to make the PATH effective
  4. Open CMD prompt and test it out with the sqlplus command:

        sqlplus scott@//ism.uakron.edu:1521/cob19c.uanet.edu

    If you can connect with that, then you're good to go.

  5.  (optional) Create tnsnames.ora file and save it into c:\instantclient\network\admin folder with the following content:

    ecourse.org =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ecourse.org)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = ol8.ecourse.org)
    )
    )

    COB19C =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST =ism.uakron.edu)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = cob19c.uanet.edu)
    )
    )

    cob19c.uakron.edu =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ism.uakron.edu)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = cob19c.uanet.edu)
    )

     

Install R and R Studio

  1. Install the current version of R-core, such as R 4.2. If you want to download an earlier version, go to https://cran.r-project.org/bin/windows/base/old/3.6.0/. Run the downloaded file to install. 
  2. Install R Studio from https://www.rstudio.com/products/rstudio/download/#download
  3. Install Rtools from https://cran.r-project.org/bin/windows/Rtools/

Install ROracle

  1. Download ROracle_1.3-2.tar.gz (for R 3.6 version) from https://www.oracle.com/database/technologies/roracle-downloads.html (the file can be also found here)
  2. Open R or R Studio and run command: install.packages("DBI") and then load the package using command library(DBI)
  3. Run command: install.packages(file.choose(), repos=NULL, type="source") to choose the downloaded zip file to install.
  4. Run command: library(ROracle)

To test Oracle connection 

Run the following two commands in R:

  • c.string="ism.uakron.edu:1521/cob19c.uanet.edu"
  • con=dbConnect(Oracle(),username="scott",password="tiger",dbname=c.string)
  • dbListTables(con)

 

ROracle for Mac OS (Updated on 6/21/2022)

Follow the instructions carefully. First you will need to get Oracle Instant Client successfully.

Prerequisite: install Xcode command line tools using the command in. terminal:

xcode-select –install

Install Oracle Instant Client

 1.  Download three files (base package, SQL*Plus package, and sdk package) from https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html and unzip all of them into instantclient inside your Downloads folder. After unzipping, instantclient folder looks like the follow:

2.  Create directory /usr/local/oracle and then copy instantclient into it:

sudo mkdir /usr/local/oracle
sudo mv ~/Downloads/instantclient /usr/local/oracle/instantclient

3.  Open the system /etc/profile

sudo nano /etc/profile

Add the following lines to /etc/profile file at the end

ORACLE_HOME="/usr/local/oracle/instantclient"
export ORACLE_HOME
DYLD_LIBRARY_PATH=$ORACLE_HOME:$DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH PATH=$ORACLE_HOME:$PATH export PATH

Then save it and reload your profile

    source /etc/profile

 Test it out with the sqlplus command line app.

    sqlplus scott@//cobismcourses.uakron.edu:1521/cob19c.uanet.edu

        If you can connect with that, then you're good to go.

5.  (optional) Create tnsnames.ora file and move it into /usr/local/oracle/instantclient/network/admin folder:

        sudo nano tnsnames.ora 

       Add the following content to the file:

        

 ecourse.org =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ecourse.org)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ol8.ecourse.org)
)
)

COB19C =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = cobismcourses.uakron.edu)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cob19c.uanet.edu)
)
)

cob19c.uakron.edu =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = cobismcourses.uakron.edu)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cob19c.uanet.edu)
)

 

Save the file and then move it to the destination folder:

sudo mv tnanames.ora /usr/local/oracle/instantclient/network/admin

                chmod 755 /usr/local/oracle/instantclient/network/admin/tnsnames.ora

 
Now we can use server alias such as cob19c to make connections. 

 

Install ROracle

1.  Open terminal and run the following commands to copy Oracle's library files 

sudo cp /usr/local/oracle/instantclient/*.dylib.19.1 /usr/local/lib
sudo cp /usr/local/oracle/instantclient/*.dylib /usr/local/lib

sudo cp /usr/local/oracle/instantclient/*.dylib.19.1 /Library/Frameworks/R.framework/Resources/lib
sudo cp /usr/local/oracle/instantclient/*.dylib /Library/Frameworks/R.framework/Resources/lib

2.  Download ROracle package file ROracle_1.3-1.1.tar.zip from https://cran.r-project.org/web/packages/ROracle/index.html and save it anywhere, say Downloads folder

3. Open R, and run command: install.packages("DBI")

4. Go back to terminal, run the following commands to install ROracle

sudo R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/oracle/instantclient --with-oci-inc=/usr/local/oracle/instantclient/sdk/include' ~/Downloads/ROracle_1.3-1.1.tar

5.  Now go to R and run command: library(ROracle)

 


           Register

Blog    News    Post
 
     
 
Blog Posts    News Digest    Contact Us    About Developer    Privacy Policy

©1997-2024 ecourse.org. All rights reserved.