使用MSCK命令修复Hive表分区

转载网址:
http://blog.csdn.net/opensure/article/details/51323220
http://www.cnblogs.com/chinhr/archive/2007/10/17/927506.html
http://blog.csdn.net/sparkexpert/article/details/51024392?locationNum=5&fps=1
http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html
我自己的操作实战:
1、先创建一张表。

hive> create table t427(id int,city string,name string,sex string) 
    > partitioned by (day int)
    > row format delimited                                         
    > fields terminated by '\t';
OK

2、查看表结构

hive> desc formatted t427;
OK
# col_name              data_type               comment             

id                      int                     None                
city                    string                  None                
name                    string                  None                
sex                     string                  None                

# Partition Information          
# col_name              data_type               comment             

day                     int                     None                

# Detailed Table Information             
Database:               fdm                      
Owner:                  root                     
CreateTime:             Mon May 01 07:22:11 PDT 2017     
LastAccessTime:         UNKNOWN                  
Protect Mode:           None                     
Retention:              0                        
Location:               hdfs://hadoop:9000/warehouse/fdm.db/t427         
Table Type:             MANAGED_TABLE            
Table Parameters:                
        transient_lastDdlTime   1493648531          

# Storage Information            
SerDe Library:          org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe       
InputFormat:            org.apache.hadoop.mapred.TextInputFormat         
OutputFormat:           org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat       
Compressed:             No                       
Num Buckets:            -1                       
Bucket Columns:         []                       
Sort Columns:           []                       
Storage Desc Params:             
        field.delim             \t                  
        serialization.format    \t                  
Time taken: 0.046 seconds

3、增加两个分区

hive> dfs -mkdir hdfs://hadoop:9000/warehouse/fdm.db/t427/day=25;
hive> dfs -mkdir hdfs://hadoop:9000/warehouse/fdm.db/t427/day=26;

4、查看分区(呵呵,此时没有)

hive> show partitions t427;
OK
Time taken: 0.101 seconds

5、使用msck命令修复分区结构

hive> msck repair table t427;
OK
Partitions not in metastore:    t427:day=25     t427:day=26
Repair: Added partition to metastore t427:day=25
Repair: Added partition to metastore t427:day=26
Time taken: 0.18 seconds

6、再次查看分区信息,此时成功。

hive> show partitions t427;  
OK
day=25
day=26
Time taken: 0.049 seconds
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值