当前位置:网站首页>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(line
string)
partitioned by (dt
string) --按照时间创建分区
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
边栏推荐
- gtk实现图片旋转
- [kali-vulnerability scanning] (2.1) Nessus download and installation (on)
- 有趣的opencv-记录图片二值化和相似度实现
- Zero trust, which has been popular for more than ten years, why can't it be implemented?
- 这几个常用 alias,带你高效做事(下)
- 【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
- CAS:908007-17-0_Biotin-azide _生物素叠氮化物
- 主板设计中:网络变压器与RJ45网口之间应该保持什么样的距离?
- 如何使用 Jmeter获取登录token并设置为全局变量?
- 开源一夏 |如何优化线上服务器
猜你喜欢
[kali-vulnerability exploitation] (3.2) Metasploit basics (on): basic knowledge
CAS: 773888-45-2_BIOTIN ALKYNE_生物素-炔基
XSS线上靶场---prompt
软件测试人员必备的60个测试工具清单,建议收藏一波~
template string
XSS practice - cycle and two cycle problem at a time
码率vs.分辨率,哪一个更重要?
手动输入班级人数及成绩求总成绩和平均成绩?
XSS online shooting range---Warmups
安全基础8 ---XSS
随机推荐
AI首席架构师13-AICA-智能文档分析技术在行业场景中的应用
Nacos配置文件管理、微服务获取Nacos配置文件
图神经网络怎么入门?一文带你了解图神经网络入门路径-GNN入门
False label aggregation
LitJson报错记录
【使用 Pytorch 实现入门级的人工神经网络】
[kali-vulnerability scanning] (2.1) Nessus lifts IP restrictions, scans quickly without results, and plugins are deleted (middle)
跨端开发技术储备记录
业界新标杆!阿里开源自研高并发编程核心笔记(2022 最新版)
剑指 Offer 16. 数值的整数次方
461. 汉明距离
A. Color the Picture- Codeforces Round #810 (Div. 1)
CAS:1797415-74-7_TAMRA-Azide-PEG-Biotin
从0到1看支付
2022/08/03 学习笔记 (day23)多线程(补充)
How to deal with commas in the content of the CSV file of the system operation and maintenance series
这几个常用 alias,带你高效做事(下)
win10安装及配置Gradle
【Unity3D】Tank对战
太香了! 阿里 Redis 速成笔记, 从头到尾全是精华!