Hive는 HDFS에서 파일을 어디에 저장합니까?
Hive 테이블과 해당 테이블이 나타내는 실제 HDFS 파일 (또는 디렉터리) 간의 매핑을 찾는 방법을 알고 싶습니다. 테이블 파일에 직접 액세스해야합니다.
Hive는 HDFS에서 파일을 어디에 저장합니까?
HDFS에 저장되는 위치는 어디를 봐야하는지 알면 쉽게 알아낼 수 있습니다. :)
http://NAMENODE_MACHINE_NAME:50070/
브라우저에서 로 이동 하면 Browse the filesystem
링크 가있는 페이지로 이동해야 합니다.
에서 $HIVE_HOME/conf
디렉토리 거기입니다 hive-default.xml
및 / 또는 hive-site.xml
가지고있는 hive.metastore.warehouse.dir
속성을. 해당 값은 Browse the filesystem
링크를 클릭 한 후 탐색하려는 위치 입니다.
내에서는 /usr/hive/warehouse
. 해당 위치로 이동하면 테이블 이름이 표시됩니다. 테이블 이름 (단지 폴더)을 클릭하면 테이블의 파티션이 표시됩니다. 제 경우에는 현재 date
. 이 수준의 폴더를 클릭하면 파일이 표시됩니다 (파티션이 많을수록 수준이 더 높음). 이러한 파일은 데이터가 실제로 HDFS에 저장되는 곳입니다.
나는이 파일들에 직접 접근하려고 시도하지 않았으며 그것이 가능하다고 가정하고있다. 편집에 대해 생각하고 있다면 매우주의를 기울일 것입니다. :) 나를 위해-디스크의 Hive 데이터에 직접 액세스하지 않고 필요한 작업을 수행하는 방법을 알아 냈습니다. 원시 데이터에 액세스해야하는 경우 Hive 쿼리를 사용하고 결과를 파일로 출력 할 수 있습니다. .NET Framework의 파일과 동일한 구조 (열 간 분할 등)를 갖습니다 HDFS
. 나는 항상 이와 같은 쿼리를 수행하고 CSV로 변환합니다.
쿼리에서 디스크로 데이터를 쓰는 방법에 대한 섹션은 https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Writingdataintothefilesystemfromqueries입니다.
최신 정보
Hadoop 3.0.0-Alpha 1 이후 기본 포트 번호가 변경되었습니다. NAMENODE_MACHINE_NAME : 50070이 NAMENODE_MACHINE_NAME : 9870으로 변경됩니다. Hadoop 3.x에서 실행중인 경우 후자를 사용하십시오. 포트 변경의 전체 목록은 HDFS-9427에 설명되어 있습니다.
Hive 테이블은 반드시웨어 하우스에 저장되지 않을 수 있습니다 (HDFS의 아무 곳에 나 테이블을 만들 수 있기 때문에).
DESCRIBE FORMATTED <table_name>
명령을 사용해야합니다 .
hive -S -e "describe formatted <table_name> ;" | grep 'Location' | awk '{ print $NF }'
파티션은 다른 위치에 저장 될 수 있으며 이후 alpha=foo/beta=bar
에 추가해야하는 파티션 의 위치를 가져올 수 있습니다 .partition(alpha='foo',beta='bar')
<table_name>
Hive 터미널 유형 :
hive> set hive.metastore.warehouse.dir;
(경로를 인쇄합니다)
show create table <table_name>
하이브 클리에 입력 하면 하이브 테이블의 정확한 위치를 알 수 있습니다.
describe formatted <table_name>;
하이브 쉘 내부.
테이블의 위치를 나타내는 "위치"값을 확인하십시오.
이전에 게시 된 몇 가지 사항을 hive-site.xml에 요약합니다. 속성 hive.metastore.warehouse.dir은 파일이 hadoop HDFS 아래에있는 위치를 지정합니다.
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
파일을 보려면 다음 명령을 사용하십시오.
hadoop fs -ls /user/hive/warehouse
또는
http://localhost:50070
Utilities > Browse the file system
or
http://localhost:50070/explorer.html#/
hadoop-2.7.3, hive-2.1.1에서 테스트되었습니다.
hive-site.xml 파일을 보면 다음과 같은 것을 볼 수 있습니다.
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/usr/hive/warehouse </value>
<description>location of the warehouse directory</description>
</property>
/ usr / hive / warehouse는 모든 관리 테이블의 기본 위치입니다. 외부 테이블은 다른 위치에 저장 될 수 있습니다.
describe formatted <table_name>
하이브 테이블과 관련된 데이터의 위치를 찾는 데 더 일반적으로 사용할 수있는 하이브 셸 명령입니다.
Hive에서 테이블은 실제로 몇 군데에 저장됩니다. 특히 파티션을 사용하는 경우 (테이블이 매우 크거나 증가하는 경우) 각 파티션에 자체 스토리지가있을 수 있습니다.
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.
Another way to check where a specific table is stored would be execute this query on the hive interactive interface:
show create table table_name;
where table_name is the name of the subject table.
An example for the above query on 'customers' table would be something like this:
CREATE TABLE `customers`(
`id` string,
`name` string)
COMMENT 'Imported by sqoop on 2016/03/01 13:01:49'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://quickstart.cloudera:8020/user/hive/warehouse/
sqoop_workspace.db/customers'
TBLPROPERTIES (
'COLUMN_STATS_ACCURATE'='true',
'numFiles'='4',
'totalSize'='77',
'transient_lastDdlTime'='1456866115')
LOCATION in the example above is where you should focus on. That is your hdfs location for hive warehouse.
Don't forget to like if you like this solution. Cheers!
In sandbox , you need to go for /apps/hive/warehouse/ and normal cluster /user/hive/warehouse
Hive database is nothing but directories within HDFS with .db extensions.
So, from a Unix or Linux host which is connected to HDFS, search by following based on type of HDFS distribution:
hdfs dfs -ls -R / 2>/dev/null|grep db
or hadoop fs -ls -R / 2>/dev/null|grep db
You will see full path of .db database directories. All tables will be residing under respective .db database directories.
참고URL : https://stackoverflow.com/questions/5058400/where-does-hive-store-files-in-hdfs
'program story' 카테고리의 다른 글
Android NDK 코드에 로그인하는 간단한 방법이 있습니까? (0) | 2020.11.17 |
---|---|
\ u003C는 무엇을 의미합니까? (0) | 2020.11.17 |
Android ViewPager는 현재보기를 가져옵니다. (0) | 2020.11.17 |
C에서 sizeof 연산자는 2.5m를 통과하면 8 바이트를 반환하지만 1.25m * 2를 통과하면 4 바이트를 반환합니다. (0) | 2020.11.17 |
교리-관계를 통해 새로운 실체가 발견되었습니다. (0) | 2020.11.17 |