1. 程式人生 > >hive歸檔分區

hive歸檔分區

origin eight mov none hdfs ash lib edi 3.6

歸檔hive歷史分區不會減少hdfs存儲空間,但是可以有效減輕hadoop namenode的壓力,尤其在於小文件比較多的情況下。

$mkdir $HIVE_HOME/auxlib

$ cp /opt/cdh-5.3.6/hadoop-2.5.0/share/hadoop/tools/lib/hadoop-archives-2.5.0-cdh5.3.6.jar /opt/cdh-5.3.6/hive-0.13.1/auxlib/hadoop-archives-2.5.0-cdh5.3.6.jar

hive (chavin)> set hive.archive.enabled=true;

hive (chavin)> alter table emp archive partition(country=‘china‘,state=‘beijing‘);
intermediate.archived is hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing_INTERMEDIATE_ARCHIVED
intermediate.original is hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing_INTERMEDIATE_ORIGINAL
Creating data.har for hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing
in hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing/.hive-staging_hive_2017-05-24_13-23-51_914_3548751700804069937-1/-ext-10000/partlevel
Please wait... (this may take a while)
Moving hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing/.hive-staging_hive_2017-05-24_13-23-51_914_3548751700804069937-1/-ext-10000/partlevel to hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing_INTERMEDIATE_ARCHIVED
Moving hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing to hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing_INTERMEDIATE_ORIGINAL
Moving hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing_INTERMEDIATE_ARCHIVED to hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing
Moved: ‘hdfs://db01:8020/user/hive/warehouse/chavin.db/emp/country=china/state=beijing_INTERMEDIATE_ORIGINAL‘ to trash at: hdfs://db01:8020/user/hadoop/.Trash/Current
OK
Time taken: 2.17 seconds

可以看到,emp表下分區文件已經被打包成data.har文件了。

技術分享

hive歸檔分區