• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >云计算 > [Hive]MapReduce将数据写入Hive分区表,mapreducehive

[Hive]MapReduce将数据写入Hive分区表,mapreducehive

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含hive mapreduce,mapreduce 分区,mapreduce过滤数据,mapreduce数据流图,mapreduce数据倾斜等服务器相关知识,网友希望可以进行参考

[Hive]MapReduce将数据写入Hive分区表,mapreducehive


业务需求:

将当天产生的数据写入Hive分区表中(以日期作为分区)

业务分析:

利用MapReduce将数据写入Hive表实则上就是将数据写入至Hive表的HDFS目录下,但是问题在于写入至当天的分区,因此问题转换为:如何事先创建Hive表的当天分区

解决方案:

1. 创建Hive表

# 先创建分区表rcmd_valid_path
hive -e "set mapred.job.queue.name=pms;

drop table if exists pms.test_rcmd_valid_path;
create table if not exists pms.test_rcmd_valid_path 
(
track_id string,
track_time string,
session_id string,
gu_id string,
end_user_id string,
page_category_id bigint,
algorithm_id int,
is_add_cart int,
rcmd_product_id bigint,
product_id bigint,
path_id string,
path_type string,
path_length int,
path_list string,
order_code string,
groupon_id bigint
)
partitioned by (ds string) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' 
LINES TERMINATED BY '\n';"
2. 创建表的date当天分区(若分区不存在则创建)

# 创建正式表rcmd_valid_path表date当天的分区目录
hive -e "set mapred.job.queue.name=pms;

insert overwrite table pms.test_rcmd_valid_path partition(ds='$date')
select track_id,
track_time,
session_id,
gu_id,
end_user_id,
page_category_id,
algorithm_id,
is_add_cart,
rcmd_product_id,
product_id,
path_id,
path_type,
path_length,
path_list,
order_code,
groupon_id 
from pms.test_rcmd_valid_path where ds = '$date';" 
3. Job直接写入即可(留意job2OutputPath)

hadoop jar lib/bigdata-datamining-1.1-user-trace-jar-with-dependencies.jar com.yhd.datamining.data.usertrack.offline.job.mapred.TrackPathJob \
--similarBrandPath /user/pms/recsys/algorithm/schedule/warehouse/relation/brand/$yesterday \
--similarCategoryPath /user/pms/recsys/algorithm/schedule/warehouse/relation/category/$yesterday \
--mcSiteCategoryPath /user/hive/warehouse/mc_site_category \
--extractPreprocess /user/hive/warehouse/test_extract_preprocess \
--engineMatchRule /user/pms/recsys/algorithm/schedule/warehouse/mix/artificial/product/$yesterday \
--artificialMatchRule /user/pms/recsys/algorithm/schedule/warehouse/ruleengine/artificial/product/$yesterday \
--category /user/hive/warehouse/category \
--keywordCategoryTopN 3 \
--termCategory /user/hive/pms/temp_term_category \
--extractGrouponInfo /user/hive/pms/extract_groupon_info \
--extractProductSerial /user/hive/pms/product_serial_id \
--job1OutputPath /user/pms/workspace/ouyangyewei/testUsertrack/job1Output \
--job2OutputPath /user/hive/pms/test_rcmd_valid_path/ds=$date 

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Hive之简单查询不启用MapReduce,hive启用mapreduce
  • [Hive]MapReduce将数据写入Hive分区表,mapreducehive

相关文章

  • SSH无密码登陆配置,ssh无密码登陆
  • 关于HIVE数据仓库的基本操作,hive数据仓库
  • Mahout-HashMap的进化版FastByIdMap,mahout
  • Mesos资料收集(持续更新),mesos资料收集
  • zookeeper——分布式锁,zookeeper
  • hdfs一致性模型,hdfs一致性
  • 分布式系列,分布式系统
  • Hadoop之——HBASE结合MapReduce批量导入数据,hadoopmapreduce
  • Spark开发指南,spark指南
  • hadoop一些常见报错的解决方案,hadoop解决方案

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • zookeeper的安装,搭建,zookeeper安装搭建
    • HDFS小文件的合并优化
    • HIVE动态分区实战,hive动态实战
    • CDH5 hadoop-hive-habse单机版配置,hadoophivehbase
    • spark core源码分析14 参数配置,sparkcore
    • JOIN操作,数据库join操作
    • shell命令curl抓取网页内容-下载xls文件,
    • What's Wrong With Hue Oozie Editor?,hueoozie
    • 几本京东上的CISCO云计算相关书籍,cisco相关书籍
    • CRM市场及Zoho模式,CRM市场Zoho模式

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有