Thursday 6 April 2017

Hive Installation and Configuration

Step 1

Download the hive package 

wget http://www-us.apache.org/dist/hive/hive-2.1.1/apache-hive-2.1.1-bin.tar.gz

untar it in preferred location with below command

cd /opt/

tar -xvzf apache-hive-2.1.1-bin.tar.gz

mv apache-hive-2.1.1-bin hive

Step 2

add hive and java home in .bashrc or .bash_profile EOF as


export JAVA_HOME=/usr/java/jdk1.8.0_92
export HIVE_HOME=/opt/hive
export PATH=$HIVE_HOME:/bin:/usr/java/jdk1.8.0_92/bin

Step 3

goto hive conf directory in hive home

cd /opt/hive/conf

rename or copy hive-env.sh.template to hive-env.sh

cp hive-env.sh.template hive.env.sh

and add execute permission

chmod +x hive-env.sh

now remove # from export HADOOP_HOME=  export HIVE_CONF_DIR= and add the location.


HADOOP_HOME=/opt/hive

HIVE_CONF_DIR=/opt/hive/conf

now create hive-site.xml. Already it's available in that directory but I have simple configuration just add that.


<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=/opt/hive/metastore_db;create=true</value>
<description>JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.</description>
</property>
<property>
<name>hive.metastore.visualize.dir</name>
<value>/hive/visualize</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value />
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.PersistenceManagerFactoryClass</name>
<value>org.datanucleus.api.jdo.JDOPersistenceManagerFactory</value>
<description>class implementing the jdo persistence</description>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>true</value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in is compatible with one from Hive jars.  Also disable automatic
schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description>
</property>
<property>
<name>hive.metastore.schema.verification.record.version</name>
<value>true</value>
<description>
When true the current MS version is recorded in the VERSION table. If this is disabled and verification is
enabled the MS will be unusable.
</description>
</property>

</configuration>

save & exit

Step 4

download and configure apache-derby in same machine.

wget http://mirror.fibergrid.in/apache//db/derby/db-derby-10.13.1.1/db-derby-10.13.1.1-bin.tar.gz

and extract it with below command

tar -xzf db-derby-10.13.1.1-bin.tar.gz

mv db-derby-10.13.1.1-bin derby

add the derby home and path to .bash_profile.

export JAVA_HOME=/usr/java/jdk1.8.0_92
export HIVE_HOME=/opt/hive
export DERBY_HOME=/opt/derby
export PATH=$HIVE_HOME:/bin:/usr/java/jdk1.8.0_92/bin:/opt/derby/bin

now goto the lib directory of derby and add execute permission for all jar files

cd /opt/derby/lib

chmod a+x *

now copy the derby.jar file to lib directory of hive

cp derby.jar /opt/hive/lib


Step 5

Now goto bin directory in hive home

and run the schematool like below

./schematool -dbType derby -initSchema

it will give result like below 











Now run hive command and it will show like below then it success.





Congratulations you have completed successfully. 

Permanent hostname setup for RHEL7

Step 1 Set the host name on NMTUI tool like following nmtui set host name   then save and exit Step 2 add the following l...