安装SparkR

原文地址:http://blog.csdn.net/wind520/article/details/48814129

必须条件:

1:安装好JDK

2:安装好R

步骤1: 运行R Shell

[plain]  view plain  copy
  1. [jifeng@feng03 R-3.1.1]$ R  
  2.   
  3. R version 3.1.1 (2014-07-10) -- "Sock it to Me"  
  4. Copyright (C) 2014 The R Foundation for Statistical Computing  
  5. Platform: x86_64-unknown-linux-gnu (64-bit)  
  6.   
  7. R is free software and comes with ABSOLUTELY NO WARRANTY.  
  8. You are welcome to redistribute it under certain conditions.  
  9. Type 'license()' or 'licence()' for distribution details.  
  10.   
  11.   Natural language support but running in an English locale  
  12.   
  13. R is a collaborative project with many contributors.  
  14. Type 'contributors()' for more information and  
  15. 'citation()' on how to cite R or R packages in publications.  
  16.   
  17. Type 'demo()' for some demos, 'help()' for on-line help, or  
  18. 'help.start()' for an HTML browser interface to help.  
  19. Type 'q()' to quit R.  
  20.   
  21. >  

步骤2: 安装rJava

install.packages("rJava")

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

[plain]  view plain  copy
  1. Selection: 21  
  2. trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/rJava_0.9-7.tar.gz'  
  3. Content type 'application/octet-stream' length 711181 bytes (694 Kb)  
  4. opened URL  
  5. ==================================================  
  6. downloaded 694 Kb  
  7.   
  8. * installing *source* package ‘rJava’ ...  
  9. ** package ‘rJava’ successfully unpacked and MD5 sums checked  
  10. checking for gcc... gcc -std=gnu99  
  11. checking whether the C compiler works... yes  
  12. checking for C compiler default output file name... a.out  
  13. checking for suffix of executables...   
  14. checking whether we are cross compiling... no  
  15. checking for suffix of object files... o  
  16. checking whether we are using the GNU C compiler... yes  
  17. checking whether gcc -std=gnu99 accepts -g... yes  
  18. checking for gcc -std=gnu99 option to accept ISO C89... none needed  
  19. checking how to run the C preprocessor... gcc -std=gnu99 -E  
  20. checking for grep that handles long lines and -e... /bin/grep  
  21. checking for egrep... /bin/grep -E  
  22. checking for ANSI C header files... yes  
  23. checking for sys/wait.h that is POSIX.1 compatible... yes  
  24. checking for sys/types.h... yes  
  25. checking for sys/stat.h... yes  
  26. checking for stdlib.h... yes  
  27. checking for string.h... yes  
  28. checking for memory.h... yes  
  29. checking for strings.h... yes  
  30. checking for inttypes.h... yes  
  31. checking for stdint.h... yes  
  32. checking for unistd.h... yes  
  33. checking for string.h... (cached) yes  
  34. checking sys/time.h usability... yes  
  35. checking sys/time.h presence... yes  
  36. checking for sys/time.h... yes  
  37. checking for unistd.h... (cached) yes  
  38. checking for an ANSI C-conforming const... yes  
  39. checking whether time.h and sys/time.h may both be included... yes  
  40. configure: checking whether gcc -std=gnu99 supports static inline...  
  41. yes  
  42. checking whether setjmp.h is POSIX.1 compatible... yes  
  43. checking whether sigsetjmp is declared... yes  
  44. checking whether siglongjmp is declared... yes  
  45. checking Java support in R... present:  
  46. interpreter : '/home/jifeng/jdk1.7.0_79/jre/bin/java'  
  47. archiver    : '/home/jifeng/jdk1.7.0_79/bin/jar'  
  48. compiler    : '/home/jifeng/jdk1.7.0_79/bin/javac'  
  49. header prep.: '/home/jifeng/jdk1.7.0_79/bin/javah'  
  50. cpp flags   : '-I/home/jifeng/jdk1.7.0_79/include -I/home/jifeng/jdk1.7.0_79/include/linux'  
  51. java libs   : '-L/home/jifeng/jdk1.7.0_79/jre/lib/amd64/server -ljvm'  
  52. checking whether Java run-time works... yes  
  53. checking whether -Xrs is supported... yes  
  54. checking whether JNI programs can be compiled... yes  
  55. checking JNI data types... ok  
  56. checking whether JRI should be compiled (autodetect)... yes  
  57. checking whether debugging output should be enabled... no  
  58. checking whether memory profiling is desired... no  
  59. checking whether threads support is requested... no  
  60. checking whether callbacks support is requested... no  
  61. checking whether JNI cache support is requested... no  
  62. checking whether headless init is enabled... no  
  63. checking whether JRI is requested... yes  
  64. configure: creating ./config.status  
  65. config.status: creating src/Makevars  
  66. config.status: creating R/zzz.R  
  67. config.status: creating src/config.h  
  68. === configuring in jri (/tmp/RtmpOBzOar/R.INSTALL5b041b635dec/rJava/jri)  
  69. configure: running /bin/sh ./configure --disable-option-checking '--prefix=/usr/local'  --cache-file=/dev/null --srcdir=.  
  70. checking build system type... x86_64-unknown-linux-gnu  
  71. checking host system type... x86_64-unknown-linux-gnu  
  72. checking for gcc... gcc -std=gnu99  
  73. checking for C compiler default output file name... a.out  
  74. checking whether the C compiler works... yes  
  75. checking whether we are cross compiling... no  
  76. checking for suffix of executables...   
  77. checking for suffix of object files... o  
  78. checking whether we are using the GNU C compiler... yes  
  79. checking whether gcc -std=gnu99 accepts -g... yes  
  80. checking for gcc -std=gnu99 option to accept ISO C89... none needed  
  81. checking how to run the C preprocessor... gcc -std=gnu99 -E  
  82. checking for grep that handles long lines and -e... /bin/grep  
  83. checking for egrep... /bin/grep -E  
  84. checking for ANSI C header files... yes  
  85. checking whether Java interpreter works... checking whether JNI programs can be compiled... yes  
  86. checking whether JNI programs can be run... yes  
  87. checking JNI data types... ok  
  88. checking whether Rinterface.h exports R_CStackXXX variables... yes  
  89. checking whether Rinterface.h exports R_SignalHandlers... yes  
  90. configure: creating ./config.status  
  91. config.status: creating src/Makefile  
  92. config.status: creating Makefile  
  93. config.status: creating run  
  94. config.status: creating src/config.h  
  95. ** libs  
  96.   
  97. /home/jifeng/jdk1.7.0_79/bin/javac -target 1.4 -source 1.4 -classpath src/JRI.jar -d examples examples/rtest2.java  
  98. warning: [options] bootstrap class path not set in conjunction with -source 1.4  
  99. Note: examples/rtest2.java uses or overrides a deprecated API.  
  100. Note: Recompile with -Xlint:deprecation for details.  
  101. 1 warning  
  102. make[1]: Leaving directory `/tmp/RtmpOBzOar/R.INSTALL5b041b635dec/rJava/jri'  
  103. installing via 'install.libs.R' to /home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/rJava  
  104. ** R  
  105. ** inst  
  106. ** preparing package for lazy loading  
  107. ** help  
  108. *** installing help indices  
  109. ** building package indices  
  110. ** testing if installed package can be loaded  
  111. * DONE (rJava)  
  112.   
  113. The downloaded source packages are in  
  114.         ‘/tmp/Rtmp1A16li/downloaded_packages’  

步骤3: 在R shell中安装devtools

install.packages("devtools")

[plain]  view plain  copy
  1. > install.packages("devtools")  
  2. Installing package into ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1’  
  3. (as ‘lib’ is unspecified)  
  4. also installing the dependencies ‘stringi’, ‘magrittr’, ‘BH’, ‘mime’, ‘R6’, ‘stringr’, ‘brew’, ‘Rcpp’, ‘xml2’, ‘httr’, ‘curl’, ‘memoise’, ‘whisker’, ‘evaluate’, ‘digest’, ‘rstudioapi’, ‘jsonlite’, ‘roxygen2’, ‘rversions’, ‘git2r’  
  5.   
  6. trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/stringi_0.5-5.tar.gz'  
  7. Content type 'application/octet-stream' length 3639183 bytes (3.5 Mb)  
  8. opened URL  
  9. ==================================================  
  10. downloaded 3.5 Mb  
  11.   
  12. trying URL 'http://mirror.bjtu.edu.cn/cran/src/contrib/magrittr_1.5.tar.gz'  
  13. Content type 'application/octet-stream' length 200504 bytes (195 Kb)  
  14. opened URL  
  15. ==================================================  
  16. downloaded 195 Kb  
出现错误:

[plain]  view plain  copy
  1. ------------------------- ANTICONF ERROR ---------------------------  
  2. Configuration failed because libcurl was not found. Try installing:  
  3.  * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)  
  4.  * rpm: libcurl-devel (Fedora, CentOS, RHEL)  
  5.  * csw: libcurl_dev (Solaris)  
  6. If libcurl is already installed, check that 'pkg-config' is in your  
  7. PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config  
  8. is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:  
  9. R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'  
  10. --------------------------------------------------------------------  
  11. ERROR: configuration failed for package ‘curl’  
  12. * removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/curl’  
  13. * installing *source* package ‘whisker’ ...  
  14. ** package ‘whisker’ successfully unpacked and MD5 sums checked  
  15. ** R  
  16. ** inst  
  17. ** preparing package for lazy loading  
  18. ** help  
  19. *** installing help indices  
  20. ** building package indices  
  21. ** testing if installed package can be loaded  
  22. * DONE (whisker)  
  23. * installing *source* package ‘digest’ ...  
  24. ** package ‘digest’ successfully unpacked and MD5 sums checked  
  25. ** libs  

[plain]  view plain  copy
  1. configure: error: in `/tmp/RtmpkQMD9t/R.INSTALL6c1166a0db0e/git2r':  
  2. configure: error:   
  3.   ---------------------------------------------  
  4.    OpenSSL library required  
  5.   
  6.    Please install:  
  7.    libssl-dev (deb) or openssl-devel (rpm)  
  8.   ---------------------------------------------  
  9. See `config.log' for more details  
  10. ERROR: configuration failed for package ‘git2r’  
  11. * removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/git2r’  
  12. * installing *source* package ‘stringr’ ...  
  13. ** package ‘stringr’ successfully unpacked and MD5 sums checked  
  14. ** R  
  15. ** inst  
  16. ** preparing package for lazy loading  
  17. ** help  
  18. *** installing help indices  
  19. ** building package indices  
  20. ** installing vignettes  
  21. ** testing if installed package can be loaded  
  22. * DONE (stringr)  
  23. * installing *source* package ‘xml2’ ...  
  24. ** package ‘xml2’ successfully unpacked and MD5 sums checked  
  25. Package libxml-2.0 was not found in the pkg-config search path.  
  26. Perhaps you should add the directory containing `libxml-2.0.pc'  
  27. to the PKG_CONFIG_PATH environment variable  
  28. No package 'libxml-2.0' found  
  29. Package libxml-2.0 was not found in the pkg-config search path.  
  30. Perhaps you should add the directory containing `libxml-2.0.pc'  
  31. to the PKG_CONFIG_PATH environment variable  
  32. No package 'libxml-2.0' found  
  33. Using PKG_CFLAGS=  
  34. Using PKG_LIBS=-lxml2  
  35. ------------------------- ANTICONF ERROR ---------------------------  
  36. Configuration failed because libxml-2.0 was not found. Try installing:  
  37.  * deb: libxml2-dev (Debian, Ubuntu, etc)  
  38.  * rpm: libxml2-devel (Fedora, CentOS, RHEL)  
  39.  * csw: libxml2_dev (Solaris)  
  40. If libxml-2.0 is already installed, check that 'pkg-config' is in your  
  41. PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config  
  42. is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:  
  43. R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'  
  44. --------------------------------------------------------------------  
  45. ERROR: configuration failed for package ‘xml2’  
  46. * removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/xml2’  
  47. * installing *source* package ‘memoise’ ...  
  48. ** package ‘memoise’ successfully unpacked and MD5 sums checked  
  49. ** R  
  50. ** preparing package for lazy loading  
  51. ** help  
  52. *** installing help indices  
  53. ** building package indices  
  54. ** testing if installed package can be loaded  
  55. * DONE (memoise)  
  56. ERROR: dependency ‘curl’ is not available for package ‘httr’  
  57. * removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/httr’  
  58. * installing *source* package ‘evaluate’ ...  
  59. ** package ‘evaluate’ successfully unpacked and MD5 sums checked  
  60. ** R  
  61. ** preparing package for lazy loading  
  62. ** help  
  63. *** installing help indices  
  64. ** building package indices  
  65. ** testing if installed package can be loaded  
  66. * DONE (evaluate)  
  67. * installing *source* package ‘roxygen2’ ...  
  68. ** package ‘roxygen2’ successfully unpacked and MD5 sums checked  
  69. ** libs  
  70. 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  
  71. 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  
  72. 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  
  73. 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  
  74. 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  
  75. 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  
  76. installing to /home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/roxygen2/libs  
  77. ** R  
  78. ** inst  
  79. ** preparing package for lazy loading  
  80. ** help  
  81. *** installing help indices  
  82. ** building package indices  
  83. ** installing vignettes  
  84. ** testing if installed package can be loaded  
  85. * DONE (roxygen2)  
  86. ERROR: dependencies ‘curl’, ‘xml2’ are not available for package ‘rversions’  
  87. * removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/rversions’  
  88. ERROR: dependencies ‘httr’, ‘curl’, ‘rversions’, ‘git2r’ are not available for package ‘devtools’  
  89. * removing ‘/home/jifeng/R/x86_64-unknown-linux-gnu-library/3.1/devtools’  
  90.   
  91. The downloaded source packages are in  
  92.         ‘/tmp/Rtmp1A16li/downloaded_packages’  
  93. Warning messages:  
  94. 1: In install.packages("devtools") :  
  95.   installation of package ‘curl’ had non-zero exit status  
  96. 2: In install.packages("devtools") :  
  97.   installation of package ‘git2r’ had non-zero exit status  
  98. 3: In install.packages("devtools") :  
  99.   installation of package ‘xml2’ had non-zero exit status  
  100. 4: In install.packages("devtools") :  
  101.   installation of package ‘httr’ had non-zero exit status  
  102. 5: In install.packages("devtools") :  
  103.   installation of package ‘rversions’ had non-zero exit status  
  104. 6: In install.packages("devtools") :  
  105.   installation of package ‘devtools’ had non-zero exit status  

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

[plain]  view plain  copy
  1. [root@feng03 ~]# yum install libcurl-devel  
  2. [root@feng03 ~]# yum install openssl-devel  
  3. [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")


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值