If you get the below error when trying out any queries in hive,




If you are using Cloudera CDH3 then execute the command sudo jps and check weather all the demons are working.

If everything is working fine the you should get demons as shown in screen shot

Note : Never go for Update or Shut Down for CDH 3.

If all the daemons are running, then  follow the below steps:

1. The problem might be because the user you logged in as (cloudera or find user by typing ‘whoami’) does not have write access to the derby metastore database directory used by Hive. The Hive metastore stores the metadata for a table and provides this metadata to the Hive compiler for converting SQL commands to MapReduce jobs.

So, go to the metastore/metastore_db and verify if your user id has permissions by doing an ls -lrt. If your userid does not have permissions, you should grant write permissions to it. Below are the commands :

Step 1: search the location of metastore_db in hive-site.xml

cd /usr/lib/hive/conf

grep metastore_db hive-site.xml

2. Now go to your the directory where your metastore_db is present. (Mine is at /var/lib/hive/metastore)

cd /var/lib/hive/metastore/metastore_db

sudo chmod a+rwx . recursive

sudo \rm *.lck

Then you can enter hive shell and the queries will not give any exception.

If you have any other issue, please feel free to contact us.