Dear Sathya,

Hope you are doing good.

Before we work with HCatalog we need to few setting in Edureka VM. Please follow the steps given below that would guide you in doing that.

  • Edit the .bashrc
Command: sudo gedit ~/.bashrc

Add the below lines and save the file.

export HIVE_HOME=/usr/lib/hive-0.13.1-bin
export HCAT_HOME=/usr/lib/hive-0.13.1-bin/hcatalog
 
export PIG_HOME=/usr/lib/pig-0.12.0
export PATH=$PATH:$HCAT_HOME/bin
export PATH=$PATH:$PIG_HOME/bin
export PIG_CLASSPATH=$HCAT_HOME/share/hcatalog/hive-hcatalog-core-0.13.1.jar:\
$HCAT_HOME/share/hcatalog/hive-hcatalog-pig-adapter-0.13.1.jar:\
$HIVE_HOME/lib/hive-metastore-0.13.1.jar:$HIVE_HOME/lib/libthrift-0.9.0.jar:\
$HIVE_HOME/lib/hive-exec-0.13.1.jar:$HIVE_HOME/lib/libfb303-0.9.0.jar:\
$HIVE_HOME/lib/jdo-api-3.0.1.jar:$HIVE_HOME/conf:$HADOOP_HOME/conf

  • Edit hive-site.xml
Command: sudo gedit /usr/lib/hive-0.13.1-bin/conf/hive-site.xml

It would create a new file. edit as follows.
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
 
<configuration>
 
<property>
  <name>hive.metastore.uris</name>
  <value>thrift://localhost:9083</value>
</property>
   <property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
  <description>JDBC connect string for a JDBC 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>
 
</configuration>

  • Restart the Edureka VM
  • Make sure that both the adapters - Auto eth1 and System eth0 are enabled. If not enable them.
  • Check if all the Hadoop daemons are running fine. If not, please start them by running below commands.
Command: sudo service hadoop-master stop
Command: sudo service hadoop-master stop
Command: hadoop dfsadmin -safemode leave
  • Starting the Hive metastore
Command: hive --service metastore &
  • Testing it if it is working fine
Command: netstat -an | grep 9083

You should receive the message similar to the one in the below screenshot.

  • Creating a table using HCat
Command: hcat -e "create table hcatalogtest(name string,place string,id int) row format delimited fields terminated by ':' stored as textfile"

Command: hcat -e "desc hcatalogtest"

  • Creating a Pig Script 
Command: gedit hcatalogtest.pig

add the below commands in it.

A = LOAD 'hcatalogtest' USING org.apache.hive.hcatalog.pig.HCatLoader();
DESCRIBE A;

  • Save the file and execute it using below command.
Command: pig -useHCatalog hcatalogtest.pig
  • Once the pig script is executed successfully you should receive the message as in the below screenshot i.e it should print the output of describe command.


Please try it and let me know if this works for you.

I will wait for your response.

Please note if you are not happy with the response on this ticket, please escalate it to escalations@edureka.in.
We assure you that we will get back to you within 24 hours