hadoophive与Oracle如何互相导入数据
这篇文章给大家分享的是有关hadoop hive与Oracle如何互相导入数据的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
站在用户的角度思考问题,与客户深入沟通,找到宜宾网站设计与宜宾网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站建设、网站建设、企业官网、英文网站、手机端网站、网站推广、国际域名空间、虚拟空间、企业邮箱。业务覆盖宜宾地区。
#1.在Oracle上建立要处理的表 create table SOURCE_TABLE_NAME as SELECT t.*,rownum as row_num FROM SOURCE_TABLE_NAME_O t ; alter table SOURCE_TABLE_NAME add constraint SOURCE_TABLE_NAME_P primary key (ROW_NUM); #2.在Oracle上建立处理结果表 DEST_TABLE_NAME #3.oracle导入到hadoop nohup \ sqoop import \ --hive-import \ --connect jdbc:oracle:thin:@192.168.1.14:1521:oradb1 \ --username USER1 \ --password "密码" \ --verbose -m 32 \ --table SOURCE_TABLE_NAME \ --hive-table db_hive.SOURCE_TABLE_NAME \ --fields-terminated-by '\t' \ --lines-terminated-by '\n' & #4.计算 hive -e "drop table db_hive.DEST_TABLE_NAME ; create table db_hive.DEST_TABLE_NAME row format delimited fields terminated by '\t' STORED AS TEXTFILE as \ select \ max(Dn) as Dn, \ EutranCellTdd_uk , \ max(EutranCellTdd_name) as EutranCellTdd_name, \ max(GsmRelation) as GsmRelation, \ adj_uk, \ max(adj_name) as adj_name, \ max(EnbFunction_uk) as EnbFunction_uk, \ max(EnbFunction_name) as EnbFunction_name, \ max(ManagedElement_uk) as ManagedElement_uk, \ max(ManagedElement_name) as ManagedElement_name, \ max(omc_uk) as omc_uk, \ max(omc_name) as omc_name, \ sum(HO_ToGsmAttOutPerRelation) as HO_ToGsmAttOutPerRelation, \ sum(HO_ToGsmSuccOutPrepPerRelation) as HO_ToGsmSuccOutPrepPerRelation, \ sum(HO_ToGsmSuccOutPerRelation) as HO_ToGsmSuccOutPerRelation, \ max(VENDOR_UK) as VENDOR_UK, \ max(VENDOR_NAME) as VENDOR_NAME, \ max(city_name) as city_name \ from db_hive.SOURCE_TABLE_NAME \ group by EutranCellTdd_uk, adj_uk ;" #5.hadoop导出oracle(需要清空目标表DEST_TABLE_NAME) sqoop export \ --connect jdbc:oracle:thin:@192.168.1.14:1521:oradb1 \ --username USER1 \ --password "密码" \ --table DEST_TABLE_NAME \ --export-dir /user/hive/warehouse/db_hive.db/DEST_TABLE_NAME \ --input-fields-terminated-by '\t' \ --input-lines-terminated-by '\n' \ --null-string '\\N' \ --null-non-string '\\N'
感谢各位的阅读!关于“hadoop hive与Oracle如何互相导入数据”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
标题名称:hadoophive与Oracle如何互相导入数据
本文网址:http://azwzsj.com/article/pecjdd.html