美文网首页
04 使用Sqoop将mysql数据导入hbase

04 使用Sqoop将mysql数据导入hbase

作者: 张力的程序园 | 来源:发表于2020-06-30 21:06 被阅读0次

本节演示使用Sqoop将mysql数据导入hbase。

1、前提约束

2、操作步骤

(1)mysql数据导入hbase

  • 在mysql中初始化数据,执行以下命令:
mysql -uroot -pzhangli
create database test;
use test;
create table t_info(id int,name varchar(20),age int);
insert into t_info(id,name,age) values(1,'ali',20);
insert into t_info(id,name,age) values(2,'xiaoli',3);
exit;
  • 在hbase中初始化表,执行以下命令:
cd /root/hbase-1.2.6/bin
./hbase
create 't1','f1'
exit
  • 把mysql数据导入hbase
cd /root/hbase-1.2.6
./sqoop import --connect jdbc:mysql://localhost:3306/test --username root --password zhangli --table t_user --hbase-table t1 --column-family f1 --hbase-create-table --hbase-row-key id

如此,就完成了把mysql导入了hbase。

相关文章

网友评论

      本文标题:04 使用Sqoop将mysql数据导入hbase

      本文链接:https://www.haomeiwen.com/subject/oxffqktx.html