Cloudera/Hive - Can't access tables after hostname change

1.7k views Asked by At

I created a Cloudera cluster and imported some sample test files from oracle DB. But after a while I had to change the hostnames of the nodes. I followed the guide mentioned in cloudera site and everything worked fine. But when I try to access tables(using both hive and impala) I created earlier I get the following error: Fetching results ran into the following error(s):

java.io.IOException: java.lang.IllegalArgumentException: java.net.UnknownHostException: [Old Host Name]

Then I created another table under the same DB (Using Hue>Metastore Tables) and I can access these new tables created under the new hostname with no issue.

Can someone explain how I can access my old tables without reverting back my hostnames. Can I access metastore db and change the table pointers to new hostname.

2

There are 2 answers

0
Tingyang On BEST ANSWER

Try this

hive --service metatool -updateLocation <newfsDefaultFSValue> <old_fsDefaultFSValue>

You can refer to https://www-01.ibm.com/support/knowledgecenter/SSPT3X_3.0.0/com.ibm.swg.im.infosphere.biginsights.trb.doc/doc/trb_inst_hive_hostnames.html

0
alda On

Never Mind I found the answer.

You can confirm that hive/impala is looking for the wrong location by executing

describe formatted [tablename];    

O/P

14  Location:               hdfs://[oldhostname]:8020/user/hive/warehouse/sample_07 NULL    

Then you can change "Location" property using :

ALTER TABLE sample_07 SET LOCATION "hdfs://[newhostname]:8020/user/hive/warehouse/sample_07";    

ps - sample_07 is my the table in concern

Some times this doesn't WORK !!

Above workaround works for sample table which is available by default but I had another table which I sqooped from external DB to a custome metastore DB, this gave me again an error similar to above.

Solution :

Go to host where you've installed hive. Temporally add the old hostname of the hive server to /etc/hosts (if you don't have external DNS both new and old hostnames should exist in the same host file)

Execute the 'ALTER TABLE ....' at hive shell (or web interface)

Remove the oldhostname entry from /etc/hosts