异常:sqoop,hbase,NoSuchMethodError,HTableDescriptor,addFamily

场景

  • Sqoop 1.4.6
  • Mysql 5.6
  • Hadoop 2.6.4
  • HBase 1.2.2

将mysql的数据导入到hbase中

Commond

sqoop import --connect jdbc:mysql://localhost:3306/hadoop --username root --password welcome --table employee --hbase-table employeeHBase --columns empid,empname,salray --column-family hbase_table_col --hbase-row-key empid --hbase-create-table

Error

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.hbase.HTableDescriptor.addFamily(Lorg/apache/hadoop/hbase/HColumnDescriptor;)V
   at org.apache.sqoop.mapreduce.HBaseImportJob.jobSetup(HBaseImportJob.java:222)
   at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:264)
   at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:673)
   at org.apache.sqoop.manager.MySQLManager.importTable(MySQLManager.java:118)
   at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:497)
   at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605)
   at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
   at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
   at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
   at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
   at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
   at org.apache.sqoop.Sqoop.main(Sqoop.java:236)

Solution 1

版本不匹配,改变成合适的版本

Incompatible version of Client. Please make sure that HBase client and server jar version is same.

Versions are: Hadoop Version; 2.6.0 Hbase: 1.0.1 SQOOP: 1.4.6

Solution 2

跳过Sqoop的HBase建表方法,手动建表

新建hbase表

hbase shell
create 'mysql_trade_dev', 'region'

导入mysql数据到hbase

bin/sqoop import --connect jdbc:mysql://192.168.1.187:3306/trade_dev --username 'mysql' --password '111111' --table TB_REGION --hbase-table mysql_trade_dev --hbase-row-key REGION_ID --column-family region

验证

scan 'mysql_trade_dev'
count 'mysql_trade_dev'

参阅

issue-while-importing-the-data-from-mysql-to-hbase

你可能感兴趣的:(异常:sqoop,hbase,NoSuchMethodError,HTableDescriptor,addFamily)