Monday, 27 January 2014

      INSTALL 'R','RHADOOP' AND 'RHBASE'

    1. Epel-release

  • You need to install epel-release which is a prerequisite for installing 'R'.
-->wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
-->rpm -ivh epel-release-6-8.noarch.rpm
  • Now you can install 'R' using yum installation method.
-->yum install R R-devel
  • Install and set the JAVA_HOME in .bashrc file.
  • Configure java in 'R' using the following command.
-->R CMD javareconf
NOTE: This is a 'R' command which we can use in command prompt itself.
  • Check whether 'R' is working fine using R command.
-->R (R shell will be opened)
  • Install  the packages in the 'R' shell.
>install.packages(c('Rcpp', 'RJSONIO', 'itertools', 'digest'), repos="http://cran.revolutionanalytics.com", INSTALL_opts=c('--byte-compile') )
> install.packages(c('functional', 'stringr', 'plyr'), repos="http://cran.revolutionanalytics.com", INSTALL_opts=c('--byte-compile') )
>install.packages(c('rJava'), repos="http://cran.revolutionanalytics.com" )
>install.packages(c('randomForest'), repos="http://cran.revolutionanalytics.com" )
>install.packages(c('reshape2'), repos="http://cran.revolutionanalytics.com" )
>install.packages(c('bitops'), repos="http://cran.revolutionanalytics.com" )
> install.packages(c('caTools'), repos="http://cran.revolutionanalytics.com" )
  • Set the following environment variables in .bashrc and /etc/profile
export HADOOP_HOME=/usr/lib/hadoop

export HADOOP_CMD=/usr/bin/hadoop

export HADOOP_STREAMING=/usr/lib/hadoop-mapreduce/hadoop-streaming-2.2.0.2.0.6.0-76.jar
NOTE: Set the jar file asper you hadoop version.
  • Make sure to source the new variables before continuing.
  • Export the paths in the terminal (execute the following commands)
    -->source /etc/profile
    -->ource ~/.bashrc
     

Download RHadoop and Install



  • We can download the Rhadoop from GITHUB site so we need to install git.
-->yum install git

Installing RMR2 package



-->git clone git://github.com/RevolutionAnalytics/rmr2.git

-->R CMD INSTALL –byte-compile rmr2/pkg
 
 
 
 

Installing rhdfs Package

-->git clone git://github.com/RevolutionAnalytics/rhdfs.git
-->R CMD INSTALL –byte –compile /rhdfs/pkg

  • Check with the permissions 
-->su hdfs
-->hadoop fs -chmod -R 777 /user
  • Open the ‘R’ terminal to check that it is working 
  • Give the commands to check whether the ‘R’ is working with hadoop 

-->R
>system("pwd")
>library(rmr2)
  • This command should output you the following lib 
 This command should show the libraries exists in it.
Loading required package: Rcpp
Loading required package: RJSONIO
Loading required package: bitops
Loading required package: digest
Loading required package: functional
Loading required package: stringr
Loading required package: plyr
Loading required package: reshape2

>library(rJava)

  • Export the Hadoop path in the 'R' terminal.
>Sys.setenv(HADOOP_HOME=”/usr/lib/hadoop”)
>Sys.setenv(HADOOP_CMD=”/usr/bin/hadoop”)
>Sys.setenv(HADOOP_STREAMING=”/usr/lib/hadoop-mapreduce/hadoop-streaming-2.2.0.2.0.6.0-76.jar”)
>library(rhdfs)
  •  Should show you the Hadoop path
>hdfs.init()
  • Starts the Hadoop
  • Run a sample job (follow the steps)
>ints=to.dfs(1:100)
  • Which writes 1-100 into hdfs
>calc = mapreduce(input = ints, map = function(k, v) cbind(v, 2*v))
  • Which is a mapreduce program to output the double values
>from.dfs(calc)
  • Which shows you the output

Install RStudio

  • Download the rpm
    -->wget http://download2.rstudio.org/rstudio-server-0.98.490-x86_64.rpm
     
  • Install the rpm 
      -->yum install --nogpgcheck rstudio-server-0.98.490-x86_64.rpm
      -->service rstudio-server status
  • By default RStudio Server runs on port 8787 and accepts connections from all remote clients. After installation you should therefore be able to navigate a web browser to the following address to access the server:
  • http://<server-ip>:8787 
NOTE:RStudio Server will not permit logins by system users (those with user ids lower than 100).


For more details visit http://www.rstudio.com/ide/docs/server/getting_started 

NOTES:
  1. Check with the JAVA_HOME path is set.
  2. You need to export the HADOOP Paths in 'R' shell all the time you are working on it.