sqoop导入数据到hbase问题

先贴上我的sqoop的脚本:

sqoop import -D sqoop.hbase.add.row.key=true --connect jdbc:mysql://192.168.1.57:3306/test --username xxxx --password xxxx --table dmp_tag --columns MAC,TC_VERSION,CHIP,CITY,SOURCE  --hbase-create-table --hbase-table test_hbase --column-family cf --hbase-row-key MAC -m 2

报错:

java.io.IOException: Generating splits for a textual index column allowed only in case of "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" property passed as a parameter

经过排查发现可能是跟 -m  参数的设置有关系。
 

原因:

  1. sqoop版本。1.4.6.2.5.0.0-1245
  2. 看官网:http://sqoop.apache.org/docs/1.4.7/SqoopUserGuide.html#_free_form_query_imports ====》Controlling Parallelism
  3. 官网原文贴上:If a table does not have a primary key defined and the --split-by <col> is not provided, then import will fail unless the number of mappers is explicitly set to one with the --num-mappers 1 option or the --autoreset-to-one-mapperoption is used. The option --autoreset-to-one-mapper is typically used with the import-all-tables tool to automatically handle tables without a primary key in a schema
  4. 提炼重点:
  • 首先:你的mysql表要有 主键 
  • 其次:你要指定  --split-by  字段  

否则就是给你默认的是 1

 

解决方案:


sqoop import -D sqoop.hbase.add.row.key=true --connect jdbc:mysql://192.168.1.57:3306/test --username xxxx --password xxxx --table dmp_tag --columns MAC,TC_VERSION,CHIP,CITY,SOURCE --split-by SOURCE --hbase-create-table --hbase-table test_hbase --column-family cf --hbase-row-key MAC -m 2

这里的hbase的表你是可以不用自己创建的,会自动创建,但是创建完毕是否符合你的胃口,你要自己去desc 'tablename' 看下

问题得到解决
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值