Where does Hive store files in HDFS?

2019-01-16 03:26发布

I'd like to know how to find the mapping between Hive tables and the actual HDFS files (or rather, directories) that they represent. I need to access the table files directly.

Where does Hive store its files in HDFS?

标签: hadoop hive hdfs
10条回答
倾城 Initia
2楼-- · 2019-01-16 04:13

In Hive, tables are actually stored in a few places. Specifically, if you use partitions (which you should, if your tables are very large or growing) then each partition can have its own storage.

To show the default location where table data or partitions will be created if you create them through default HIVE commands: (insert overwrite ... partition ... and such):

describe formatted dbname.tablename

To show the actual location of a particular partition within a HIVE table, instead do this:

describe formatted dbname.tablename partition (name=value)

If you look in your filesystem where a table "should" live, and you find no files there, it's very likely that the table is created (usually incrementally) by creating a new partition and pointing that partition at some other location. This is a great way of building tables from things like daily imports from third parties and such, which avoids having to copy the files around or storing them more than once in different places.

查看更多
家丑人穷心不美
3楼-- · 2019-01-16 04:14

It's also very possible that typing show create table <table_name> in the hive cli will give you the exact location of your hive table.

查看更多
够拽才男人
4楼-- · 2019-01-16 04:22

Summarize few points posted earlier, in hive-site.xml, property hive.metastore.warehouse.dir specifies where the files located under hadoop HDFS

<property>
   <name>hive.metastore.warehouse.dir</name>
   <value>/user/hive/warehouse</value>
</property>

To view files, use this command:

hadoop fs -ls /user/hive/warehouse

or

http://localhost:50070
Utilities > Browse the file system
or
http://localhost:50070/explorer.html#/

tested under hadoop-2.7.3, hive-2.1.1

查看更多
Fickle 薄情
5楼-- · 2019-01-16 04:29

In sandbox , you need to go for /apps/hive/warehouse/ and normal cluster /user/hive/warehouse

查看更多
登录 后发表回答