使用hbase shell创建好表:create "tobacco_price","info"。如果在sqoop导入语句中使用--hbase-create-table创建表,会报错。
使用sqoop将mysql的数据导入到hbase中(自己指定列的情形)
./sqoop import --connect "jdbc:mysql://192.168.127.12/asto_ec_origin?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true" --username root --password 123456 --table datag_tobacco_price_list --columns "id,area_code,name,brand,wholesale_price,retail_price,producer_name,gmt_created,gmt_modified" --hbase-table tobacco_price --column-family info --hbase-row-key id -m 1
(默认列名)
./sqoop import --connect "jdbc:mysql://192.168.127.12/asto_ec_origin?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true" --username root --password 123456 --table datag_tobacco_price_list --hbase-table tobacco_price2 --column-family info --hbase-row-key id -m 1
如果rowkey需要两个字段的组合,可以用逗号分隔,如:
--hbase-row-key id,area_code