Monday, January 20, 2014

Hive for Hadoop - FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

Hive for Hadoop

Complete Error -

hive>select count(1) from temp_table;
FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

Resolution -

The below steps should help resolve the error -

1. Under hive/bin directory goto metastore_db directory where the hive metadata is stored.

drwxr-xr-x 3 hdd1 root   4096 Jan 15 11:01 ext
drwxr-xr-x 5 hdd1 hddba  4096 Jan 16 11:44 metastore_db
-rw-r--r-- 1 hdd1 hddba 38518 Jan 16 11:44 derby.log
[hdd1@kchjovm41 bin]$ cd metastore_db

2. You should see two .lck files created

[hdd1@kchjovm41 metastore_db]$ ls -ltr
total 48
drwxr-xr-x 2 hdd1 hddba 4096 Jan 16 10:10 log
-rw-r--r-- 1 hdd1 hddba    4 Jan 16 10:10 dbex.lck
-rw-r--r-- 1 hdd1 hddba  857 Jan 16 10:10 service.properties
drwxr-xr-x 2 hdd1 hddba 4096 Jan 16 10:10 seg0
drwxr-xr-x 2 hdd1 hddba 4096 Jan 16 11:44 tmp
-rw-r--r-- 1 hdd1 hddba   38 Jan 16 11:44 db.lck

3. Rename the .lck files

[hdd1@kchjovm41 metastore_db]$ mv dbex.lck dbex.lck1
[hdd1@kchjovm41 metastore_db]$ mv db.lck db.lck1
[hdd1@kchjovm41 metastore_db]$

4. Retry the hive sql , should work fine.

Let me know if it helps - Thank you