在Linux下安装ROracle比较简单,只需要用install.packages("ROracle")即可,而在windows下要通过源码安装。
1.下载oracle client
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
2.安装oracle client
[root@hadoop2 ~]# rpm -ivhoracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
Preparing... ################################ [100%]
1:oracle-instantclient11.################################[100%]
[root@hadoop2 ~]# rpm -ivhoracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
Preparing... ################################ [100%]
1:oracle-instantclient11.################################[100%]
3.下载ROracle 包
https://cran.r-project.org/web/packages/ROracle/index.html
ROracle_1.2-2.tar.gz
4.设置环境变量
# vi ~/.bash_profile
exportLD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
注:如果没有设置环境变量,在下一步安装ROracle包时,会出现下面的错误:
** building package indices
** testing if installed packagecan be loaded
Error in dyn.load(file, DLLpath= DLLpath, ...) :
无法载入共享目标对象‘/usr/lib64/R/library/ROracle/libs/ROracle.so’::
libclntsh.so.11.1: 无法打开共享对象文件: 没有那个文件或目录
错误: 载入失败
停止执行
ERROR: loading failed
5.安装DBI包
R
>install.packages(“DBI”)
6.安装ROracle 包
# R CMD INSTALL--configure-args='--with-oci-lib=/usr/lib/oracle/11.2/client64/lib--with-oci-inc=/usr/include/oracle/11.2/client64' ROracle_1.2-2.tar.gz
......
** building package indices
** testing if installed package can beloaded
* DONE (ROracle)
Making 'packages.html' ... 好了