=== 在同时对应的hive中如下表
create table users(
id int,
name string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;
create table tags(
id int,
user_id int,
tag string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;
在hive中准备数据
load data local inpath '/home/hadoop/data/users.txt' overwrite into table users;
--users.txt
1 jeffery
2 shirdrn
3 sulee
load data local inpath '/home/hadoop/data/tags.txt' overwrite into table tags;
--tags.txt
1 1 music
2 1 programing
3 2 travel
4 3 sport
============在MySQL中准备如下的表
create database tag_db;
create table tag_db.users(
id int(11) not null,
name VARCHAR(100) NOT NULL,
PRIMARY KEY(id)
)
engine= innodb default charset=utf8;
create table tag_db.tags(
id int(11) not null,
user_id int not null,
tag VARCHAR(10) NOT NULL,
PRIMARY KEY(id)
)
engine= innodb default charset=utf8;
sqoop export \
--connect jdbc:mysql://node1.oracle.com:3306/tag_db \
--username root \
--password oracle \
--table tags \
--export-dir /user/hive/warehouse/tags \
--num-mappers 2 \
--input-fields-terminated-by '\t'
--default-character-set=utf8
sqoop export \
--connect jdbc:mysql://node1.oracle.com:3306/tag_db \
--username root \
--password oracle \
--table users \
--export-dir /user/hive/warehouse/users \
--num-mappers 2 \
--input-fields-terminated-by '\t'
create table users(
id int,
name string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;
create table tags(
id int,
user_id int,
tag string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;
在hive中准备数据
load data local inpath '/home/hadoop/data/users.txt' overwrite into table users;
--users.txt
1 jeffery
2 shirdrn
3 sulee
load data local inpath '/home/hadoop/data/tags.txt' overwrite into table tags;
--tags.txt
1 1 music
2 1 programing
3 2 travel
4 3 sport
============在MySQL中准备如下的表
create database tag_db;
create table tag_db.users(
id int(11) not null,
name VARCHAR(100) NOT NULL,
PRIMARY KEY(id)
)
engine= innodb default charset=utf8;
create table tag_db.tags(
id int(11) not null,
user_id int not null,
tag VARCHAR(10) NOT NULL,
PRIMARY KEY(id)
)
engine= innodb default charset=utf8;
sqoop export \
--connect jdbc:mysql://node1.oracle.com:3306/tag_db \
--username root \
--password oracle \
--table tags \
--export-dir /user/hive/warehouse/tags \
--num-mappers 2 \
--input-fields-terminated-by '\t'
--default-character-set=utf8
sqoop export \
--connect jdbc:mysql://node1.oracle.com:3306/tag_db \
--username root \
--password oracle \
--table users \
--export-dir /user/hive/warehouse/users \
--num-mappers 2 \
--input-fields-terminated-by '\t'