Correct Hive File Locations

Contacting Cloudera Support for help to correct file location problems is highly recommended. Alternatively, you can perform correct file locations of managed files yourself.

  1. Login as the HDFS superuser and if you use Kerberos, you need to become the superuser with a valid ticket.
    $ sudo su - hdfs
  2. Start Hive in Ambari 7.1.x.x.
  3. On a node in your cluster, start Beeline in the background and a Hive shell in the foreground.
    $ hive
  4. Change the location of the database and the table from the old location to the new location.
    hive> ALTER DATABASE tpcds_bin_partitioned_orc_10 SET LOCATION 
    'hdfs://ns1/apps/hive/warehouse/tpcds_bin_partitioned_orc_10.db'; 
    hive> ALTER TABLE tpcds_bin_partitioned_orc_10.store_sales SET LOCATION 
    'hdfs://ns1/apps/hive/warehouse/tpcds_bin_partitioned_orc_10.db/store_sales';
  5. On the Hive Metastore node, log in as the HDFS superuser.
  6. Set STACK_VERSION to the HDP version you are running.
    $ export STACK_VERSION=`hdp-select status hive-server2 | awk '{ print $3; }'`
  7. Run the script for strict Hive migration.
    $ /usr/hdp/$STACK_VERSION/hive/bin/hive --config /etc/hive/conf 
    --service strictmanagedmigration 
    --hiveconf hive.strict.managed.tables=true -m automatic 
    --modifyManagedTables --oldWarehouseRoot /apps/hive/warehouse