title: Avoiding mapred.child.env modification at runtime on HDP so that R can establish connection to hiveserver2 using RHive
body: <p>I'm trying to get R's RHive package to communicate nicely with hiveserver2. </p>
  
  <p>I receive an error while trying to connect into hiveserver2 using:</p>
  
  <pre><code>&gt;rhive.connect(host="localhost",port=10000, hiveServer2=TRUE, user="root", password="hadoop")
  </code></pre>
  
  <p>The output on the initial run:</p>
  
  <pre><code>SLF4J: Class path contains multiple SLF4J bindings.
  SLF4J: Found binding in [jar:file:/usr/hdp/2.2.0.0-2041/hadoop/client/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/hdp/2.2.0.0-2041/hadoop/client/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/hdp/2.2.0.0-2041/hadoop/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/hdp/2.2.0.0-2041/hive/lib/hive-jdbc-0.14.0.2.2.0.0-2041-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: Found binding in [jar:file:/usr/hdp/2.2.0.0-2041/hive/lib/hive-jdbc.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
  15/03/19 07:08:22 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  15/03/19 07:08:23 WARN shortcircuit.DomainSocketFactory: The short-circuit local reads feature cannot be used because libhadoop cannot be loaded.
  15/03/19 07:08:24 INFO jdbc.Utils: Supplied authorities: localhost:10000
  15/03/19 07:08:24 INFO jdbc.Utils: Resolved authority: localhost:10000
  15/03/19 07:08:24 INFO jdbc.HiveConnection: Will try to open client transport with JDBC Uri: jdbc:hive2://localhost:10000/default
  </code></pre>
  
  <p>This leads to the error:</p>
  
  <p><strong>Error: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: Cannot modify mapred.child.env at runtime. It is not in list of params that are allowed to be modified at runtime</strong></p>
  
  <p>On subsequent runs of the same command the output reduces to:</p>
  
  <pre><code>15/03/19 07:16:24 INFO jdbc.Utils: Supplied authorities: localhost:10000
  15/03/19 07:16:24 INFO jdbc.Utils: Resolved authority: localhost:10000
  15/03/19 07:16:24 INFO jdbc.HiveConnection: Will try to open client transport with JDBC Uri: jdbc:hive2://localhost:10000/default
  Error: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: Cannot modify mapred.child.env at runtime. It is not in list of params that are allowed to be modified at runtime
  </code></pre>
  
  <p>This indicates to me that I may have insufficient permissions somewhere... However, I'm running this using root. So, I'm unsure of what permissions I'm missing...</p>
  
  <p>I've installed RHive using the installation guidelines <a href="https://github.com/nexr/RHive/blob/master/README.md" rel="nofollow">via README</a>.</p>
  
  <p><strong>NOTE: The same error occurs if I use the <a href="http://cran.r-project.org/web/packages/RHive/" rel="nofollow">CRAN version of the package</a>.</strong></p>
  
  <p>I'm currently using <a href="http://hortonassets.s3.amazonaws.com/2.2/Sandbox_HDP_2.2_VirtualBox.ova" rel="nofollow">Hortonworks Data Platform 2.2 (HDP 2.2)</a>'s virtual box image. As a result, hadoop and hiveserver2 are already installed. I've installed R version 3.1.2. </p>
  
  <p>The following is how I am installing RHive:</p>
  
  <pre><code># Set up paths for HIVE_HOME, HADOOP_HOME, and HADOOP_CONF
  export HIVE_HOME=/usr/hdp/2.2.0.0-2041/hive
  
  export HADOOP_HOME=/usr/hdp/2.2.0.0-2041/hadoop
  
  export HADOOP_CONF_DIR=/etc/hadoop/conf
  
  # R Location via RHOME
  R_HOME=/usr/lib64/R
  
  # Place R_HOME into hadoop config location
  sudo sh -c "echo \"R_HOME='$R_HOME'\" &gt;&gt; $HADOOP_HOME/conf/hadoop-env.sh"
  
  # Add remote enable to Rserve config.
  sudo sh -c "echo 'remote enable' &gt;&gt; /etc/Rserv.conf"
  
  # Launch the daemon
  R CMD Rserve
  
  # Confirm launch
  netstat -nltp
  
  # Install ant to build java files
  sudo yum -y install ant
  
  # Install package dependencies
  sudo R --no-save &lt;&lt; EOF
  install.packages( c('rJava','Rserve','RUnit'), repos='http://cran.us.r-project.org', INSTALL_opts=c('--byte-compile') )
  EOF
  
  # Install RHive package
  git clone https://github.com/nexr/RHive.git
  cd RHive
  ant build
  sudo R CMD INSTALL RHive
  </code></pre>
  
  <p>To check either open R and use the statements between EOF or just run the command directly from shell:</p>
  
  <pre><code>sudo R --no-save &lt;&lt; EOF
  Sys.setenv(HIVE_HOME="/usr/hdp/2.2.0.0-2041/hive")
  Sys.setenv(HADOOP_HOME="/usr/hdp/2.2.0.0-2041/hadoop")
  Sys.setenv(HADOOP_CONF_DIR="/etc/hadoop/conf")
  library(RHive)
  rhive.connect(host="localhost",port=10000, hiveServer2=TRUE, user="root", password="hadoop")
  EOF
  </code></pre>