Wednesday 23 December 2015

Hive 1.2.1 Installation with Mysql

Hive 1.2.1 Installation with Mysql


Download a binary pack from http://apache.claz.org/hive/stable/

user@host:~$  cd /opt/
user@host:~$  sudo mkdir hive
user@host:~$  cd Downloads
user@host:~$  sudo mv <HIVE-BIN-FILE> /opt/hive
user@host:~$  cd /opt/hive 
user@host:~$  cp conf/hive-default.xml.template conf/hive-site.xml
 
Edit the hive-site.xml with the below settings
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localhost/metastore?createDatabaseIfNotExist=true</value>
  <description>the URL of the MySQL database</description>
</property>

<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>root</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>root</value>
</property>
<property>
  <name>hive.hwi.listen.host</name>
  <value>0.0.0.0</value>
</property>
<property>
  <name>hive.hwi.listen.port</name>
  <value>9999</value>
</property>
<property>
  <name>hive.hwi.war.file</name>
  <value>lib/hive-hwi-0.12.0.war</value>
</property>

<property>
  <name>hive.support.concurrency</name>
  <value>true</value>
</property>

<property>
  <name>hive.enforce.bucketing</name>
  <value>true</value>
</property>

<property>
  <name>hive.exec.dynamic.partition.mode</name>
  <value>nonstrict</value>
</property>

<property>
  <name>hive.compactor.initiator.on</name>
  <value>true</value>
</property>

<property>
  <name>hive.compactor.worker.threads</name>
  <value>1</value>
</property>
 

Mysql Connector

Download a Mysql connector jar file
Put that in /opt/hive/lib folder with name mysql-connector.jar
 
~/opt/hive/> bin/hive
 
Happy Hiving... 
 
 

Some Errors and fixes

 
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
 at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
 at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
 at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
 at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:612)
 at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
 at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
 
For this issue, Give the write permission for /tmp/hive
 in hadoop with the below command
 
bin/hadoop dfs -chmod 777 /tmp/hive
 
Then hit hive.