Sqoop导入hbase

Mysql创建表

  1. mysql> create table test.smq_to_hbase select id,name,name grade from test.smq_mysql;
  2. mysql> update test.smq_to_hbase set grade = '1';
  3. mysql> Alter table test.smq_to_hbase add primary key(id);

Hbase创建表

  1. hbase(main):008:0> create 'smq_hbase','info'

Sqoop导入hbase中

  1. [root@master bin]# sqoop import
  2. --connect jdbc:mysql://192.168.220.20:3306/test
  3. --username root --password 123456
  4. --table smq_to_hbase
  5. --hbase-table smq_hbase
  6. --column-family info
  7. --hbase-row-key id

Sqoop导出hbase

Hbase→hive外部表→hive内部表→通过sqoop→mysql

Mysql创建空表

  1. mysql> create table test.employee(rowkey int(11),id int(11),name varchar(20),primary key (id));