瞌睡中的葡萄虎

博客园 首页 新随笔 联系 订阅 管理

方式一: hadoop命令导出

hadoop fs -get hdfs://hadoop000:8020/data/page_views2   pv2 

 

方式二:通过insert...directory导出 【spark暂不支持】

导出到本地:

INSERT OVERWRITE LOCAL directory '/home/spark/hivetmp/'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
select * from page_views;

导出到HDFS:

INSERT OVERWRITE directory '/hivetmp/'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
select * from page_views;

报错:cannot recognize input near 'ROW' 'FORMAT' 'DELIMITED' in select clause

INSERT OVERWRITE directory '/hivetmp/'
select * from page_views;

注意: 导出到本地可以通过ROW FORMAT来设置分隔符,导出到HDFS是不能设置分隔符的

 

方式三: shell命令 + 管道(hive -f/-e | sed/grep/awk > file)

hive -e "select * from page_views limit 5"
hive -S -e "select * from page_views limit 5" | grep B58W48U4WKZCJ5D1T3Z9ZY88RU7QA7B1
hive -S -e "select * from page_views limit 5" | grep B58W48U4WKZCJ5D1T3Z9ZY88RU7QA7B1 > file

 

方式四: sqoop

详见sqoop章节:http://www.cnblogs.com/luogankun/category/601761.html

 

posted on 2014-11-19 16:06  瞌睡中的葡萄虎  阅读(1228)  评论(0编辑  收藏  举报