安装SparkR

必须条件:

1:安装好JDK

2:安装好R

步骤1: 运行R Shell

[jifeng@feng03 R-3.1.1]$ R

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

>

步骤2: 安装rJava

install.packages("rJava")

> install.packages("rJava")
Warning in install.packages("rJava") :
  'lib = "/usr/local/lib64/R/library"' is not writable
Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
~/R/x86_64-unknown-linux-gnu-library/3.1
to install packages into?  (y/n) y
--- Please select a CRAN mirror for use in this session ---
CRAN mirror 

  1: 0-Cloud [https]                2: 0-Cloud                    
  3: Algeria                        4: Argentina (La Plata)       
  5: Australia (Canberra)           6: Australia (Melbourne)      
  7: Austria [https]                8: Austria                    
  9: Belgium (Antwerp)             10: Belgium (Ghent)            
 11: Brazil (BA)                   12: Brazil (PR)                
 13: Brazil (RJ)                   14: Brazil (SP 1)              
 15: Brazil (SP 2)                 16: Canada (BC)                
 17: Canada (NS)                   18: Canada (ON)                
 19: Chile [https]                 20: Chile                      
 21: China (Beijing 2)             22: China (Beijing 3)          
 23: China (Beijing 4) [https]     24: China (Beijing 4)          
 25: China (Hefei) [https]         26: China (Hefei)              
 27: China (Xiamen)                28: Colombia (Cali) [https]    
 29: Colombia (Cali)               30: Czech Republic             
 31: Denmark                       32: Ecuador                    
 33: El Salvador                   34: Estonia                    
 35: France (Lyon 1)               36: France (Lyon 2) [https]    
 37: France (Lyon 2)               38: France (Montpellier)       
 39: France (Paris 1)              40: France (Paris 2)           
 41: Germany (Berlin)              42: Germany (G?ttingen)        
 43: Germany (Münster) [https]     44: Germany (Münster)          
 45: Greece                        46: Hungary                    
 47: Iceland [https]               48: Iceland                    
 49: India                         50: Indonesia (Jakarta)        
 51: Iran                          52: Ireland                    
 53: Italy (Milano)                54: Italy (Padua) [https]      
 55: Italy (Padua)                 56: Italy (Palermo)            
 57: Japan (Tokyo)                 58: Japan (Yamagata)           
 59: Korea (Seoul 1)               60: Korea (Seoul 2)            
 61: Korea (Ulsan)                 62: Lebanon                    
 63: Mexico (Mexico City)          64: Mexico (Texcoco)           
 65: Netherlands (Amsterdam)       66: Netherlands (Utrecht)      
 67: New Zealand                   68: Norway                     
 69: Philippines                   70: Poland                     
 71: Portugal (Lisbon)             72: Portugal (Porto)           
 73: Russia (Moscow) [https]       74: Russia (Moscow)            
 75: Slovakia                      76: South Africa (Cape Town)   
 77: South Africa (Johannesburg)   78: Spain (A Coru?a) [https]   
 79: Spain (A Coru?a)              80: Spain (Madrid)             
 81: Sweden                        82: Switzerland [https]        
 83: Switzerland                   84: Taiwan (Chungli)           
 85: Taiwan (Taipei)               86: Thailand                   
 87: Turkey (Denizli)              88: Turkey (Mersin)            
 89: UK (Bristol) [https]          90: UK (Bristol)               
 91: UK (Cambridge) [https]        92: UK (Cambridge)             
 93: UK (London 1)                 94: UK (London 2)              
 95: UK (St Andrews)               96: USA (CA 1) [https]         
 97: USA (CA 1)                    98: USA (CA 2)                 
 99: USA (CO)                     100: USA (IA)                   
101: USA (IN)                     102: USA (KS) [https]           
103: USA (KS)                     104: USA (MD)                   
105: USA (MI 1) [https]           106: USA (MI 1)                 
107: USA (MI 2)                   108: USA (MO)                   
109: USA (NC)                     110: USA (OH 1)                 
111: USA (OH 2)                   112: USA (OR)                   
113: USA (PA 1)                   114: USA (PA 2)                 
115: USA (TN) [https]             116: USA (TN)                   
117: USA (TX) [https]             118: USA (TX)                   
119: USA (WA) [https]             120: USA (WA)                   
121: Venezuela                    122: Vietnam                    
选择21

Selection: 21
trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/rJava_0.9-7.tar.gz'
Content type 'application/octet-stream' length 711181 bytes (694 Kb)
opened URL
==================================================
downloaded 694 Kb

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/home/jifeng/jdk1.7.0_79/jre/bin/java'
archiver    : '/home/jifeng/jdk1.7.0_79/bin/jar'
compiler    : '/home/jifeng/jdk1.7.0_79/bin/javac'
header prep.: '/home/jifeng/jdk1.7.0_79/bin/javah'
cpp flags   : '-I/home/jifeng/jdk1.7.0_79/include -I/home/jifeng/jdk1.7.0_79/include/linux'
java libs   : '-L/home/jifeng/jdk1.7.0_79/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... ok
checking whether JRI should be compiled (autodetect)... yes
checking whether debugging output should be enabled... no
checking whether memory profiling is desired... no
checking whether threads support is requested... no
checking whether callbacks support is requested... no
checking whether JNI cache support is requested... no
checking whether headless init is enabled... no
checking whether JRI is requested... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
=== configuring in jri (/tmp/RtmpOBzOar/R.INSTALL5b041b635dec/rJava/jri)
configure: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/local'  --cache-file=/dev/null --srcdir=.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking whether Java interpreter works... checking whether JNI programs can be compiled... yes
checking whether JNI programs can be run... yes
checking JNI data types... ok
checking whether Rinterface.h exports R_CStackXXX variables... yes
checking whether Rinterface.h exports R_SignalHandlers... yes
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating Makefile
config.status: creating run
config.status: creating src/config.h
** libs

/home/jifeng/jdk1.7.0_79/bin/javac -target 1.4 -source 1.4 -classpath src/JRI.jar -d examples examples/rtest2.java
warning: [options] bootstrap class path not set in conjunction with -source 1.4
Note: examples/rtest2.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
make[1]: Leaving directory `/tmp/RtmpOBzOar/R.INSTALL5b041b635dec/rJava/jri'
installing via 'install.libs.R' to /home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/rJava
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (rJava)

The downloaded source packages are in
        ‘/tmp/Rtmp1A16li/downloaded_packages’

步骤3: 在R shell中安装devtools

install.packages("devtools")

> install.packages("devtools")
Installing package into ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
also installing the dependencies ‘stringi’, ‘magrittr’, ‘BH’, ‘mime’, ‘R6’, ‘stringr’, ‘brew’, ‘Rcpp’, ‘xml2’, ‘httr’, ‘curl’, ‘memoise’, ‘whisker’, ‘evaluate’, ‘digest’, ‘rstudioapi’, ‘jsonlite’, ‘roxygen2’, ‘rversions’, ‘git2r’

trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/stringi_0.5-5.tar.gz'
Content type 'application/octet-stream' length 3639183 bytes (3.5 Mb)
opened URL
==================================================
downloaded 3.5 Mb

trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/magrittr_1.5.tar.gz'
Content type 'application/octet-stream' length 200504 bytes (195 Kb)
opened URL
==================================================
downloaded 195 Kb
出现错误:

------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘curl’
* removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/curl’
* installing *source* package ‘whisker’ ...
** package ‘whisker’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (whisker)
* installing *source* package ‘digest’ ...
** package ‘digest’ successfully unpacked and MD5 sums checked
** libs

configure: error: in `/tmp/RtmpkQMD9t/R.INSTALL6c1166a0db0e/git2r':
configure: error: 
  ---------------------------------------------
   OpenSSL library required

   Please install:
   libssl-dev (deb) or openssl-devel (rpm)
  ---------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/git2r’
* installing *source* package ‘stringr’ ...
** package ‘stringr’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (stringr)
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lxml2
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)
 * csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘xml2’
* removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/xml2’
* installing *source* package ‘memoise’ ...
** package ‘memoise’ successfully unpacked and MD5 sums checked
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (memoise)
ERROR: dependency ‘curl’ is not available for package ‘httr’
* removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/httr’
* installing *source* package ‘evaluate’ ...
** package ‘evaluate’ successfully unpacked and MD5 sums checked
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (evaluate)
* installing *source* package ‘roxygen2’ ...
** package ‘roxygen2’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/local/lib64/R/include -DNDEBUG  -I/usr/local/include -I"/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include"   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/local/lib64/R/include -DNDEBUG  -I/usr/local/include -I"/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include"   -fpic  -g -O2  -c isComplete.cpp -o isComplete.o
g++ -I/usr/local/lib64/R/include -DNDEBUG  -I/usr/local/include -I"/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include"   -fpic  -g -O2  -c leadingSpaces.cpp -o leadingSpaces.o
g++ -I/usr/local/lib64/R/include -DNDEBUG  -I/usr/local/include -I"/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include"   -fpic  -g -O2  -c parser.cpp -o parser.o
g++ -I/usr/local/lib64/R/include -DNDEBUG  -I/usr/local/include -I"/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include"   -fpic  -g -O2  -c wrapString.cpp -o wrapString.o
g++ -shared -L/usr/local/lib64 -o roxygen2.so RcppExports.o isComplete.o leadingSpaces.o parser.o wrapString.o -L/usr/local/lib64/R/lib -lR
installing to /home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/roxygen2/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (roxygen2)
ERROR: dependencies ‘curl’, ‘xml2’ are not available for package ‘rversions’
* removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/rversions’
ERROR: dependencies ‘httr’, ‘curl’, ‘rversions’, ‘git2r’ are not available for package ‘devtools’
* removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/devtools’

The downloaded source packages are in
        ‘/tmp/Rtmp1A16li/downloaded_packages’
Warning messages:
1: In install.packages("devtools") :
  installation of package ‘curl’ had non-zero exit status
2: In install.packages("devtools") :
  installation of package ‘git2r’ had non-zero exit status
3: In install.packages("devtools") :
  installation of package ‘xml2’ had non-zero exit status
4: In install.packages("devtools") :
  installation of package ‘httr’ had non-zero exit status
5: In install.packages("devtools") :
  installation of package ‘rversions’ had non-zero exit status
6: In install.packages("devtools") :
  installation of package ‘devtools’ had non-zero exit status

根据错误安装,我这里安装了

[root@feng03 ~]# yum install libcurl-devel
[root@feng03 ~]# yum install openssl-devel
[root@feng03 ~]# yum install libxml2-devel

进入R shell

>install.packages("git2r")

>install.packages("xml2")

>install.packages("rversions")

步骤4: 安装好rJava及devtools,接下来安装SparkR


library(devtools)
install_github("amplab-extras/SparkR-pkg", subdir="pkg")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值