当前位置:网站首页>E-commerce data warehouse ODS layer-----log data loading
E-commerce data warehouse ODS layer-----log data loading
2022-08-03 21:34:00 【big data theory】
First generate the simulated log data and upload it to hdfs层
再将hdfsThe log data in the cut data is loaded intoODS层日志
一般企业在搭建数仓时,业务系统中会存在一定的历史数据,此处为模拟真实场景,需准备若干历史数据.假定数仓上线的日期为2020-06-14,具体说明如下.
1.用户行为日志
用户行为日志,一般是没有历史数据的,故日志只需要准备2020-06-14一天的数据.具体操作如下:
1)启动日志采集通道,包括Flume、Kafak等
2)修改两个日志服务器(hadoop102、hadoop103)中的/opt/module/applog/application.yml配置文件,将mock.date参数改为2020-06-14.
3)执行日志生成脚本lg.sh.
4)观察HDFS是否出现相应文件.
以下使用datagripData warehouse tools and script commands
create database gmall;
– ODS层
– ODS日志表
drop table if exists ods_log;
create external table ods_log(linestring)
partitioned by (dtstring) --按照时间创建分区
stored as inputformat ‘com.hadoop.mapred.DeprecatedLzoTextInputFormat’
–指定存储格式,读数据采用LzoTextInputFormat;
OUTPUTFORMAT ‘org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat’
LOCATION ‘/warehourse/gmall/ods/ods_log’ --指定数据在hdfs上的存储位置
;
–数据装载语句:Load with a load script
–2020-06-14
//load data inpath ‘/origin_data/gmall/log/topic_log/2020-06-14’ into table ods_log partition(dt=‘2020-06-14’);
–为hiveCreate an index on the files in the table
// [bin]$ hadoop jar /opt/module/hadoop3.1.3/share/common/hadoop-lzo-0.4.20.jar
– com.hadoop.compression.lzo.DistributedLzoIIndexer /warehouse/gmall/ods/ods_log/dt=2020-06-14
// 即hadoop jar jar包位置 全类名 to create an indexlzo文件所在的路径
//创建脚本 vim hdfs_to_ods_log.sh 再 chmod 777 hdfs_ods_log.sh
/*
#!/bin/bash
定义变量方便修改
APP=gmall
hive=/opt/module/hive/bin/hive
如果是输入的日期按照取输入日期;如果没输入日期取当前时间的前一天
if [ -n “$1” ] ;then
do_date=$1
else
do_date=date -d "-1 day" +%F
fi
echo ================== 日志日期为 d o d a t e = = = = = = = = = = = = = = = = = = s q l = " l o a d d a t a i n p a t h ′ / o r i g i n d a t a / do_date ================== sql=" load data inpath '/origin_data/ dodate==================sql="loaddatainpath′/origindata/APP/log/topic_log/$do_date’ into table A P P . o d s l o g p a r t i t i o n ( d t = ′ {APP}.ods_log partition(dt=' APP.odslogpartition(dt=′do_date’);
"
h i v e − e " hive -e " hive−e"sql"
hadoop jar /opt/module/hadoop-3.1.3/share/hadoop/common/hadoop-lzo-0.4.20.jar com.hadoop.compression.lzo.DistributedLzoIndexer /warehouse/ A P P / o d s / o d s l o g / d t = APP/ods/ods_log/dt= APP/ods/odslog/dt=do_date
*/
After executing the script, the files in the original path are gone,剪切到了ODSlayer in the log layer

通过datagripYou can see that the data is loaded into the table
Double-click a table to view table data
边栏推荐
- buildscript和allprojects的作用和区别是什么?
- From September 1st, my country has granted zero-tariff treatment to 98% of tax items from 16 countries including Togo
- 研究Fabric中Etcd的Raft应用
- 461. 汉明距离
- 15年软件架构师经验总结:在ML领域,初学者踩过的五个坑
- 这几个常用 alias,带你高效做事(下)
- 【kali-漏洞利用】(3.2)Metasploit基础(上):基础知识
- 电商数仓ODS层-----日志数据装载
- 七夕快乐!
- CAS:122567-66-2_DSPE-生物素_DSPE-Biotin
猜你喜欢

Diazo Biotin-PEG3-DBCO|重氮化合物修饰生物素-三聚乙二醇-二苯并环辛炔

卷起来!阿里高工携 18 位高级架构师耗时 57 天整合的 1658 页面试总结

CC2530_ZigBee+华为云IOT:设计一套属于自己的冷链采集系统

idea2021.1.3版本如何启动多个客户端程序

shell编程基础

XSS practice - cycle and two cycle problem at a time

小朋友学C语言(3):整数、浮点数、字符

史兴国对谈于佳宁:从经济模式到落地应用,Web3的中国之路怎么走?

Interesting opencv - record image binarization and similarity

『百日百题 · 基础篇』备战面试,坚持刷题 第四话——循环语句!
随机推荐
XSS online shooting range---Warmups
【使用 Pytorch 实现入门级的人工神经网络】
LitJson报错记录
ES6--residual parameters
2022年1~7月语音合成(TTS)和语音识别(ASR)论文月报
跨端开发技术储备记录
聚焦开源与联合共创|麒麟软件出席开源峰会欧拉分论坛
gtk实现图片旋转
史兴国对谈于佳宁:从经济模式到落地应用,Web3的中国之路怎么走?
小朋友学C语言(1):Hello World
Five Steps to Detect and Control Shadow IT
LVS负载均衡集群
YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响
Interesting opencv - record image binarization and similarity
敏捷交付的工程效能治理
服务器安装redis
现网设备兼容SRv6网络演进
线程池的高级应用技巧核心解读
2022-8-3 第七组 潘堂智 锁、多线程
6. XML