SparkR的R3.3.1源碼安裝


   如果想要在spark上使用sparkR必須首先在集羣的所有機器上安裝R包,前面有安裝過R.3.2.1,但是因爲很多R包不支持,所以更新爲3.3.1。

1、安裝依賴
yuminstall gcc
yuminstall gcc-c++
yuminstall gcc-gfortran
yuminstall pcre-devel
yuminstall tcl-devel
yuminstall zlib-devel
yuminstall bzip2-devel
yuminstall libX11-devel
yuminstall readline-devel    #否則報”–with-readline=yes (default) and headers/libs are not available”錯誤
yuminstall libXt-devel          #否則報”configure: error: –with-x=yes (default) and X11 headers/libs are not available”錯誤
yuminstall tk-devel
yuminstalltetex-latex
yum -y install libcurl libcurl-devel
2、 編譯
下載R包解壓縮
進入/usr/local/program/R-3.3.1/ 目錄下,執行
./configure
1、報錯 checking if zlib version >= 1.2.5... no
checking whether zlib support suffices... configure: error: zlib library and headers are required
解決:
tar xvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/opt/zlib-1.2.8
make && make install
2、報錯checking if zlib version >= 1.2.5... no
checking whether zlib support suffices... configure: error: zlib library and headers are required
解決:
首先:rm -vf /usr/bin/bz*
1、tar zxf bzip2-1.0.6.tar.gz
2、make -f  Makefile-libbz2_so #-f 標誌是使bzip2 根據另一個Makefile來編譯,就是Makefile-libbz2_so文件,創建一個動態的libbz.so庫文件,然後把bzip2工具連接到這個庫上
3、make clean
4、 make
5、make install PREFIX=/opt/bzip2-1.0.6
6、./configure --prefix=/opt/R-3.3.1   --enable-R-shlib LDFLAGS="-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib -L/opt/xz-5.2.2/lib " CPPFLAGS="-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include -I/opt/xz-5.2.2/include "

3、報錯
checking whether bzip2 support suffices... no
checking for lzma_version_number in -llzma... no
configure: error: "liblzma library and headers are required"
解決:wget http://tukaani.org/xz/xz-5.2.2.tar.gz --no-check-certificat
rm -vf /usr/bin/xz*
tar xzvf xz-5.2.2.tar.gz
cd xz-5.2.2
./configure --prefix=/opt/xz-5.2.2
make -j3 && make install
./configure --prefix=/opt/R-3.3.1   --enable-R-shlib LDFLAGS="-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib -L/opt/xz-5.2.2/lib " CPPFLAGS="-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include -I/opt/xz-5.2.2/include "

4、報錯 if PCRE version >= 8.10, < 10.0 and has UTF-8 support... no
解決:

tar xzvf pcre-8.39.tar.gz
 ./configure --prefix=/opt/pcre-8.39
 make -j3 && make install
./configure --prefix=/opt/R-3.3.1   --enable-R-shlib LDFLAGS="-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib -L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib " CPPFLAGS="-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include -I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include "
仍然報錯
checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support... no
checking whether PCRE support suffices... configure: error: pcre >= 8.10 library and headers are required
CRE需要安裝--enable-utf8
重新安裝pcre

rm -rf /opt/pcre-8.39


cd /pcre-8.39  

./configure  --prefix=/opt/pcre-8.39  --enable-utf8


make -j3 && make install
./configure --prefix=/opt/R-3.3.1   --enable-R-shlib LDFLAGS="-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib -L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib " CPPFLAGS="-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include -I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include "
5、報錯 checking if libcurl is version 7 and >= 7.28.0... no
configure: error: libcurl >= 7.28.0 library and headers are required with support for https

tar xzvf curl-7.47.1.tar.gz
 cd curl-7.47.1
 ./configure --prefix=/opt/curl-7.47.1
make -j3 && make install

./configure --prefix=/opt/R-3.3.1   --enable-R-shlib LDFLAGS="-L/opt/zlib-1.2.8/lib -L/opt/bzip2-1.0.6/lib -L/opt/xz-5.2.2/lib -L/opt/pcre-8.39/lib -L/opt/curl-7.47.1/lib " CPPFLAGS="-I/opt/zlib-1.2.8/include -I/opt/bzip2-1.0.6/include -I/opt/xz-5.2.2/include -I/opt/pcre-8.39/include -I/opt/curl-7.47.1/include "
成功然後進入R的安裝目錄下執行:
make && make install
6、報錯
/usr/bin/ld: warning: libpcre.so.1, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: liblzma.so.5, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)
此處報錯是由於沒有找到動態庫,看第一二行
解決方法:添加動態庫
vi /etc/ld.so.conf 添加pcre和xz
include ld.so.conf.d/*.conf
/opt/pcre-8.39/lib
/opt/xz-5.2.2/lib
然後執行
#ldconfig
進入R的安裝目錄下執行:
make && make install
7、報錯
version.o g_alab_her.o g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o   `ls ../unix/*.o ../appl/*.o ../nmath/*.o` ../extra/tre/libtre.a    -L../../lib -lRblas -lgfortran -lm   -lreadline  -lpcre -llzma -lbz2 -lz -lrt -ldl -lm 
/usr/bin/ld: /opt/bzip2-1.0.6/lib/libbz2.a(bzlib.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/bzip2-1.0.6/lib/libbz2.a: could not read symbols: Bad value
collect2: ld 返回 1
make[3]: *** [libR.so] 錯誤 1
make[3]: Leaving directory `/usr/local/program/R-3.3.1/src/main'
make[2]: *** [R] 錯誤 2
make[2]: Leaving directory `/usr/local/program/R-3.3.1/src/main'
make[1]: *** [R] 錯誤 1
make[1]: Leaving directory `/usr/local/program/R-3.3.1/src'
make: *** [R] 錯誤 1
解決方法:
vi /usr/local/program/bzip2-1.0.6/Makefile 的CFLAGS 行修改爲
CFLAGS=-Wall -fPIC -Winline -O2 -g $(BIGFILES)
3、make clean
4、 make
5、make install PREFIX=/opt/bzip2-1.0.6

進入R的安裝目錄下執行:
make && make install

成功
進入spark所在的目錄下執行 ./bin/sparkR即可
vim /etc/profile      ##添加R源環境變量
export PATH=$PATH:$JAVA_HOME/bin:/usr/local/program/R-3.3.1/bin
 source /etc/profile   ##讓環境變量立馬生效
參考:
http://pj.freefaculty.org/blog/?p=315


8、報錯 env: R: 沒有那個文件或目錄
是因爲執行sparkR的時候會到/usr/bin下面找執行文件,找到執行文件創建個軟鏈接即可
ln -s /usr/local/program/R-3.3.1/bin/R /usr/bin/R

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章