转载网址:
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