今日进度

Result文件数据说明:

Ip106.39.41.166,(城市)

Date10/Nov/2016:00:01:02 +0800,(日期)

Day10,(天数)

Traffic: 54 ,(流量)

Type: video,(类型:视频video或文章article

Id: 8701(视频或者文章的id

测试要求:

1、 数据清洗:按照进行数据清洗,并将清洗后的数据导入MongDB数据库中

两阶段数据清洗:

1)第一阶段:把需要的信息从原始日志中提取出来

ip:    199.30.25.88

time:  10/Nov/2016:00:01:03 +0800

traffic:  62

文章: article/11325

视频: video/3235

 

create database data;

CREATE TABLE `data_01` ( `ip` string ,
                       `date` string,
                       `day` string,
                       `traffic` string,
                       `type` string ,
                       `id` string
) row format delimited fields terminated by ',' STORED AS TEXTFILE;

load data  local inpath  '/kkb/data/hive-import/result.txt' into table data_01;

 

2)第二阶段:根据提取出来的信息做精细化操作

ip--->城市 cityIP

date--> time:2016-11-10 00:01:03

day: 10

traffic:62

type:article/video

id:11325

 

 

3MongDB数据库表结构:

create table data(  ip string,  time string , day string, traffic bigint,

type string, id   string )

2、数据处理:

·统计最受欢迎的视频/文章的Top10访问次数 (video/article

 

CREATE TABLE `id_01` ( `id` string ,
                         `id_count` string
) row format delimited fields terminated by ',' STORED AS TEXTFILE;


insert into id_01 (select id,count(id) from data_02 group by id  order by count(id) desc limit 10);

 

·按照地市统计最受欢迎的Top10课程 (ip

CREATE TABLE `ip_01` ( `ip` string ,
                       `ip_count` string
) row format delimited fields terminated by ',' STORED AS TEXTFILE;
insert into ip_01 (select ip,count(ip) from data_02 group by ip  order by count(ip) desc limit 10);

 

·按照流量统计最受欢迎的Top10课程 (traffic

CREATE TABLE `traffic_01` ( `id` string ,
                       `traffic_sum` string
) row format delimited fields terminated by ',' STORED AS TEXTFILE;

insert into traffic_01(
    select id,sum(traffic) from data_02 group by id  order by sum(traffic) desc limit 10
);

 

3、数据可视化:将统计结果倒入MySql数据库中,通过图形化展示的方式展现出来。

导入到mysql

bin/sqoop export \

--connect jdbc:mysql://node01:3306/data \

--username root \

--password hadoop \

--table id_01 \

--num-mappers 1 \

--export-dir /user/hive/warehouse/data.db/id_01 \

--input-fields-terminated-by ","

 

 

bin/sqoop export \

--connect jdbc:mysql://node01:3306/data \

--username root \

--password hadoop \

--table ip_01 \

--num-mappers 1 \

--export-dir /user/hive/warehouse/data.db/ip_01 \

--input-fields-terminated-by ","

 

bin/sqoop export \

--connect jdbc:mysql://node01:3306/data \

--username root \

--password hadoop \

--table traffic_01 \

--num-mappers 1 \

--export-dir /user/hive/warehouse/data.db/traffic_01 \

--input-fields-terminated-by ","

 

最受欢迎的视频/文章的Top10访问次数 (video/article

 

按照地市统计最受欢迎的Top10课程 (ip

 

按照流量统计最受欢迎的Top10课程 (traffic

 

posted @ 2021-11-08 19:36  一口獠牙  阅读(48)  评论(0编辑  收藏  举报