0
点赞
收藏
分享

微信扫一扫

sqoop同步数据mysql---->hive

googlefrank 2022-04-17 阅读 60

通过sqoop把MySQL数据库中mysql库的表同步到hive上。

前提:开启Hadoop

1.查看hive中的表,为了方便验证实验的成功与否。

2.查看MySQL数据库中的表。

3.同步表结构

MySQL中的表为:time_zone_transition_type、time_zone_leap_second

hive中的表为:time_zone_transition_type、time_zone_leap_second

MySQL中的数据库名为:mysql

sqoop create-hive-table -connect jdbc:mysql://192.168.17.135:3306/mysql -table time_zone_transition_type  -username root -password 123456 -hive-table time_zone_transition_type

sqoop create-hive-table -connect jdbc:mysql://192.168.17.135:3306/mysql -table time_zone_leap_second  -username root -password 123456 -hive-table time_zone_leap_second

 desc看一下结构!

4.同步表内容。

注:hive中可以不提前建表也可以导入进去。

MySQL中的表为:db、func

hive中的表为:hive_db、hive_func

MySQL中的数据库名为:mysql

sqoop import -connect jdbc:mysql://192.168.17.135:3306/mysql -username root -password 123456 -table db -hive-import -hive-table hive_db -m 1

sqoop import -connect jdbc:mysql://192.168.17.135:3306/mysql -username root -password 123456 -table func -hive-import -hive-table hive_func -m 1

select看一下数据!

举报

相关推荐

0 条评论