Skip to main content

Hive Installation on Ubuntu

Hive Installation on Ubuntu:

Please follow the below steps to install Apache Hive on Ubuntu:
Step 1:  Download Hive tar.
Command: wget http://archive.apache.org/dist/hive/hive-2.1.0/apache-hive-2.1.0-bin.tar.gz
Step 2:  Extract the tar file.
Command: tar -xzf apache-hive-2.1.0-bin.tar.gz
Command: ls

Step 3: Edit the “.bashrc” file to update the environment variables for user.

Command:  sudo gedit .bashrc
Add the following at the end of the file:
# Set HIVE_HOME
export HIVE_HOME=/home/hduser/apache-hive-2.1.0-bin
export PATH=$PATH:/home/hduser/apache-hive-2.1.0-bin/bin
Also, make sure that hadoop path is also set.
Run below command to make the changes work in same terminal.
Command: source .bashrc
Step 4: Check hive version.
Command: hive --version
Step 5:  Create Hive directories within HDFS. The directory ‘warehouse’ is the location to store the table or data related to hive.
Command:
  • hdfs dfs -mkdir -p /user/hive/warehouse
  • hdfs dfs -mkdir /tmp
Step 6: Set read/write permissions for table.
Command:
In this command, we are giving write permission to the group:
  • hdfs dfs -chmod g+w /user/hive/warehouse
  • hdfs dfs -chmod g+w /tmp
Step 7:  Set Hadoop path in hive-env.sh
Command: cd apache-hive-2.1.0-bin/
Command: gedit conf/hive-env.sh
Set the parameters as shown in the below snapshot.
Step 8: Edit hive-site.xml
Command: gedit conf/hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=/home/hduser/apache-hive-2.1.0-bin/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.warehouse.dir</name>
<value>/user/hive/warehouse</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>
</configuration>
Step 9: By default, Hive uses Derby database. Initialize Derby database.
Command: bin/schematool -initSchema -dbType derby
Step 10: Launch Hive.
Command: hive
Step 11: Run few queries in Hive shell.
Command: show databases;
Command: create table employee (id string, name string, dept string) row format delimited fields terminated by ‘\t’ stored as textfile;
Command: show tables;
Step 12: To exit from Hive:
Command: exit;
Now that you are done with Hive installation

Comments

Popular posts from this blog

How to Install MongoDB on Ubuntu 16.04

How to Install MongoDB on Ubuntu 16.04                                         MongoDB is an open source database management system (DBMS)  that uses a  document-oriented database model which supports various forms of data. Step 1: Adding the MongoDB Repository       MongoDB is already included in Ubuntu package repositories, but the official MongoDB repository  provides most up-to-date version and is the recommended way of installing the software. In this step,  we will add this official repository to our server. Ubuntu ensures the authenticity of software packages by verifying that they are signed with GPG keys,  so we first have to import they key for the official MongoDB repository. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 After successfully importing the key, you will see: gpg: ...

Loopback - Create datasource and model for Cassandra

Loopback 3.0- Create datasource and model for Cassandra Pre-Installed:-                           Loopback 3.0 and cassandra  Step 1: Creating a Keyspace using Cqlsh cqlsh.> CREATE KEYSPACE test WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3}; cqlsh> DESCRIBE keyspaces; test system system_traces Step 2: Creating a table using Cqlsh cqlsh> USE test; cqlsh:test>; CREATE TABLE pullcassandra( id text PRIMARY KEY emp_id text, emp_name text, emp_city text, emp_sal text, emp_phone text, ); "id" - for store the object key which is generated by loopback  Step 3: Creating a datasouce In your application root directory, enter this command to install the connector: npm install loopback-connector-cassandra --save $ lb datasource ? Enter the data-source name: mycass ? Select the connector for mycass: Cassandra (s...

Hbase installation on ubuntu

Hbase installation on ubuntu In this tutorial we will see how to install Hbase on ubuntu 16.04 by doing the following steps Step 1: Before installing Hbase, you need to First ensure that java8 is installed: sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer Verify that java is correctly installed: java -version       Configuring Java Environment sudo apt-get install oracle-java8-set-default    Step 2: Ensure that you successfully installed hadoop on your machine  Check this link if you need to know how to install it.  Step 3: Download Apache Hbase Go to downloads page Choose hbase file: hbase-1.2.5-bin.tar.gz Step 4: Complete the installation process Move the downloaded file “ hbase-1.2.5-bin.tar.gz ” to your home (~) Compress it :  tar -zxvf hbase-1.2.5-bin.tar.gz Edit hbase-env.sh using this co...