1.全表导入 mysql表名必须大写,(可以指定列名,也可以不指定 –columns中 逗号分隔,不加空格),可以添加条件过滤 --where
sqoop import -Dorg.apache.sqoop.splitter.allow_text_splitter=true --connect jdbc:mysql://192.168.0.116:3306/bigdata -driver com.mysql.jdbc.Driver --username root --password root--table CITY_DAY --columns "ID,DAYTIME,CITYCODE,SO2,CO,NO2,O3,PM10,PM2_5,AQI,MEASURE,TIMEPOINT" --where "id= '9:110000:20180101'" -null-string '\\N' --null-non-string '\\N' --hbase-table air:airTest --column-family f1 --hbase-row-key ID
2,增量导入 append方式,指定列不能是varchar 最好是int类型(大于等于指定值)
sqoop import -Dorg.apache.sqoop.splitter.allow_text_splitter=true --connect jdbc:mysql://192.168.0.116:3306/bigdata -driver com.mysql.jdbc.Driver --username root --password root --table CITY_DAY -null-string '\\N' --null-non-string '\\N' --hbase-table air:test02 --column-family f1 --hbase-row-key ID --incremental append --check-column 'DAYTIME' --last-value 20180113 --m 1
3,增量导入 lastmodified方式, 该字段在数据库中格式是date类型
使用lastmodified模式进行增量处理要指定增量数据是以append模式(附加)还是merge-key(合并,通常是更新某个字段后,按照key,合并)模式添加
sqoop import -Dorg.apache.sqoop.splitter.allow_text_splitter=true --connect jdbc:mysql://192.168.0.116:3306/bigdata -driver com.mysql.jdbc.Driver --username root --password root --table CITY_DAY -null-string '\\N' --null-non-string '\\N' --hbase-table air:test03 --column-family f1 --hbase-row-key ID --incremental lastmodified --check-column TIMEPOINT --last-value '2018-01-13' --append --m 1
参考:
https://blog.csdn.net/zleven/article/details/53781111