“采集分析购物平台数据”的版本间的差异
来自CloudWiki
201708010242(讨论 | 贡献) |
201708010242(讨论 | 贡献) |
||
第15行: | 第15行: | ||
− | == | + | == 建表,加载数据 == |
+ | 创建hongya数据库,并且查看 | ||
+ | <nowiki>create database hongya; | ||
+ | show databases; | ||
+ | </nowiki> | ||
+ | [[文件:Show.png]] | ||
− | + | 建match_data表 | |
+ | |||
+ | <nowiki>create table match_data( | ||
+ | user_id int, | ||
+ | age_range int, | ||
+ | gender int, | ||
+ | merchant_id int, | ||
+ | label int, | ||
+ | activity_log varchar(1000) | ||
+ | ) | ||
+ | row format delimited fields terminated by ',';</nowiki> | ||
+ | 加载数据 | ||
+ | |||
+ | <nowiki> | ||
+ | load data local | ||
+ | inpath '/opt/soft/train_format2.csv' | ||
+ | overwrite into table match_data;</nowiki> | ||
+ | |||
+ | [[文件:数据加载完成.png]] | ||
+ | |||
+ | select * from match_data limit 100; | ||
+ | |||
+ | [[文件:查看前一百行.png]] |
2018年11月19日 (一) 12:46的版本
.
使用 hive 对数据进行操作
在 master 上执行:
(1)# start-all.sh (启动 hadoop) (2)# zkServer.sh start(各个节点均执行) (3)# start-hbase.sh (直接运行这个命令需要将 HBASE 的 bin 目录也加
入到/etc/environment 中) (4)# 在 slave1 上输入命令:bin/hive --service metastore 启动 hive server,然后在 master 节点上输入命令:bin/hive 启动 hive 客户端,当所有 进程启动完全后方可执行以下操作。(所有命令需要在 hive 的安装目录下输入)
建表,加载数据
创建hongya数据库,并且查看
create database hongya; show databases;
建match_data表
create table match_data( user_id int, age_range int, gender int, merchant_id int, label int, activity_log varchar(1000) ) row format delimited fields terminated by ',';
加载数据
load data local inpath '/opt/soft/train_format2.csv' overwrite into table match_data;
select * from match_data limit 100;