Hive存储格式textfile转orcfile,并导出数据到另一hive集群

1. 在源hive数据库,创建一张orcfile格式的临时表

CREATE TABLE `user_tmp`(
`id` bigint,
`created` string,
`modified` string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS orcfile;


2. 在目标hive数据库,创建一张orcfile格式的正式表

CREATE TABLE `user`(
`id` bigint,
`created` string,
`modified` string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS orcfile;


3. 在源hive数据库,转换数据格式;

insert into table db.use_tmp select * from db.user;

4. Hadoop 推数据


hadoop distcp -skipcrccheck -update hdfs://fromip:8020/user/hive/warehouse/db.db/user_tmp hdfs://toip:8020/user/hive/warehouse/db.db/user

distcp参数:http://hadoop.apache.org/docs/current/hadoop-distcp/DistCp.html

5. 完成

你可能感兴趣的:(hive,Hadoop)