先贴上我的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 参数的设置有关系。
原因:
- sqoop版本。1.4.6.2.5.0.0-1245
- 看官网:http://sqoop.apache.org/docs/1.4.7/SqoopUserGuide.html#_free_form_query_imports ====》Controlling Parallelism
- 官网原文贴上: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-mapper
option 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 - 提炼重点:
- 首先:你的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' 看下
问题得到解决